svc.c 16 KB

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