rpcb_clnt.c 17 KB

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