SUNRPC: call svc_process() from svc_recv().
[platform/kernel/linux-rpi.git] / fs / lockd / svc.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * linux/fs/lockd/svc.c
4  *
5  * This is the central lockd service.
6  *
7  * FIXME: Separate the lockd NFS server functionality from the lockd NFS
8  *        client functionality. Oh why didn't Sun create two separate
9  *        services in the first place?
10  *
11  * Authors:     Olaf Kirch (okir@monad.swb.de)
12  *
13  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
14  */
15
16 #include <linux/module.h>
17 #include <linux/init.h>
18 #include <linux/sysctl.h>
19 #include <linux/moduleparam.h>
20
21 #include <linux/sched/signal.h>
22 #include <linux/errno.h>
23 #include <linux/in.h>
24 #include <linux/uio.h>
25 #include <linux/smp.h>
26 #include <linux/mutex.h>
27 #include <linux/kthread.h>
28 #include <linux/freezer.h>
29 #include <linux/inetdevice.h>
30
31 #include <linux/sunrpc/types.h>
32 #include <linux/sunrpc/stats.h>
33 #include <linux/sunrpc/clnt.h>
34 #include <linux/sunrpc/svc.h>
35 #include <linux/sunrpc/svcsock.h>
36 #include <linux/sunrpc/svc_xprt.h>
37 #include <net/ip.h>
38 #include <net/addrconf.h>
39 #include <net/ipv6.h>
40 #include <linux/lockd/lockd.h>
41 #include <linux/nfs.h>
42
43 #include "netns.h"
44 #include "procfs.h"
45
46 #define NLMDBG_FACILITY         NLMDBG_SVC
47 #define LOCKD_BUFSIZE           (1024 + NLMSVC_XDRSIZE)
48
49 static struct svc_program       nlmsvc_program;
50
51 const struct nlmsvc_binding     *nlmsvc_ops;
52 EXPORT_SYMBOL_GPL(nlmsvc_ops);
53
54 static DEFINE_MUTEX(nlmsvc_mutex);
55 static unsigned int             nlmsvc_users;
56 static struct svc_serv          *nlmsvc_serv;
57 unsigned long                   nlmsvc_timeout;
58
59 unsigned int lockd_net_id;
60
61 /*
62  * These can be set at insmod time (useful for NFS as root filesystem),
63  * and also changed through the sysctl interface.  -- Jamie Lokier, Aug 2003
64  */
65 static unsigned long            nlm_grace_period;
66 static unsigned long            nlm_timeout = LOCKD_DFLT_TIMEO;
67 static int                      nlm_udpport, nlm_tcpport;
68
69 /* RLIM_NOFILE defaults to 1024. That seems like a reasonable default here. */
70 static unsigned int             nlm_max_connections = 1024;
71
72 /*
73  * Constants needed for the sysctl interface.
74  */
75 static const unsigned long      nlm_grace_period_min = 0;
76 static const unsigned long      nlm_grace_period_max = 240;
77 static const unsigned long      nlm_timeout_min = 3;
78 static const unsigned long      nlm_timeout_max = 20;
79
80 #ifdef CONFIG_SYSCTL
81 static const int                nlm_port_min = 0, nlm_port_max = 65535;
82 static struct ctl_table_header * nlm_sysctl_table;
83 #endif
84
85 static unsigned long get_lockd_grace_period(void)
86 {
87         /* Note: nlm_timeout should always be nonzero */
88         if (nlm_grace_period)
89                 return roundup(nlm_grace_period, nlm_timeout) * HZ;
90         else
91                 return nlm_timeout * 5 * HZ;
92 }
93
94 static void grace_ender(struct work_struct *grace)
95 {
96         struct delayed_work *dwork = to_delayed_work(grace);
97         struct lockd_net *ln = container_of(dwork, struct lockd_net,
98                                             grace_period_end);
99
100         locks_end_grace(&ln->lockd_manager);
101 }
102
103 static void set_grace_period(struct net *net)
104 {
105         unsigned long grace_period = get_lockd_grace_period();
106         struct lockd_net *ln = net_generic(net, lockd_net_id);
107
108         locks_start_grace(net, &ln->lockd_manager);
109         cancel_delayed_work_sync(&ln->grace_period_end);
110         schedule_delayed_work(&ln->grace_period_end, grace_period);
111 }
112
113 /*
114  * This is the lockd kernel thread
115  */
116 static int
117 lockd(void *vrqstp)
118 {
119         int             err = 0;
120         struct svc_rqst *rqstp = vrqstp;
121         struct net *net = &init_net;
122         struct lockd_net *ln = net_generic(net, lockd_net_id);
123
124         /* try_to_freeze() is called from svc_recv() */
125         set_freezable();
126
127         dprintk("NFS locking service started (ver " LOCKD_VERSION ").\n");
128
129         /*
130          * The main request loop. We don't terminate until the last
131          * NFS mount or NFS daemon has gone away.
132          */
133         while (!kthread_should_stop()) {
134                 long timeout = MAX_SCHEDULE_TIMEOUT;
135
136                 /* update sv_maxconn if it has changed */
137                 rqstp->rq_server->sv_maxconn = nlm_max_connections;
138
139                 timeout = nlmsvc_retry_blocked();
140
141                 /*
142                  * Find a socket with data available and call its
143                  * recvfrom routine.
144                  */
145                 err = svc_recv(rqstp, timeout);
146                 if (err == -EAGAIN || err == -EINTR)
147                         continue;
148         }
149         if (nlmsvc_ops)
150                 nlmsvc_invalidate_all();
151         nlm_shutdown_hosts();
152         cancel_delayed_work_sync(&ln->grace_period_end);
153         locks_end_grace(&ln->lockd_manager);
154
155         dprintk("lockd_down: service stopped\n");
156
157         svc_exit_thread(rqstp);
158         return 0;
159 }
160
161 static int create_lockd_listener(struct svc_serv *serv, const char *name,
162                                  struct net *net, const int family,
163                                  const unsigned short port,
164                                  const struct cred *cred)
165 {
166         struct svc_xprt *xprt;
167
168         xprt = svc_find_xprt(serv, name, net, family, 0);
169         if (xprt == NULL)
170                 return svc_xprt_create(serv, name, net, family, port,
171                                        SVC_SOCK_DEFAULTS, cred);
172         svc_xprt_put(xprt);
173         return 0;
174 }
175
176 static int create_lockd_family(struct svc_serv *serv, struct net *net,
177                                const int family, const struct cred *cred)
178 {
179         int err;
180
181         err = create_lockd_listener(serv, "udp", net, family, nlm_udpport,
182                         cred);
183         if (err < 0)
184                 return err;
185
186         return create_lockd_listener(serv, "tcp", net, family, nlm_tcpport,
187                         cred);
188 }
189
190 /*
191  * Ensure there are active UDP and TCP listeners for lockd.
192  *
193  * Even if we have only TCP NFS mounts and/or TCP NFSDs, some
194  * local services (such as rpc.statd) still require UDP, and
195  * some NFS servers do not yet support NLM over TCP.
196  *
197  * Returns zero if all listeners are available; otherwise a
198  * negative errno value is returned.
199  */
200 static int make_socks(struct svc_serv *serv, struct net *net,
201                 const struct cred *cred)
202 {
203         static int warned;
204         int err;
205
206         err = create_lockd_family(serv, net, PF_INET, cred);
207         if (err < 0)
208                 goto out_err;
209
210         err = create_lockd_family(serv, net, PF_INET6, cred);
211         if (err < 0 && err != -EAFNOSUPPORT)
212                 goto out_err;
213
214         warned = 0;
215         return 0;
216
217 out_err:
218         if (warned++ == 0)
219                 printk(KERN_WARNING
220                         "lockd_up: makesock failed, error=%d\n", err);
221         svc_xprt_destroy_all(serv, net);
222         svc_rpcb_cleanup(serv, net);
223         return err;
224 }
225
226 static int lockd_up_net(struct svc_serv *serv, struct net *net,
227                 const struct cred *cred)
228 {
229         struct lockd_net *ln = net_generic(net, lockd_net_id);
230         int error;
231
232         if (ln->nlmsvc_users++)
233                 return 0;
234
235         error = svc_bind(serv, net);
236         if (error)
237                 goto err_bind;
238
239         error = make_socks(serv, net, cred);
240         if (error < 0)
241                 goto err_bind;
242         set_grace_period(net);
243         dprintk("%s: per-net data created; net=%x\n", __func__, net->ns.inum);
244         return 0;
245
246 err_bind:
247         ln->nlmsvc_users--;
248         return error;
249 }
250
251 static void lockd_down_net(struct svc_serv *serv, struct net *net)
252 {
253         struct lockd_net *ln = net_generic(net, lockd_net_id);
254
255         if (ln->nlmsvc_users) {
256                 if (--ln->nlmsvc_users == 0) {
257                         nlm_shutdown_hosts_net(net);
258                         cancel_delayed_work_sync(&ln->grace_period_end);
259                         locks_end_grace(&ln->lockd_manager);
260                         svc_xprt_destroy_all(serv, net);
261                         svc_rpcb_cleanup(serv, net);
262                 }
263         } else {
264                 pr_err("%s: no users! net=%x\n",
265                         __func__, net->ns.inum);
266                 BUG();
267         }
268 }
269
270 static int lockd_inetaddr_event(struct notifier_block *this,
271         unsigned long event, void *ptr)
272 {
273         struct in_ifaddr *ifa = (struct in_ifaddr *)ptr;
274         struct sockaddr_in sin;
275
276         if (event != NETDEV_DOWN)
277                 goto out;
278
279         if (nlmsvc_serv) {
280                 dprintk("lockd_inetaddr_event: removed %pI4\n",
281                         &ifa->ifa_local);
282                 sin.sin_family = AF_INET;
283                 sin.sin_addr.s_addr = ifa->ifa_local;
284                 svc_age_temp_xprts_now(nlmsvc_serv, (struct sockaddr *)&sin);
285         }
286
287 out:
288         return NOTIFY_DONE;
289 }
290
291 static struct notifier_block lockd_inetaddr_notifier = {
292         .notifier_call = lockd_inetaddr_event,
293 };
294
295 #if IS_ENABLED(CONFIG_IPV6)
296 static int lockd_inet6addr_event(struct notifier_block *this,
297         unsigned long event, void *ptr)
298 {
299         struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr;
300         struct sockaddr_in6 sin6;
301
302         if (event != NETDEV_DOWN)
303                 goto out;
304
305         if (nlmsvc_serv) {
306                 dprintk("lockd_inet6addr_event: removed %pI6\n", &ifa->addr);
307                 sin6.sin6_family = AF_INET6;
308                 sin6.sin6_addr = ifa->addr;
309                 if (ipv6_addr_type(&sin6.sin6_addr) & IPV6_ADDR_LINKLOCAL)
310                         sin6.sin6_scope_id = ifa->idev->dev->ifindex;
311                 svc_age_temp_xprts_now(nlmsvc_serv, (struct sockaddr *)&sin6);
312         }
313
314 out:
315         return NOTIFY_DONE;
316 }
317
318 static struct notifier_block lockd_inet6addr_notifier = {
319         .notifier_call = lockd_inet6addr_event,
320 };
321 #endif
322
323 static int lockd_get(void)
324 {
325         struct svc_serv *serv;
326         int error;
327
328         if (nlmsvc_serv) {
329                 nlmsvc_users++;
330                 return 0;
331         }
332
333         /*
334          * Sanity check: if there's no pid,
335          * we should be the first user ...
336          */
337         if (nlmsvc_users)
338                 printk(KERN_WARNING
339                         "lockd_up: no pid, %d users??\n", nlmsvc_users);
340
341         if (!nlm_timeout)
342                 nlm_timeout = LOCKD_DFLT_TIMEO;
343         nlmsvc_timeout = nlm_timeout * HZ;
344
345         serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, lockd);
346         if (!serv) {
347                 printk(KERN_WARNING "lockd_up: create service failed\n");
348                 return -ENOMEM;
349         }
350
351         serv->sv_maxconn = nlm_max_connections;
352         error = svc_set_num_threads(serv, NULL, 1);
353         /* The thread now holds the only reference */
354         svc_put(serv);
355         if (error < 0)
356                 return error;
357
358         nlmsvc_serv = serv;
359         register_inetaddr_notifier(&lockd_inetaddr_notifier);
360 #if IS_ENABLED(CONFIG_IPV6)
361         register_inet6addr_notifier(&lockd_inet6addr_notifier);
362 #endif
363         dprintk("lockd_up: service created\n");
364         nlmsvc_users++;
365         return 0;
366 }
367
368 static void lockd_put(void)
369 {
370         if (WARN(nlmsvc_users <= 0, "lockd_down: no users!\n"))
371                 return;
372         if (--nlmsvc_users)
373                 return;
374
375         unregister_inetaddr_notifier(&lockd_inetaddr_notifier);
376 #if IS_ENABLED(CONFIG_IPV6)
377         unregister_inet6addr_notifier(&lockd_inet6addr_notifier);
378 #endif
379
380         svc_set_num_threads(nlmsvc_serv, NULL, 0);
381         nlmsvc_serv = NULL;
382         dprintk("lockd_down: service destroyed\n");
383 }
384
385 /*
386  * Bring up the lockd process if it's not already up.
387  */
388 int lockd_up(struct net *net, const struct cred *cred)
389 {
390         int error;
391
392         mutex_lock(&nlmsvc_mutex);
393
394         error = lockd_get();
395         if (error)
396                 goto err;
397
398         error = lockd_up_net(nlmsvc_serv, net, cred);
399         if (error < 0) {
400                 lockd_put();
401                 goto err;
402         }
403
404 err:
405         mutex_unlock(&nlmsvc_mutex);
406         return error;
407 }
408 EXPORT_SYMBOL_GPL(lockd_up);
409
410 /*
411  * Decrement the user count and bring down lockd if we're the last.
412  */
413 void
414 lockd_down(struct net *net)
415 {
416         mutex_lock(&nlmsvc_mutex);
417         lockd_down_net(nlmsvc_serv, net);
418         lockd_put();
419         mutex_unlock(&nlmsvc_mutex);
420 }
421 EXPORT_SYMBOL_GPL(lockd_down);
422
423 #ifdef CONFIG_SYSCTL
424
425 /*
426  * Sysctl parameters (same as module parameters, different interface).
427  */
428
429 static struct ctl_table nlm_sysctls[] = {
430         {
431                 .procname       = "nlm_grace_period",
432                 .data           = &nlm_grace_period,
433                 .maxlen         = sizeof(unsigned long),
434                 .mode           = 0644,
435                 .proc_handler   = proc_doulongvec_minmax,
436                 .extra1         = (unsigned long *) &nlm_grace_period_min,
437                 .extra2         = (unsigned long *) &nlm_grace_period_max,
438         },
439         {
440                 .procname       = "nlm_timeout",
441                 .data           = &nlm_timeout,
442                 .maxlen         = sizeof(unsigned long),
443                 .mode           = 0644,
444                 .proc_handler   = proc_doulongvec_minmax,
445                 .extra1         = (unsigned long *) &nlm_timeout_min,
446                 .extra2         = (unsigned long *) &nlm_timeout_max,
447         },
448         {
449                 .procname       = "nlm_udpport",
450                 .data           = &nlm_udpport,
451                 .maxlen         = sizeof(int),
452                 .mode           = 0644,
453                 .proc_handler   = proc_dointvec_minmax,
454                 .extra1         = (int *) &nlm_port_min,
455                 .extra2         = (int *) &nlm_port_max,
456         },
457         {
458                 .procname       = "nlm_tcpport",
459                 .data           = &nlm_tcpport,
460                 .maxlen         = sizeof(int),
461                 .mode           = 0644,
462                 .proc_handler   = proc_dointvec_minmax,
463                 .extra1         = (int *) &nlm_port_min,
464                 .extra2         = (int *) &nlm_port_max,
465         },
466         {
467                 .procname       = "nsm_use_hostnames",
468                 .data           = &nsm_use_hostnames,
469                 .maxlen         = sizeof(bool),
470                 .mode           = 0644,
471                 .proc_handler   = proc_dobool,
472         },
473         {
474                 .procname       = "nsm_local_state",
475                 .data           = &nsm_local_state,
476                 .maxlen         = sizeof(int),
477                 .mode           = 0644,
478                 .proc_handler   = proc_dointvec,
479         },
480         { }
481 };
482
483 #endif  /* CONFIG_SYSCTL */
484
485 /*
486  * Module (and sysfs) parameters.
487  */
488
489 #define param_set_min_max(name, type, which_strtol, min, max)           \
490 static int param_set_##name(const char *val, const struct kernel_param *kp) \
491 {                                                                       \
492         char *endp;                                                     \
493         __typeof__(type) num = which_strtol(val, &endp, 0);             \
494         if (endp == val || *endp || num < (min) || num > (max))         \
495                 return -EINVAL;                                         \
496         *((type *) kp->arg) = num;                                      \
497         return 0;                                                       \
498 }
499
500 static inline int is_callback(u32 proc)
501 {
502         return proc == NLMPROC_GRANTED
503                 || proc == NLMPROC_GRANTED_MSG
504                 || proc == NLMPROC_TEST_RES
505                 || proc == NLMPROC_LOCK_RES
506                 || proc == NLMPROC_CANCEL_RES
507                 || proc == NLMPROC_UNLOCK_RES
508                 || proc == NLMPROC_NSM_NOTIFY;
509 }
510
511
512 static int lockd_authenticate(struct svc_rqst *rqstp)
513 {
514         rqstp->rq_client = NULL;
515         switch (rqstp->rq_authop->flavour) {
516                 case RPC_AUTH_NULL:
517                 case RPC_AUTH_UNIX:
518                         rqstp->rq_auth_stat = rpc_auth_ok;
519                         if (rqstp->rq_proc == 0)
520                                 return SVC_OK;
521                         if (is_callback(rqstp->rq_proc)) {
522                                 /* Leave it to individual procedures to
523                                  * call nlmsvc_lookup_host(rqstp)
524                                  */
525                                 return SVC_OK;
526                         }
527                         return svc_set_client(rqstp);
528         }
529         rqstp->rq_auth_stat = rpc_autherr_badcred;
530         return SVC_DENIED;
531 }
532
533
534 param_set_min_max(port, int, simple_strtol, 0, 65535)
535 param_set_min_max(grace_period, unsigned long, simple_strtoul,
536                   nlm_grace_period_min, nlm_grace_period_max)
537 param_set_min_max(timeout, unsigned long, simple_strtoul,
538                   nlm_timeout_min, nlm_timeout_max)
539
540 MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
541 MODULE_DESCRIPTION("NFS file locking service version " LOCKD_VERSION ".");
542 MODULE_LICENSE("GPL");
543
544 module_param_call(nlm_grace_period, param_set_grace_period, param_get_ulong,
545                   &nlm_grace_period, 0644);
546 module_param_call(nlm_timeout, param_set_timeout, param_get_ulong,
547                   &nlm_timeout, 0644);
548 module_param_call(nlm_udpport, param_set_port, param_get_int,
549                   &nlm_udpport, 0644);
550 module_param_call(nlm_tcpport, param_set_port, param_get_int,
551                   &nlm_tcpport, 0644);
552 module_param(nsm_use_hostnames, bool, 0644);
553 module_param(nlm_max_connections, uint, 0644);
554
555 static int lockd_init_net(struct net *net)
556 {
557         struct lockd_net *ln = net_generic(net, lockd_net_id);
558
559         INIT_DELAYED_WORK(&ln->grace_period_end, grace_ender);
560         INIT_LIST_HEAD(&ln->lockd_manager.list);
561         ln->lockd_manager.block_opens = false;
562         INIT_LIST_HEAD(&ln->nsm_handles);
563         return 0;
564 }
565
566 static void lockd_exit_net(struct net *net)
567 {
568         struct lockd_net *ln = net_generic(net, lockd_net_id);
569
570         WARN_ONCE(!list_empty(&ln->lockd_manager.list),
571                   "net %x %s: lockd_manager.list is not empty\n",
572                   net->ns.inum, __func__);
573         WARN_ONCE(!list_empty(&ln->nsm_handles),
574                   "net %x %s: nsm_handles list is not empty\n",
575                   net->ns.inum, __func__);
576         WARN_ONCE(delayed_work_pending(&ln->grace_period_end),
577                   "net %x %s: grace_period_end was not cancelled\n",
578                   net->ns.inum, __func__);
579 }
580
581 static struct pernet_operations lockd_net_ops = {
582         .init = lockd_init_net,
583         .exit = lockd_exit_net,
584         .id = &lockd_net_id,
585         .size = sizeof(struct lockd_net),
586 };
587
588
589 /*
590  * Initialising and terminating the module.
591  */
592
593 static int __init init_nlm(void)
594 {
595         int err;
596
597 #ifdef CONFIG_SYSCTL
598         err = -ENOMEM;
599         nlm_sysctl_table = register_sysctl("fs/nfs", nlm_sysctls);
600         if (nlm_sysctl_table == NULL)
601                 goto err_sysctl;
602 #endif
603         err = register_pernet_subsys(&lockd_net_ops);
604         if (err)
605                 goto err_pernet;
606
607         err = lockd_create_procfs();
608         if (err)
609                 goto err_procfs;
610
611         return 0;
612
613 err_procfs:
614         unregister_pernet_subsys(&lockd_net_ops);
615 err_pernet:
616 #ifdef CONFIG_SYSCTL
617         unregister_sysctl_table(nlm_sysctl_table);
618 err_sysctl:
619 #endif
620         return err;
621 }
622
623 static void __exit exit_nlm(void)
624 {
625         /* FIXME: delete all NLM clients */
626         nlm_shutdown_hosts();
627         lockd_remove_procfs();
628         unregister_pernet_subsys(&lockd_net_ops);
629 #ifdef CONFIG_SYSCTL
630         unregister_sysctl_table(nlm_sysctl_table);
631 #endif
632 }
633
634 module_init(init_nlm);
635 module_exit(exit_nlm);
636
637 /**
638  * nlmsvc_dispatch - Process an NLM Request
639  * @rqstp: incoming request
640  *
641  * Return values:
642  *  %0: Processing complete; do not send a Reply
643  *  %1: Processing complete; send Reply in rqstp->rq_res
644  */
645 static int nlmsvc_dispatch(struct svc_rqst *rqstp)
646 {
647         const struct svc_procedure *procp = rqstp->rq_procinfo;
648         __be32 *statp = rqstp->rq_accept_statp;
649
650         if (!procp->pc_decode(rqstp, &rqstp->rq_arg_stream))
651                 goto out_decode_err;
652
653         *statp = procp->pc_func(rqstp);
654         if (*statp == rpc_drop_reply)
655                 return 0;
656         if (*statp != rpc_success)
657                 return 1;
658
659         if (!procp->pc_encode(rqstp, &rqstp->rq_res_stream))
660                 goto out_encode_err;
661
662         return 1;
663
664 out_decode_err:
665         *statp = rpc_garbage_args;
666         return 1;
667
668 out_encode_err:
669         *statp = rpc_system_err;
670         return 1;
671 }
672
673 /*
674  * Define NLM program and procedures
675  */
676 static DEFINE_PER_CPU_ALIGNED(unsigned long, nlmsvc_version1_count[17]);
677 static const struct svc_version nlmsvc_version1 = {
678         .vs_vers        = 1,
679         .vs_nproc       = 17,
680         .vs_proc        = nlmsvc_procedures,
681         .vs_count       = nlmsvc_version1_count,
682         .vs_dispatch    = nlmsvc_dispatch,
683         .vs_xdrsize     = NLMSVC_XDRSIZE,
684 };
685
686 static DEFINE_PER_CPU_ALIGNED(unsigned long,
687                               nlmsvc_version3_count[ARRAY_SIZE(nlmsvc_procedures)]);
688 static const struct svc_version nlmsvc_version3 = {
689         .vs_vers        = 3,
690         .vs_nproc       = ARRAY_SIZE(nlmsvc_procedures),
691         .vs_proc        = nlmsvc_procedures,
692         .vs_count       = nlmsvc_version3_count,
693         .vs_dispatch    = nlmsvc_dispatch,
694         .vs_xdrsize     = NLMSVC_XDRSIZE,
695 };
696
697 #ifdef CONFIG_LOCKD_V4
698 static DEFINE_PER_CPU_ALIGNED(unsigned long,
699                               nlmsvc_version4_count[ARRAY_SIZE(nlmsvc_procedures4)]);
700 static const struct svc_version nlmsvc_version4 = {
701         .vs_vers        = 4,
702         .vs_nproc       = ARRAY_SIZE(nlmsvc_procedures4),
703         .vs_proc        = nlmsvc_procedures4,
704         .vs_count       = nlmsvc_version4_count,
705         .vs_dispatch    = nlmsvc_dispatch,
706         .vs_xdrsize     = NLMSVC_XDRSIZE,
707 };
708 #endif
709
710 static const struct svc_version *nlmsvc_version[] = {
711         [1] = &nlmsvc_version1,
712         [3] = &nlmsvc_version3,
713 #ifdef CONFIG_LOCKD_V4
714         [4] = &nlmsvc_version4,
715 #endif
716 };
717
718 static struct svc_stat          nlmsvc_stats;
719
720 #define NLM_NRVERS      ARRAY_SIZE(nlmsvc_version)
721 static struct svc_program       nlmsvc_program = {
722         .pg_prog                = NLM_PROGRAM,          /* program number */
723         .pg_nvers               = NLM_NRVERS,           /* number of entries in nlmsvc_version */
724         .pg_vers                = nlmsvc_version,       /* version table */
725         .pg_name                = "lockd",              /* service name */
726         .pg_class               = "nfsd",               /* share authentication with nfsd */
727         .pg_stats               = &nlmsvc_stats,        /* stats table */
728         .pg_authenticate        = &lockd_authenticate,  /* export authentication */
729         .pg_init_request        = svc_generic_init_request,
730         .pg_rpcbind_set         = svc_generic_rpcbind_set,
731 };