rpcb_clnt.c 16 KB

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