rpcb_clnt.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. /*
  2. * In-kernel rpcbind client supporting versions 2, 3, and 4 of the rpcbind
  3. * protocol
  4. *
  5. * Based on RFC 1833: "Binding Protocols for ONC RPC Version 2" and
  6. * RFC 3530: "Network File System (NFS) version 4 Protocol"
  7. *
  8. * Original: Gilles Quillard, Bull Open Source, 2005 <gilles.quillard@bull.net>
  9. * Updated: Chuck Lever, Oracle Corporation, 2007 <chuck.lever@oracle.com>
  10. *
  11. * Descended from net/sunrpc/pmap_clnt.c,
  12. * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
  13. */
  14. #include <linux/module.h>
  15. #include <linux/types.h>
  16. #include <linux/socket.h>
  17. #include <linux/in.h>
  18. #include <linux/in6.h>
  19. #include <linux/kernel.h>
  20. #include <linux/errno.h>
  21. #include <linux/sunrpc/clnt.h>
  22. #include <linux/sunrpc/sched.h>
  23. #include <linux/sunrpc/xprtsock.h>
  24. #ifdef RPC_DEBUG
  25. # define RPCDBG_FACILITY RPCDBG_BIND
  26. #endif
  27. #define RPCBIND_PROGRAM (100000u)
  28. #define RPCBIND_PORT (111u)
  29. enum {
  30. RPCBPROC_NULL,
  31. RPCBPROC_SET,
  32. RPCBPROC_UNSET,
  33. RPCBPROC_GETPORT,
  34. RPCBPROC_GETADDR = 3, /* alias for GETPORT */
  35. RPCBPROC_DUMP,
  36. RPCBPROC_CALLIT,
  37. RPCBPROC_BCAST = 5, /* alias for CALLIT */
  38. RPCBPROC_GETTIME,
  39. RPCBPROC_UADDR2TADDR,
  40. RPCBPROC_TADDR2UADDR,
  41. RPCBPROC_GETVERSADDR,
  42. RPCBPROC_INDIRECT,
  43. RPCBPROC_GETADDRLIST,
  44. RPCBPROC_GETSTAT,
  45. };
  46. #define RPCB_HIGHPROC_2 RPCBPROC_CALLIT
  47. #define RPCB_HIGHPROC_3 RPCBPROC_TADDR2UADDR
  48. #define RPCB_HIGHPROC_4 RPCBPROC_GETSTAT
  49. /*
  50. * r_owner
  51. *
  52. * The "owner" is allowed to unset a service in the rpcbind database.
  53. * We always use the following (arbitrary) fixed string.
  54. */
  55. #define RPCB_OWNER_STRING "rpcb"
  56. #define RPCB_MAXOWNERLEN sizeof(RPCB_OWNER_STRING)
  57. static void rpcb_getport_done(struct rpc_task *, void *);
  58. static struct rpc_program rpcb_program;
  59. struct rpcbind_args {
  60. struct rpc_xprt * r_xprt;
  61. u32 r_prog;
  62. u32 r_vers;
  63. u32 r_prot;
  64. unsigned short r_port;
  65. const char * r_netid;
  66. const char * r_addr;
  67. const char * r_owner;
  68. };
  69. static struct rpc_procinfo rpcb_procedures2[];
  70. static struct rpc_procinfo rpcb_procedures3[];
  71. struct rpcb_info {
  72. int rpc_vers;
  73. struct rpc_procinfo * rpc_proc;
  74. };
  75. static struct rpcb_info rpcb_next_version[];
  76. static struct rpcb_info rpcb_next_version6[];
  77. static void rpcb_map_release(void *data)
  78. {
  79. struct rpcbind_args *map = data;
  80. xprt_put(map->r_xprt);
  81. kfree(map);
  82. }
  83. static const struct rpc_call_ops rpcb_getport_ops = {
  84. .rpc_call_done = rpcb_getport_done,
  85. .rpc_release = rpcb_map_release,
  86. };
  87. static void rpcb_wake_rpcbind_waiters(struct rpc_xprt *xprt, int status)
  88. {
  89. xprt_clear_binding(xprt);
  90. rpc_wake_up_status(&xprt->binding, status);
  91. }
  92. static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr,
  93. size_t salen, int proto, u32 version,
  94. int privileged)
  95. {
  96. struct rpc_create_args args = {
  97. .protocol = proto,
  98. .address = srvaddr,
  99. .addrsize = salen,
  100. .servername = hostname,
  101. .program = &rpcb_program,
  102. .version = version,
  103. .authflavor = RPC_AUTH_UNIX,
  104. .flags = RPC_CLNT_CREATE_NOPING,
  105. };
  106. switch (srvaddr->sa_family) {
  107. case AF_INET:
  108. ((struct sockaddr_in *)srvaddr)->sin_port = htons(RPCBIND_PORT);
  109. break;
  110. case AF_INET6:
  111. ((struct sockaddr_in6 *)srvaddr)->sin6_port = htons(RPCBIND_PORT);
  112. break;
  113. default:
  114. return NULL;
  115. }
  116. if (!privileged)
  117. args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
  118. return rpc_create(&args);
  119. }
  120. /**
  121. * rpcb_register - set or unset a port registration with the local rpcbind svc
  122. * @prog: RPC program number to bind
  123. * @vers: RPC version number to bind
  124. * @prot: transport protocol to use to make this request
  125. * @port: port value to register
  126. * @okay: result code
  127. *
  128. * port == 0 means unregister, port != 0 means register.
  129. *
  130. * This routine supports only rpcbind version 2.
  131. */
  132. int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
  133. {
  134. struct sockaddr_in sin = {
  135. .sin_family = AF_INET,
  136. .sin_addr.s_addr = htonl(INADDR_LOOPBACK),
  137. };
  138. struct rpcbind_args map = {
  139. .r_prog = prog,
  140. .r_vers = vers,
  141. .r_prot = prot,
  142. .r_port = port,
  143. };
  144. struct rpc_message msg = {
  145. .rpc_proc = &rpcb_procedures2[port ?
  146. RPCBPROC_SET : RPCBPROC_UNSET],
  147. .rpc_argp = &map,
  148. .rpc_resp = okay,
  149. };
  150. struct rpc_clnt *rpcb_clnt;
  151. int error = 0;
  152. dprintk("RPC: %sregistering (%u, %u, %d, %u) with local "
  153. "rpcbind\n", (port ? "" : "un"),
  154. prog, vers, prot, port);
  155. rpcb_clnt = rpcb_create("localhost", (struct sockaddr *) &sin,
  156. sizeof(sin), XPRT_TRANSPORT_UDP, 2, 1);
  157. if (IS_ERR(rpcb_clnt))
  158. return PTR_ERR(rpcb_clnt);
  159. error = rpc_call_sync(rpcb_clnt, &msg, 0);
  160. rpc_shutdown_client(rpcb_clnt);
  161. if (error < 0)
  162. printk(KERN_WARNING "RPC: failed to contact local rpcbind "
  163. "server (errno %d).\n", -error);
  164. dprintk("RPC: registration status %d/%d\n", error, *okay);
  165. return error;
  166. }
  167. /**
  168. * rpcb_getport_sync - obtain the port for an RPC service on a given host
  169. * @sin: address of remote peer
  170. * @prog: RPC program number to bind
  171. * @vers: RPC version number to bind
  172. * @prot: transport protocol to use to make this request
  173. *
  174. * Return value is the requested advertised port number,
  175. * or a negative errno value.
  176. *
  177. * Called from outside the RPC client in a synchronous task context.
  178. * Uses default timeout parameters specified by underlying transport.
  179. *
  180. * XXX: Needs to support IPv6
  181. */
  182. int rpcb_getport_sync(struct sockaddr_in *sin, u32 prog, u32 vers, int prot)
  183. {
  184. struct rpcbind_args map = {
  185. .r_prog = prog,
  186. .r_vers = vers,
  187. .r_prot = prot,
  188. .r_port = 0,
  189. };
  190. struct rpc_message msg = {
  191. .rpc_proc = &rpcb_procedures2[RPCBPROC_GETPORT],
  192. .rpc_argp = &map,
  193. .rpc_resp = &map.r_port,
  194. };
  195. struct rpc_clnt *rpcb_clnt;
  196. int status;
  197. dprintk("RPC: %s(" NIPQUAD_FMT ", %u, %u, %d)\n",
  198. __func__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot);
  199. rpcb_clnt = rpcb_create(NULL, (struct sockaddr *)sin,
  200. sizeof(*sin), prot, 2, 0);
  201. if (IS_ERR(rpcb_clnt))
  202. return PTR_ERR(rpcb_clnt);
  203. status = rpc_call_sync(rpcb_clnt, &msg, 0);
  204. rpc_shutdown_client(rpcb_clnt);
  205. if (status >= 0) {
  206. if (map.r_port != 0)
  207. return map.r_port;
  208. status = -EACCES;
  209. }
  210. return status;
  211. }
  212. EXPORT_SYMBOL_GPL(rpcb_getport_sync);
  213. static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbind_args *map, struct rpc_procinfo *proc)
  214. {
  215. struct rpc_message msg = {
  216. .rpc_proc = proc,
  217. .rpc_argp = map,
  218. .rpc_resp = &map->r_port,
  219. };
  220. struct rpc_task_setup task_setup_data = {
  221. .rpc_client = rpcb_clnt,
  222. .rpc_message = &msg,
  223. .callback_ops = &rpcb_getport_ops,
  224. .callback_data = map,
  225. .flags = RPC_TASK_ASYNC,
  226. };
  227. return rpc_run_task(&task_setup_data);
  228. }
  229. /**
  230. * rpcb_getport_async - obtain the port for a given RPC service on a given host
  231. * @task: task that is waiting for portmapper request
  232. *
  233. * This one can be called for an ongoing RPC request, and can be used in
  234. * an async (rpciod) context.
  235. */
  236. void rpcb_getport_async(struct rpc_task *task)
  237. {
  238. struct rpc_clnt *clnt = task->tk_client;
  239. struct rpc_procinfo *proc;
  240. u32 bind_version;
  241. struct rpc_xprt *xprt = task->tk_xprt;
  242. struct rpc_clnt *rpcb_clnt;
  243. static struct rpcbind_args *map;
  244. struct rpc_task *child;
  245. struct sockaddr_storage addr;
  246. struct sockaddr *sap = (struct sockaddr *)&addr;
  247. size_t salen;
  248. int status;
  249. dprintk("RPC: %5u %s(%s, %u, %u, %d)\n",
  250. task->tk_pid, __func__,
  251. clnt->cl_server, clnt->cl_prog, clnt->cl_vers, xprt->prot);
  252. /* Autobind on cloned rpc clients is discouraged */
  253. BUG_ON(clnt->cl_parent != clnt);
  254. if (xprt_test_and_set_binding(xprt)) {
  255. status = -EAGAIN; /* tell caller to check again */
  256. dprintk("RPC: %5u %s: waiting for another binder\n",
  257. task->tk_pid, __func__);
  258. goto bailout_nowake;
  259. }
  260. /* Put self on queue before sending rpcbind request, in case
  261. * rpcb_getport_done completes before we return from rpc_run_task */
  262. rpc_sleep_on(&xprt->binding, task, NULL);
  263. /* Someone else may have bound if we slept */
  264. if (xprt_bound(xprt)) {
  265. status = 0;
  266. dprintk("RPC: %5u %s: already bound\n",
  267. task->tk_pid, __func__);
  268. goto bailout_nofree;
  269. }
  270. salen = rpc_peeraddr(clnt, sap, sizeof(addr));
  271. /* Don't ever use rpcbind v2 for AF_INET6 requests */
  272. switch (sap->sa_family) {
  273. case AF_INET:
  274. proc = rpcb_next_version[xprt->bind_index].rpc_proc;
  275. bind_version = rpcb_next_version[xprt->bind_index].rpc_vers;
  276. break;
  277. case AF_INET6:
  278. proc = rpcb_next_version6[xprt->bind_index].rpc_proc;
  279. bind_version = rpcb_next_version6[xprt->bind_index].rpc_vers;
  280. break;
  281. default:
  282. status = -EAFNOSUPPORT;
  283. dprintk("RPC: %5u %s: bad address family\n",
  284. task->tk_pid, __func__);
  285. goto bailout_nofree;
  286. }
  287. if (proc == NULL) {
  288. xprt->bind_index = 0;
  289. status = -EPFNOSUPPORT;
  290. dprintk("RPC: %5u %s: no more getport versions available\n",
  291. task->tk_pid, __func__);
  292. goto bailout_nofree;
  293. }
  294. dprintk("RPC: %5u %s: trying rpcbind version %u\n",
  295. task->tk_pid, __func__, bind_version);
  296. rpcb_clnt = rpcb_create(clnt->cl_server, sap, salen, xprt->prot,
  297. bind_version, 0);
  298. if (IS_ERR(rpcb_clnt)) {
  299. status = PTR_ERR(rpcb_clnt);
  300. dprintk("RPC: %5u %s: rpcb_create failed, error %ld\n",
  301. task->tk_pid, __func__, PTR_ERR(rpcb_clnt));
  302. goto bailout_nofree;
  303. }
  304. map = kzalloc(sizeof(struct rpcbind_args), GFP_ATOMIC);
  305. if (!map) {
  306. status = -ENOMEM;
  307. dprintk("RPC: %5u %s: no memory available\n",
  308. task->tk_pid, __func__);
  309. goto bailout_nofree;
  310. }
  311. map->r_prog = clnt->cl_prog;
  312. map->r_vers = clnt->cl_vers;
  313. map->r_prot = xprt->prot;
  314. map->r_port = 0;
  315. map->r_xprt = xprt_get(xprt);
  316. map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID);
  317. map->r_addr = rpc_peeraddr2str(rpcb_clnt, RPC_DISPLAY_UNIVERSAL_ADDR);
  318. map->r_owner = RPCB_OWNER_STRING; /* ignored for GETADDR */
  319. child = rpcb_call_async(rpcb_clnt, map, proc);
  320. rpc_release_client(rpcb_clnt);
  321. if (IS_ERR(child)) {
  322. status = -EIO;
  323. /* rpcb_map_release() has freed the arguments */
  324. dprintk("RPC: %5u %s: rpc_run_task failed\n",
  325. task->tk_pid, __func__);
  326. goto bailout_nofree;
  327. }
  328. rpc_put_task(child);
  329. task->tk_xprt->stat.bind_count++;
  330. return;
  331. bailout_nofree:
  332. rpcb_wake_rpcbind_waiters(xprt, status);
  333. bailout_nowake:
  334. task->tk_status = status;
  335. }
  336. EXPORT_SYMBOL_GPL(rpcb_getport_async);
  337. /*
  338. * Rpcbind child task calls this callback via tk_exit.
  339. */
  340. static void rpcb_getport_done(struct rpc_task *child, void *data)
  341. {
  342. struct rpcbind_args *map = data;
  343. struct rpc_xprt *xprt = map->r_xprt;
  344. int status = child->tk_status;
  345. /* Garbage reply: retry with a lesser rpcbind version */
  346. if (status == -EIO)
  347. status = -EPROTONOSUPPORT;
  348. /* rpcbind server doesn't support this rpcbind protocol version */
  349. if (status == -EPROTONOSUPPORT)
  350. xprt->bind_index++;
  351. if (status < 0) {
  352. /* rpcbind server not available on remote host? */
  353. xprt->ops->set_port(xprt, 0);
  354. } else if (map->r_port == 0) {
  355. /* Requested RPC service wasn't registered on remote host */
  356. xprt->ops->set_port(xprt, 0);
  357. status = -EACCES;
  358. } else {
  359. /* Succeeded */
  360. xprt->ops->set_port(xprt, map->r_port);
  361. xprt_set_bound(xprt);
  362. status = 0;
  363. }
  364. dprintk("RPC: %5u rpcb_getport_done(status %d, port %u)\n",
  365. child->tk_pid, status, map->r_port);
  366. rpcb_wake_rpcbind_waiters(xprt, status);
  367. }
  368. static int rpcb_encode_mapping(struct rpc_rqst *req, __be32 *p,
  369. struct rpcbind_args *rpcb)
  370. {
  371. dprintk("RPC: rpcb_encode_mapping(%u, %u, %d, %u)\n",
  372. rpcb->r_prog, rpcb->r_vers, rpcb->r_prot, rpcb->r_port);
  373. *p++ = htonl(rpcb->r_prog);
  374. *p++ = htonl(rpcb->r_vers);
  375. *p++ = htonl(rpcb->r_prot);
  376. *p++ = htonl(rpcb->r_port);
  377. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  378. return 0;
  379. }
  380. static int rpcb_decode_getport(struct rpc_rqst *req, __be32 *p,
  381. unsigned short *portp)
  382. {
  383. *portp = (unsigned short) ntohl(*p++);
  384. dprintk("RPC: rpcb_decode_getport result %u\n",
  385. *portp);
  386. return 0;
  387. }
  388. static int rpcb_decode_set(struct rpc_rqst *req, __be32 *p,
  389. unsigned int *boolp)
  390. {
  391. *boolp = (unsigned int) ntohl(*p++);
  392. dprintk("RPC: rpcb_decode_set result %u\n",
  393. *boolp);
  394. return 0;
  395. }
  396. static int rpcb_encode_getaddr(struct rpc_rqst *req, __be32 *p,
  397. struct rpcbind_args *rpcb)
  398. {
  399. dprintk("RPC: rpcb_encode_getaddr(%u, %u, %s)\n",
  400. rpcb->r_prog, rpcb->r_vers, rpcb->r_addr);
  401. *p++ = htonl(rpcb->r_prog);
  402. *p++ = htonl(rpcb->r_vers);
  403. p = xdr_encode_string(p, rpcb->r_netid);
  404. p = xdr_encode_string(p, rpcb->r_addr);
  405. p = xdr_encode_string(p, rpcb->r_owner);
  406. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  407. return 0;
  408. }
  409. static int rpcb_decode_getaddr(struct rpc_rqst *req, __be32 *p,
  410. unsigned short *portp)
  411. {
  412. char *addr;
  413. u32 addr_len;
  414. int c, i, f, first, val;
  415. *portp = 0;
  416. addr_len = ntohl(*p++);
  417. /*
  418. * Simple sanity check. The smallest possible universal
  419. * address is an IPv4 address string containing 11 bytes.
  420. */
  421. if (addr_len < 11 || addr_len > RPCBIND_MAXUADDRLEN)
  422. goto out_err;
  423. /*
  424. * Start at the end and walk backwards until the first dot
  425. * is encountered. When the second dot is found, we have
  426. * both parts of the port number.
  427. */
  428. addr = (char *)p;
  429. val = 0;
  430. first = 1;
  431. f = 1;
  432. for (i = addr_len - 1; i > 0; i--) {
  433. c = addr[i];
  434. if (c >= '0' && c <= '9') {
  435. val += (c - '0') * f;
  436. f *= 10;
  437. } else if (c == '.') {
  438. if (first) {
  439. *portp = val;
  440. val = first = 0;
  441. f = 1;
  442. } else {
  443. *portp |= (val << 8);
  444. break;
  445. }
  446. }
  447. }
  448. /*
  449. * Simple sanity check. If we never saw a dot in the reply,
  450. * then this was probably just garbage.
  451. */
  452. if (first)
  453. goto out_err;
  454. dprintk("RPC: rpcb_decode_getaddr port=%u\n", *portp);
  455. return 0;
  456. out_err:
  457. dprintk("RPC: rpcbind server returned malformed reply\n");
  458. return -EIO;
  459. }
  460. #define RPCB_program_sz (1u)
  461. #define RPCB_version_sz (1u)
  462. #define RPCB_protocol_sz (1u)
  463. #define RPCB_port_sz (1u)
  464. #define RPCB_boolean_sz (1u)
  465. #define RPCB_netid_sz (1+XDR_QUADLEN(RPCBIND_MAXNETIDLEN))
  466. #define RPCB_addr_sz (1+XDR_QUADLEN(RPCBIND_MAXUADDRLEN))
  467. #define RPCB_ownerstring_sz (1+XDR_QUADLEN(RPCB_MAXOWNERLEN))
  468. #define RPCB_mappingargs_sz RPCB_program_sz+RPCB_version_sz+ \
  469. RPCB_protocol_sz+RPCB_port_sz
  470. #define RPCB_getaddrargs_sz RPCB_program_sz+RPCB_version_sz+ \
  471. RPCB_netid_sz+RPCB_addr_sz+ \
  472. RPCB_ownerstring_sz
  473. #define RPCB_setres_sz RPCB_boolean_sz
  474. #define RPCB_getportres_sz RPCB_port_sz
  475. /*
  476. * Note that RFC 1833 does not put any size restrictions on the
  477. * address string returned by the remote rpcbind database.
  478. */
  479. #define RPCB_getaddrres_sz RPCB_addr_sz
  480. #define PROC(proc, argtype, restype) \
  481. [RPCBPROC_##proc] = { \
  482. .p_proc = RPCBPROC_##proc, \
  483. .p_encode = (kxdrproc_t) rpcb_encode_##argtype, \
  484. .p_decode = (kxdrproc_t) rpcb_decode_##restype, \
  485. .p_arglen = RPCB_##argtype##args_sz, \
  486. .p_replen = RPCB_##restype##res_sz, \
  487. .p_statidx = RPCBPROC_##proc, \
  488. .p_timer = 0, \
  489. .p_name = #proc, \
  490. }
  491. /*
  492. * Not all rpcbind procedures described in RFC 1833 are implemented
  493. * since the Linux kernel RPC code requires only these.
  494. */
  495. static struct rpc_procinfo rpcb_procedures2[] = {
  496. PROC(SET, mapping, set),
  497. PROC(UNSET, mapping, set),
  498. PROC(GETADDR, mapping, getport),
  499. };
  500. static struct rpc_procinfo rpcb_procedures3[] = {
  501. PROC(SET, mapping, set),
  502. PROC(UNSET, mapping, set),
  503. PROC(GETADDR, getaddr, getaddr),
  504. };
  505. static struct rpc_procinfo rpcb_procedures4[] = {
  506. PROC(SET, mapping, set),
  507. PROC(UNSET, mapping, set),
  508. PROC(GETVERSADDR, getaddr, getaddr),
  509. };
  510. static struct rpcb_info rpcb_next_version[] = {
  511. #ifdef CONFIG_SUNRPC_BIND34
  512. { 4, &rpcb_procedures4[RPCBPROC_GETVERSADDR] },
  513. { 3, &rpcb_procedures3[RPCBPROC_GETADDR] },
  514. #endif
  515. { 2, &rpcb_procedures2[RPCBPROC_GETPORT] },
  516. { 0, NULL },
  517. };
  518. static struct rpcb_info rpcb_next_version6[] = {
  519. #ifdef CONFIG_SUNRPC_BIND34
  520. { 4, &rpcb_procedures4[RPCBPROC_GETVERSADDR] },
  521. { 3, &rpcb_procedures3[RPCBPROC_GETADDR] },
  522. #endif
  523. { 0, NULL },
  524. };
  525. static struct rpc_version rpcb_version2 = {
  526. .number = 2,
  527. .nrprocs = RPCB_HIGHPROC_2,
  528. .procs = rpcb_procedures2
  529. };
  530. static struct rpc_version rpcb_version3 = {
  531. .number = 3,
  532. .nrprocs = RPCB_HIGHPROC_3,
  533. .procs = rpcb_procedures3
  534. };
  535. static struct rpc_version rpcb_version4 = {
  536. .number = 4,
  537. .nrprocs = RPCB_HIGHPROC_4,
  538. .procs = rpcb_procedures4
  539. };
  540. static struct rpc_version *rpcb_version[] = {
  541. NULL,
  542. NULL,
  543. &rpcb_version2,
  544. &rpcb_version3,
  545. &rpcb_version4
  546. };
  547. static struct rpc_stat rpcb_stats;
  548. static struct rpc_program rpcb_program = {
  549. .name = "rpcbind",
  550. .number = RPCBIND_PROGRAM,
  551. .nrvers = ARRAY_SIZE(rpcb_version),
  552. .version = rpcb_version,
  553. .stats = &rpcb_stats,
  554. };