svc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. /*
  2. * linux/fs/lockd/svc.c
  3. *
  4. * This is the central lockd service.
  5. *
  6. * FIXME: Separate the lockd NFS server functionality from the lockd NFS
  7. * client functionality. Oh why didn't Sun create two separate
  8. * services in the first place?
  9. *
  10. * Authors: Olaf Kirch (okir@monad.swb.de)
  11. *
  12. * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  13. */
  14. #include <linux/module.h>
  15. #include <linux/init.h>
  16. #include <linux/sysctl.h>
  17. #include <linux/moduleparam.h>
  18. #include <linux/sched.h>
  19. #include <linux/errno.h>
  20. #include <linux/in.h>
  21. #include <linux/uio.h>
  22. #include <linux/smp.h>
  23. #include <linux/mutex.h>
  24. #include <linux/kthread.h>
  25. #include <linux/freezer.h>
  26. #include <linux/sunrpc/types.h>
  27. #include <linux/sunrpc/stats.h>
  28. #include <linux/sunrpc/clnt.h>
  29. #include <linux/sunrpc/svc.h>
  30. #include <linux/sunrpc/svcsock.h>
  31. #include <net/ip.h>
  32. #include <linux/lockd/lockd.h>
  33. #include <linux/nfs.h>
  34. #include "netns.h"
  35. #include "procfs.h"
  36. #define NLMDBG_FACILITY NLMDBG_SVC
  37. #define LOCKD_BUFSIZE (1024 + NLMSVC_XDRSIZE)
  38. #define ALLOWED_SIGS (sigmask(SIGKILL))
  39. static struct svc_program nlmsvc_program;
  40. struct nlmsvc_binding * nlmsvc_ops;
  41. EXPORT_SYMBOL_GPL(nlmsvc_ops);
  42. static DEFINE_MUTEX(nlmsvc_mutex);
  43. static unsigned int nlmsvc_users;
  44. static struct task_struct *nlmsvc_task;
  45. static struct svc_rqst *nlmsvc_rqst;
  46. unsigned long nlmsvc_timeout;
  47. int lockd_net_id;
  48. /*
  49. * These can be set at insmod time (useful for NFS as root filesystem),
  50. * and also changed through the sysctl interface. -- Jamie Lokier, Aug 2003
  51. */
  52. static unsigned long nlm_grace_period;
  53. static unsigned long nlm_timeout = LOCKD_DFLT_TIMEO;
  54. static int nlm_udpport, nlm_tcpport;
  55. /* RLIM_NOFILE defaults to 1024. That seems like a reasonable default here. */
  56. static unsigned int nlm_max_connections = 1024;
  57. /*
  58. * Constants needed for the sysctl interface.
  59. */
  60. static const unsigned long nlm_grace_period_min = 0;
  61. static const unsigned long nlm_grace_period_max = 240;
  62. static const unsigned long nlm_timeout_min = 3;
  63. static const unsigned long nlm_timeout_max = 20;
  64. static const int nlm_port_min = 0, nlm_port_max = 65535;
  65. #ifdef CONFIG_SYSCTL
  66. static struct ctl_table_header * nlm_sysctl_table;
  67. #endif
  68. static unsigned long get_lockd_grace_period(void)
  69. {
  70. /* Note: nlm_timeout should always be nonzero */
  71. if (nlm_grace_period)
  72. return roundup(nlm_grace_period, nlm_timeout) * HZ;
  73. else
  74. return nlm_timeout * 5 * HZ;
  75. }
  76. static void grace_ender(struct work_struct *grace)
  77. {
  78. struct delayed_work *dwork = container_of(grace, struct delayed_work,
  79. work);
  80. struct lockd_net *ln = container_of(dwork, struct lockd_net,
  81. grace_period_end);
  82. locks_end_grace(&ln->lockd_manager);
  83. }
  84. static void set_grace_period(struct net *net)
  85. {
  86. unsigned long grace_period = get_lockd_grace_period();
  87. struct lockd_net *ln = net_generic(net, lockd_net_id);
  88. locks_start_grace(net, &ln->lockd_manager);
  89. cancel_delayed_work_sync(&ln->grace_period_end);
  90. schedule_delayed_work(&ln->grace_period_end, grace_period);
  91. }
  92. static void restart_grace(void)
  93. {
  94. if (nlmsvc_ops) {
  95. struct net *net = &init_net;
  96. struct lockd_net *ln = net_generic(net, lockd_net_id);
  97. cancel_delayed_work_sync(&ln->grace_period_end);
  98. locks_end_grace(&ln->lockd_manager);
  99. nlmsvc_invalidate_all();
  100. set_grace_period(net);
  101. }
  102. }
  103. /*
  104. * This is the lockd kernel thread
  105. */
  106. static int
  107. lockd(void *vrqstp)
  108. {
  109. int err = 0;
  110. struct svc_rqst *rqstp = vrqstp;
  111. struct net *net = &init_net;
  112. struct lockd_net *ln = net_generic(net, lockd_net_id);
  113. /* try_to_freeze() is called from svc_recv() */
  114. set_freezable();
  115. /* Allow SIGKILL to tell lockd to drop all of its locks */
  116. allow_signal(SIGKILL);
  117. dprintk("NFS locking service started (ver " LOCKD_VERSION ").\n");
  118. /*
  119. * The main request loop. We don't terminate until the last
  120. * NFS mount or NFS daemon has gone away.
  121. */
  122. while (!kthread_should_stop()) {
  123. long timeout = MAX_SCHEDULE_TIMEOUT;
  124. RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
  125. /* update sv_maxconn if it has changed */
  126. rqstp->rq_server->sv_maxconn = nlm_max_connections;
  127. if (signalled()) {
  128. flush_signals(current);
  129. restart_grace();
  130. continue;
  131. }
  132. timeout = nlmsvc_retry_blocked();
  133. /*
  134. * Find a socket with data available and call its
  135. * recvfrom routine.
  136. */
  137. err = svc_recv(rqstp, timeout);
  138. if (err == -EAGAIN || err == -EINTR)
  139. continue;
  140. dprintk("lockd: request from %s\n",
  141. svc_print_addr(rqstp, buf, sizeof(buf)));
  142. svc_process(rqstp);
  143. }
  144. flush_signals(current);
  145. if (nlmsvc_ops)
  146. nlmsvc_invalidate_all();
  147. nlm_shutdown_hosts();
  148. cancel_delayed_work_sync(&ln->grace_period_end);
  149. locks_end_grace(&ln->lockd_manager);
  150. return 0;
  151. }
  152. static int create_lockd_listener(struct svc_serv *serv, const char *name,
  153. struct net *net, const int family,
  154. const unsigned short port)
  155. {
  156. struct svc_xprt *xprt;
  157. xprt = svc_find_xprt(serv, name, net, family, 0);
  158. if (xprt == NULL)
  159. return svc_create_xprt(serv, name, net, family, port,
  160. SVC_SOCK_DEFAULTS);
  161. svc_xprt_put(xprt);
  162. return 0;
  163. }
  164. static int create_lockd_family(struct svc_serv *serv, struct net *net,
  165. const int family)
  166. {
  167. int err;
  168. err = create_lockd_listener(serv, "udp", net, family, nlm_udpport);
  169. if (err < 0)
  170. return err;
  171. return create_lockd_listener(serv, "tcp", net, family, nlm_tcpport);
  172. }
  173. /*
  174. * Ensure there are active UDP and TCP listeners for lockd.
  175. *
  176. * Even if we have only TCP NFS mounts and/or TCP NFSDs, some
  177. * local services (such as rpc.statd) still require UDP, and
  178. * some NFS servers do not yet support NLM over TCP.
  179. *
  180. * Returns zero if all listeners are available; otherwise a
  181. * negative errno value is returned.
  182. */
  183. static int make_socks(struct svc_serv *serv, struct net *net)
  184. {
  185. static int warned;
  186. int err;
  187. err = create_lockd_family(serv, net, PF_INET);
  188. if (err < 0)
  189. goto out_err;
  190. err = create_lockd_family(serv, net, PF_INET6);
  191. if (err < 0 && err != -EAFNOSUPPORT)
  192. goto out_err;
  193. warned = 0;
  194. return 0;
  195. out_err:
  196. if (warned++ == 0)
  197. printk(KERN_WARNING
  198. "lockd_up: makesock failed, error=%d\n", err);
  199. svc_shutdown_net(serv, net);
  200. return err;
  201. }
  202. static int lockd_up_net(struct svc_serv *serv, struct net *net)
  203. {
  204. struct lockd_net *ln = net_generic(net, lockd_net_id);
  205. int error;
  206. if (ln->nlmsvc_users++)
  207. return 0;
  208. error = svc_bind(serv, net);
  209. if (error)
  210. goto err_bind;
  211. error = make_socks(serv, net);
  212. if (error < 0)
  213. goto err_bind;
  214. set_grace_period(net);
  215. dprintk("lockd_up_net: per-net data created; net=%p\n", net);
  216. return 0;
  217. err_bind:
  218. ln->nlmsvc_users--;
  219. return error;
  220. }
  221. static void lockd_down_net(struct svc_serv *serv, struct net *net)
  222. {
  223. struct lockd_net *ln = net_generic(net, lockd_net_id);
  224. if (ln->nlmsvc_users) {
  225. if (--ln->nlmsvc_users == 0) {
  226. nlm_shutdown_hosts_net(net);
  227. cancel_delayed_work_sync(&ln->grace_period_end);
  228. locks_end_grace(&ln->lockd_manager);
  229. svc_shutdown_net(serv, net);
  230. dprintk("lockd_down_net: per-net data destroyed; net=%p\n", net);
  231. }
  232. } else {
  233. printk(KERN_ERR "lockd_down_net: no users! task=%p, net=%p\n",
  234. nlmsvc_task, net);
  235. BUG();
  236. }
  237. }
  238. static int lockd_start_svc(struct svc_serv *serv)
  239. {
  240. int error;
  241. if (nlmsvc_rqst)
  242. return 0;
  243. /*
  244. * Create the kernel thread and wait for it to start.
  245. */
  246. nlmsvc_rqst = svc_prepare_thread(serv, &serv->sv_pools[0], NUMA_NO_NODE);
  247. if (IS_ERR(nlmsvc_rqst)) {
  248. error = PTR_ERR(nlmsvc_rqst);
  249. printk(KERN_WARNING
  250. "lockd_up: svc_rqst allocation failed, error=%d\n",
  251. error);
  252. goto out_rqst;
  253. }
  254. svc_sock_update_bufs(serv);
  255. serv->sv_maxconn = nlm_max_connections;
  256. nlmsvc_task = kthread_create(lockd, nlmsvc_rqst, "%s", serv->sv_name);
  257. if (IS_ERR(nlmsvc_task)) {
  258. error = PTR_ERR(nlmsvc_task);
  259. printk(KERN_WARNING
  260. "lockd_up: kthread_run failed, error=%d\n", error);
  261. goto out_task;
  262. }
  263. nlmsvc_rqst->rq_task = nlmsvc_task;
  264. wake_up_process(nlmsvc_task);
  265. dprintk("lockd_up: service started\n");
  266. return 0;
  267. out_task:
  268. svc_exit_thread(nlmsvc_rqst);
  269. nlmsvc_task = NULL;
  270. out_rqst:
  271. nlmsvc_rqst = NULL;
  272. return error;
  273. }
  274. static struct svc_serv_ops lockd_sv_ops = {
  275. .svo_shutdown = svc_rpcb_cleanup,
  276. .svo_enqueue_xprt = svc_xprt_do_enqueue,
  277. };
  278. static struct svc_serv *lockd_create_svc(void)
  279. {
  280. struct svc_serv *serv;
  281. /*
  282. * Check whether we're already up and running.
  283. */
  284. if (nlmsvc_rqst) {
  285. /*
  286. * Note: increase service usage, because later in case of error
  287. * svc_destroy() will be called.
  288. */
  289. svc_get(nlmsvc_rqst->rq_server);
  290. return nlmsvc_rqst->rq_server;
  291. }
  292. /*
  293. * Sanity check: if there's no pid,
  294. * we should be the first user ...
  295. */
  296. if (nlmsvc_users)
  297. printk(KERN_WARNING
  298. "lockd_up: no pid, %d users??\n", nlmsvc_users);
  299. if (!nlm_timeout)
  300. nlm_timeout = LOCKD_DFLT_TIMEO;
  301. nlmsvc_timeout = nlm_timeout * HZ;
  302. serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, &lockd_sv_ops);
  303. if (!serv) {
  304. printk(KERN_WARNING "lockd_up: create service failed\n");
  305. return ERR_PTR(-ENOMEM);
  306. }
  307. dprintk("lockd_up: service created\n");
  308. return serv;
  309. }
  310. /*
  311. * Bring up the lockd process if it's not already up.
  312. */
  313. int lockd_up(struct net *net)
  314. {
  315. struct svc_serv *serv;
  316. int error;
  317. mutex_lock(&nlmsvc_mutex);
  318. serv = lockd_create_svc();
  319. if (IS_ERR(serv)) {
  320. error = PTR_ERR(serv);
  321. goto err_create;
  322. }
  323. error = lockd_up_net(serv, net);
  324. if (error < 0)
  325. goto err_net;
  326. error = lockd_start_svc(serv);
  327. if (error < 0)
  328. goto err_start;
  329. nlmsvc_users++;
  330. /*
  331. * Note: svc_serv structures have an initial use count of 1,
  332. * so we exit through here on both success and failure.
  333. */
  334. err_net:
  335. svc_destroy(serv);
  336. err_create:
  337. mutex_unlock(&nlmsvc_mutex);
  338. return error;
  339. err_start:
  340. lockd_down_net(serv, net);
  341. goto err_net;
  342. }
  343. EXPORT_SYMBOL_GPL(lockd_up);
  344. /*
  345. * Decrement the user count and bring down lockd if we're the last.
  346. */
  347. void
  348. lockd_down(struct net *net)
  349. {
  350. mutex_lock(&nlmsvc_mutex);
  351. lockd_down_net(nlmsvc_rqst->rq_server, net);
  352. if (nlmsvc_users) {
  353. if (--nlmsvc_users)
  354. goto out;
  355. } else {
  356. printk(KERN_ERR "lockd_down: no users! task=%p\n",
  357. nlmsvc_task);
  358. BUG();
  359. }
  360. if (!nlmsvc_task) {
  361. printk(KERN_ERR "lockd_down: no lockd running.\n");
  362. BUG();
  363. }
  364. kthread_stop(nlmsvc_task);
  365. dprintk("lockd_down: service stopped\n");
  366. svc_exit_thread(nlmsvc_rqst);
  367. dprintk("lockd_down: service destroyed\n");
  368. nlmsvc_task = NULL;
  369. nlmsvc_rqst = NULL;
  370. out:
  371. mutex_unlock(&nlmsvc_mutex);
  372. }
  373. EXPORT_SYMBOL_GPL(lockd_down);
  374. #ifdef CONFIG_SYSCTL
  375. /*
  376. * Sysctl parameters (same as module parameters, different interface).
  377. */
  378. static struct ctl_table nlm_sysctls[] = {
  379. {
  380. .procname = "nlm_grace_period",
  381. .data = &nlm_grace_period,
  382. .maxlen = sizeof(unsigned long),
  383. .mode = 0644,
  384. .proc_handler = proc_doulongvec_minmax,
  385. .extra1 = (unsigned long *) &nlm_grace_period_min,
  386. .extra2 = (unsigned long *) &nlm_grace_period_max,
  387. },
  388. {
  389. .procname = "nlm_timeout",
  390. .data = &nlm_timeout,
  391. .maxlen = sizeof(unsigned long),
  392. .mode = 0644,
  393. .proc_handler = proc_doulongvec_minmax,
  394. .extra1 = (unsigned long *) &nlm_timeout_min,
  395. .extra2 = (unsigned long *) &nlm_timeout_max,
  396. },
  397. {
  398. .procname = "nlm_udpport",
  399. .data = &nlm_udpport,
  400. .maxlen = sizeof(int),
  401. .mode = 0644,
  402. .proc_handler = proc_dointvec_minmax,
  403. .extra1 = (int *) &nlm_port_min,
  404. .extra2 = (int *) &nlm_port_max,
  405. },
  406. {
  407. .procname = "nlm_tcpport",
  408. .data = &nlm_tcpport,
  409. .maxlen = sizeof(int),
  410. .mode = 0644,
  411. .proc_handler = proc_dointvec_minmax,
  412. .extra1 = (int *) &nlm_port_min,
  413. .extra2 = (int *) &nlm_port_max,
  414. },
  415. {
  416. .procname = "nsm_use_hostnames",
  417. .data = &nsm_use_hostnames,
  418. .maxlen = sizeof(int),
  419. .mode = 0644,
  420. .proc_handler = proc_dointvec,
  421. },
  422. {
  423. .procname = "nsm_local_state",
  424. .data = &nsm_local_state,
  425. .maxlen = sizeof(int),
  426. .mode = 0644,
  427. .proc_handler = proc_dointvec,
  428. },
  429. { }
  430. };
  431. static struct ctl_table nlm_sysctl_dir[] = {
  432. {
  433. .procname = "nfs",
  434. .mode = 0555,
  435. .child = nlm_sysctls,
  436. },
  437. { }
  438. };
  439. static struct ctl_table nlm_sysctl_root[] = {
  440. {
  441. .procname = "fs",
  442. .mode = 0555,
  443. .child = nlm_sysctl_dir,
  444. },
  445. { }
  446. };
  447. #endif /* CONFIG_SYSCTL */
  448. /*
  449. * Module (and sysfs) parameters.
  450. */
  451. #define param_set_min_max(name, type, which_strtol, min, max) \
  452. static int param_set_##name(const char *val, struct kernel_param *kp) \
  453. { \
  454. char *endp; \
  455. __typeof__(type) num = which_strtol(val, &endp, 0); \
  456. if (endp == val || *endp || num < (min) || num > (max)) \
  457. return -EINVAL; \
  458. *((type *) kp->arg) = num; \
  459. return 0; \
  460. }
  461. static inline int is_callback(u32 proc)
  462. {
  463. return proc == NLMPROC_GRANTED
  464. || proc == NLMPROC_GRANTED_MSG
  465. || proc == NLMPROC_TEST_RES
  466. || proc == NLMPROC_LOCK_RES
  467. || proc == NLMPROC_CANCEL_RES
  468. || proc == NLMPROC_UNLOCK_RES
  469. || proc == NLMPROC_NSM_NOTIFY;
  470. }
  471. static int lockd_authenticate(struct svc_rqst *rqstp)
  472. {
  473. rqstp->rq_client = NULL;
  474. switch (rqstp->rq_authop->flavour) {
  475. case RPC_AUTH_NULL:
  476. case RPC_AUTH_UNIX:
  477. if (rqstp->rq_proc == 0)
  478. return SVC_OK;
  479. if (is_callback(rqstp->rq_proc)) {
  480. /* Leave it to individual procedures to
  481. * call nlmsvc_lookup_host(rqstp)
  482. */
  483. return SVC_OK;
  484. }
  485. return svc_set_client(rqstp);
  486. }
  487. return SVC_DENIED;
  488. }
  489. param_set_min_max(port, int, simple_strtol, 0, 65535)
  490. param_set_min_max(grace_period, unsigned long, simple_strtoul,
  491. nlm_grace_period_min, nlm_grace_period_max)
  492. param_set_min_max(timeout, unsigned long, simple_strtoul,
  493. nlm_timeout_min, nlm_timeout_max)
  494. MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
  495. MODULE_DESCRIPTION("NFS file locking service version " LOCKD_VERSION ".");
  496. MODULE_LICENSE("GPL");
  497. module_param_call(nlm_grace_period, param_set_grace_period, param_get_ulong,
  498. &nlm_grace_period, 0644);
  499. module_param_call(nlm_timeout, param_set_timeout, param_get_ulong,
  500. &nlm_timeout, 0644);
  501. module_param_call(nlm_udpport, param_set_port, param_get_int,
  502. &nlm_udpport, 0644);
  503. module_param_call(nlm_tcpport, param_set_port, param_get_int,
  504. &nlm_tcpport, 0644);
  505. module_param(nsm_use_hostnames, bool, 0644);
  506. module_param(nlm_max_connections, uint, 0644);
  507. static int lockd_init_net(struct net *net)
  508. {
  509. struct lockd_net *ln = net_generic(net, lockd_net_id);
  510. INIT_DELAYED_WORK(&ln->grace_period_end, grace_ender);
  511. INIT_LIST_HEAD(&ln->lockd_manager.list);
  512. ln->lockd_manager.block_opens = false;
  513. INIT_LIST_HEAD(&ln->nsm_handles);
  514. return 0;
  515. }
  516. static void lockd_exit_net(struct net *net)
  517. {
  518. }
  519. static struct pernet_operations lockd_net_ops = {
  520. .init = lockd_init_net,
  521. .exit = lockd_exit_net,
  522. .id = &lockd_net_id,
  523. .size = sizeof(struct lockd_net),
  524. };
  525. /*
  526. * Initialising and terminating the module.
  527. */
  528. static int __init init_nlm(void)
  529. {
  530. int err;
  531. #ifdef CONFIG_SYSCTL
  532. err = -ENOMEM;
  533. nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root);
  534. if (nlm_sysctl_table == NULL)
  535. goto err_sysctl;
  536. #endif
  537. err = register_pernet_subsys(&lockd_net_ops);
  538. if (err)
  539. goto err_pernet;
  540. err = lockd_create_procfs();
  541. if (err)
  542. goto err_procfs;
  543. return 0;
  544. err_procfs:
  545. unregister_pernet_subsys(&lockd_net_ops);
  546. err_pernet:
  547. #ifdef CONFIG_SYSCTL
  548. unregister_sysctl_table(nlm_sysctl_table);
  549. err_sysctl:
  550. #endif
  551. return err;
  552. }
  553. static void __exit exit_nlm(void)
  554. {
  555. /* FIXME: delete all NLM clients */
  556. nlm_shutdown_hosts();
  557. lockd_remove_procfs();
  558. unregister_pernet_subsys(&lockd_net_ops);
  559. #ifdef CONFIG_SYSCTL
  560. unregister_sysctl_table(nlm_sysctl_table);
  561. #endif
  562. }
  563. module_init(init_nlm);
  564. module_exit(exit_nlm);
  565. /*
  566. * Define NLM program and procedures
  567. */
  568. static struct svc_version nlmsvc_version1 = {
  569. .vs_vers = 1,
  570. .vs_nproc = 17,
  571. .vs_proc = nlmsvc_procedures,
  572. .vs_xdrsize = NLMSVC_XDRSIZE,
  573. };
  574. static struct svc_version nlmsvc_version3 = {
  575. .vs_vers = 3,
  576. .vs_nproc = 24,
  577. .vs_proc = nlmsvc_procedures,
  578. .vs_xdrsize = NLMSVC_XDRSIZE,
  579. };
  580. #ifdef CONFIG_LOCKD_V4
  581. static struct svc_version nlmsvc_version4 = {
  582. .vs_vers = 4,
  583. .vs_nproc = 24,
  584. .vs_proc = nlmsvc_procedures4,
  585. .vs_xdrsize = NLMSVC_XDRSIZE,
  586. };
  587. #endif
  588. static struct svc_version * nlmsvc_version[] = {
  589. [1] = &nlmsvc_version1,
  590. [3] = &nlmsvc_version3,
  591. #ifdef CONFIG_LOCKD_V4
  592. [4] = &nlmsvc_version4,
  593. #endif
  594. };
  595. static struct svc_stat nlmsvc_stats;
  596. #define NLM_NRVERS ARRAY_SIZE(nlmsvc_version)
  597. static struct svc_program nlmsvc_program = {
  598. .pg_prog = NLM_PROGRAM, /* program number */
  599. .pg_nvers = NLM_NRVERS, /* number of entries in nlmsvc_version */
  600. .pg_vers = nlmsvc_version, /* version table */
  601. .pg_name = "lockd", /* service name */
  602. .pg_class = "nfsd", /* share authentication with nfsd */
  603. .pg_stats = &nlmsvc_stats, /* stats table */
  604. .pg_authenticate = &lockd_authenticate /* export authentication */
  605. };