[PATCH] sysctl: remove insert_at_head from register_sysctl
[sfrench/cifs-2.6.git] / fs / lockd / svc.c
index 3cc369e5693f2d9af1c34e605c1ba2c615a21eae..50cb8daba4e5c7962282bcdbe6fa55cd7558ea1d 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/sunrpc/svcsock.h>
 #include <net/ip.h>
 #include <linux/lockd/lockd.h>
+#include <linux/lockd/sm_inter.h>
 #include <linux/nfs.h>
 
 #define NLMDBG_FACILITY                NLMDBG_SVC
@@ -61,6 +62,7 @@ static DECLARE_WAIT_QUEUE_HEAD(lockd_exit);
 static unsigned long           nlm_grace_period;
 static unsigned long           nlm_timeout = LOCKD_DFLT_TIMEO;
 static int                     nlm_udpport, nlm_tcpport;
+int                            nsm_use_hostnames = 0;
 
 /*
  * Constants needed for the sysctl interface.
@@ -139,6 +141,7 @@ lockd(struct svc_rqst *rqstp)
         */
        while ((nlmsvc_users || !signalled()) && nlmsvc_pid == current->pid) {
                long timeout = MAX_SCHEDULE_TIMEOUT;
+               char buf[RPC_MAX_ADDRBUFLEN];
 
                if (signalled()) {
                        flush_signals(current);
@@ -173,11 +176,10 @@ lockd(struct svc_rqst *rqstp)
                        break;
                }
 
-               dprintk("lockd: request from %08x\n",
-                       (unsigned)ntohl(rqstp->rq_addr.sin_addr.s_addr));
+               dprintk("lockd: request from %s\n",
+                               svc_print_addr(rqstp, buf, sizeof(buf)));
 
                svc_process(rqstp);
-
        }
 
        flush_signals(current);
@@ -221,23 +223,29 @@ static int find_socket(struct svc_serv *serv, int proto)
        return found;
 }
 
+/*
+ * Make any sockets that are needed but not present.
+ * If nlm_udpport or nlm_tcpport were set as module
+ * options, make those sockets unconditionally
+ */
 static int make_socks(struct svc_serv *serv, int proto)
 {
-       /* Make any sockets that are needed but not present.
-        * If nlm_udpport or nlm_tcpport were set as module
-        * options, make those sockets unconditionally
-        */
-       static int              warned;
+       static int warned;
        int err = 0;
+
        if (proto == IPPROTO_UDP || nlm_udpport)
                if (!find_socket(serv, IPPROTO_UDP))
-                       err = svc_makesock(serv, IPPROTO_UDP, nlm_udpport);
-       if (err == 0 && (proto == IPPROTO_TCP || nlm_tcpport))
+                       err = svc_makesock(serv, IPPROTO_UDP, nlm_udpport,
+                                               SVC_SOCK_DEFAULTS);
+       if (err >= 0 && (proto == IPPROTO_TCP || nlm_tcpport))
                if (!find_socket(serv, IPPROTO_TCP))
-                       err= svc_makesock(serv, IPPROTO_TCP, nlm_tcpport);
-       if (!err)
+                       err = svc_makesock(serv, IPPROTO_TCP, nlm_tcpport,
+                                               SVC_SOCK_DEFAULTS);
+
+       if (err >= 0) {
                warned = 0;
-       else if (warned++ == 0)
+               err = 0;
+       } else if (warned++ == 0)
                printk(KERN_WARNING
                       "lockd_up: makesock failed, error=%d\n", err);
        return err;
@@ -351,9 +359,6 @@ EXPORT_SYMBOL(lockd_down);
  * Sysctl parameters (same as module parameters, different interface).
  */
 
-/* Something that isn't CTL_ANY, CTL_NONE or a value that may clash. */
-#define CTL_UNNUMBERED         -2
-
 static ctl_table nlm_sysctls[] = {
        {
                .ctl_name       = CTL_UNNUMBERED,
@@ -395,6 +400,22 @@ static ctl_table nlm_sysctls[] = {
                .extra1         = (int *) &nlm_port_min,
                .extra2         = (int *) &nlm_port_max,
        },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "nsm_use_hostnames",
+               .data           = &nsm_use_hostnames,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+       },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "nsm_local_state",
+               .data           = &nsm_local_state,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+       },
        { .ctl_name = 0 }
 };
 
@@ -483,6 +504,7 @@ module_param_call(nlm_udpport, param_set_port, param_get_int,
                  &nlm_udpport, 0644);
 module_param_call(nlm_tcpport, param_set_port, param_get_int,
                  &nlm_tcpport, 0644);
+module_param(nsm_use_hostnames, bool, 0644);
 
 /*
  * Initialising and terminating the module.
@@ -490,7 +512,7 @@ module_param_call(nlm_tcpport, param_set_port, param_get_int,
 
 static int __init init_nlm(void)
 {
-       nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root, 0);
+       nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root);
        return nlm_sysctl_table ? 0 : -ENOMEM;
 }