2 * In-kernel rpcbind client supporting versions 2, 3, and 4 of the rpcbind
5 * Based on RFC 1833: "Binding Protocols for ONC RPC Version 2" and
6 * RFC 3530: "Network File System (NFS) version 4 Protocol"
8 * Original: Gilles Quillard, Bull Open Source, 2005 <gilles.quillard@bull.net>
9 * Updated: Chuck Lever, Oracle Corporation, 2007 <chuck.lever@oracle.com>
11 * Descended from net/sunrpc/pmap_clnt.c,
12 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
15 #include <linux/module.h>
17 #include <linux/types.h>
18 #include <linux/socket.h>
20 #include <linux/in6.h>
21 #include <linux/kernel.h>
22 #include <linux/errno.h>
24 #include <linux/sunrpc/clnt.h>
25 #include <linux/sunrpc/sched.h>
26 #include <linux/sunrpc/xprtsock.h>
29 # define RPCDBG_FACILITY RPCDBG_BIND
32 #define RPCBIND_PROGRAM (100000u)
33 #define RPCBIND_PORT (111u)
35 #define RPCBVERS_2 (2u)
36 #define RPCBVERS_3 (3u)
37 #define RPCBVERS_4 (4u)
44 RPCBPROC_GETADDR
= 3, /* alias for GETPORT */
47 RPCBPROC_BCAST
= 5, /* alias for CALLIT */
57 #define RPCB_HIGHPROC_2 RPCBPROC_CALLIT
58 #define RPCB_HIGHPROC_3 RPCBPROC_TADDR2UADDR
59 #define RPCB_HIGHPROC_4 RPCBPROC_GETSTAT
64 * The "owner" is allowed to unset a service in the rpcbind database.
65 * We always use the following (arbitrary) fixed string.
67 #define RPCB_OWNER_STRING "rpcb"
68 #define RPCB_MAXOWNERLEN sizeof(RPCB_OWNER_STRING)
70 static void rpcb_getport_done(struct rpc_task
*, void *);
71 static void rpcb_map_release(void *data
);
72 static struct rpc_program rpcb_program
;
75 struct rpc_xprt
* r_xprt
;
80 unsigned short r_port
;
88 static struct rpc_procinfo rpcb_procedures2
[];
89 static struct rpc_procinfo rpcb_procedures3
[];
90 static struct rpc_procinfo rpcb_procedures4
[];
94 struct rpc_procinfo
* rpc_proc
;
97 static struct rpcb_info rpcb_next_version
[];
98 static struct rpcb_info rpcb_next_version6
[];
100 static const struct rpc_call_ops rpcb_getport_ops
= {
101 .rpc_call_done
= rpcb_getport_done
,
102 .rpc_release
= rpcb_map_release
,
105 static void rpcb_wake_rpcbind_waiters(struct rpc_xprt
*xprt
, int status
)
107 xprt_clear_binding(xprt
);
108 rpc_wake_up_status(&xprt
->binding
, status
);
111 static void rpcb_map_release(void *data
)
113 struct rpcbind_args
*map
= data
;
115 rpcb_wake_rpcbind_waiters(map
->r_xprt
, map
->r_status
);
116 xprt_put(map
->r_xprt
);
120 static const struct sockaddr_in rpcb_inaddr_loopback
= {
121 .sin_family
= AF_INET
,
122 .sin_addr
.s_addr
= htonl(INADDR_LOOPBACK
),
123 .sin_port
= htons(RPCBIND_PORT
),
126 static const struct sockaddr_in6 rpcb_in6addr_loopback
= {
127 .sin6_family
= AF_INET6
,
128 .sin6_addr
= IN6ADDR_LOOPBACK_INIT
,
129 .sin6_port
= htons(RPCBIND_PORT
),
132 static struct rpc_clnt
*rpcb_create_local(struct sockaddr
*addr
,
133 size_t addrlen
, u32 version
)
135 struct rpc_create_args args
= {
136 .protocol
= XPRT_TRANSPORT_UDP
,
139 .servername
= "localhost",
140 .program
= &rpcb_program
,
142 .authflavor
= RPC_AUTH_UNIX
,
143 .flags
= RPC_CLNT_CREATE_NOPING
,
146 return rpc_create(&args
);
149 static struct rpc_clnt
*rpcb_create(char *hostname
, struct sockaddr
*srvaddr
,
150 size_t salen
, int proto
, u32 version
)
152 struct rpc_create_args args
= {
156 .servername
= hostname
,
157 .program
= &rpcb_program
,
159 .authflavor
= RPC_AUTH_UNIX
,
160 .flags
= (RPC_CLNT_CREATE_NOPING
|
161 RPC_CLNT_CREATE_NONPRIVPORT
),
164 switch (srvaddr
->sa_family
) {
166 ((struct sockaddr_in
*)srvaddr
)->sin_port
= htons(RPCBIND_PORT
);
169 ((struct sockaddr_in6
*)srvaddr
)->sin6_port
= htons(RPCBIND_PORT
);
175 return rpc_create(&args
);
178 static int rpcb_register_call(struct sockaddr
*addr
, size_t addrlen
,
179 u32 version
, struct rpc_message
*msg
,
182 struct rpc_clnt
*rpcb_clnt
;
187 rpcb_clnt
= rpcb_create_local(addr
, addrlen
, version
);
188 if (!IS_ERR(rpcb_clnt
)) {
189 error
= rpc_call_sync(rpcb_clnt
, msg
, 0);
190 rpc_shutdown_client(rpcb_clnt
);
192 error
= PTR_ERR(rpcb_clnt
);
195 printk(KERN_WARNING
"RPC: failed to contact local rpcbind "
196 "server (errno %d).\n", -error
);
197 dprintk("RPC: registration status %d/%d\n", error
, *result
);
203 * rpcb_register - set or unset a port registration with the local rpcbind svc
204 * @prog: RPC program number to bind
205 * @vers: RPC version number to bind
206 * @prot: transport protocol to register
207 * @port: port value to register
208 * @okay: OUT: result code
210 * RPC services invoke this function to advertise their contact
211 * information via the system's rpcbind daemon. RPC services
212 * invoke this function once for each [program, version, transport]
213 * tuple they wish to advertise.
215 * Callers may also unregister RPC services that are no longer
216 * available by setting the passed-in port to zero. This removes
217 * all registered transports for [program, version] from the local
220 * Returns zero if the registration request was dispatched
221 * successfully and a reply was received. The rpcbind daemon's
222 * boolean result code is stored in *okay.
224 * Returns an errno value and sets *result to zero if there was
225 * some problem that prevented the rpcbind request from being
226 * dispatched, or if the rpcbind daemon did not respond within
229 * This function uses rpcbind protocol version 2 to contact the
230 * local rpcbind daemon.
232 * Registration works over both AF_INET and AF_INET6, and services
233 * registered via this function are advertised as available for any
234 * address. If the local rpcbind daemon is listening on AF_INET6,
235 * services registered via this function will be advertised on
236 * IN6ADDR_ANY (ie available for all AF_INET and AF_INET6
239 int rpcb_register(u32 prog
, u32 vers
, int prot
, unsigned short port
, int *okay
)
241 struct rpcbind_args map
= {
247 struct rpc_message msg
= {
252 dprintk("RPC: %sregistering (%u, %u, %d, %u) with local "
253 "rpcbind\n", (port
? "" : "un"),
254 prog
, vers
, prot
, port
);
256 msg
.rpc_proc
= &rpcb_procedures2
[RPCBPROC_UNSET
];
258 msg
.rpc_proc
= &rpcb_procedures2
[RPCBPROC_SET
];
260 return rpcb_register_call((struct sockaddr
*)&rpcb_inaddr_loopback
,
261 sizeof(rpcb_inaddr_loopback
),
262 RPCBVERS_2
, &msg
, okay
);
266 * Fill in AF_INET family-specific arguments to register
268 static int rpcb_register_netid4(struct sockaddr_in
*address_to_register
,
269 struct rpc_message
*msg
)
271 struct rpcbind_args
*map
= msg
->rpc_argp
;
272 unsigned short port
= ntohs(address_to_register
->sin_port
);
275 /* Construct AF_INET universal address */
276 snprintf(buf
, sizeof(buf
),
278 NIPQUAD(address_to_register
->sin_addr
.s_addr
),
279 port
>> 8, port
& 0xff);
282 dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with "
283 "local rpcbind\n", (port
? "" : "un"),
284 map
->r_prog
, map
->r_vers
,
285 map
->r_addr
, map
->r_netid
);
287 msg
->rpc_proc
= &rpcb_procedures4
[RPCBPROC_UNSET
];
289 msg
->rpc_proc
= &rpcb_procedures4
[RPCBPROC_SET
];
291 return rpcb_register_call((struct sockaddr
*)&rpcb_inaddr_loopback
,
292 sizeof(rpcb_inaddr_loopback
),
293 RPCBVERS_4
, msg
, msg
->rpc_resp
);
297 * Fill in AF_INET6 family-specific arguments to register
299 static int rpcb_register_netid6(struct sockaddr_in6
*address_to_register
,
300 struct rpc_message
*msg
)
302 struct rpcbind_args
*map
= msg
->rpc_argp
;
303 unsigned short port
= ntohs(address_to_register
->sin6_port
);
306 /* Construct AF_INET6 universal address */
307 snprintf(buf
, sizeof(buf
),
309 NIP6(address_to_register
->sin6_addr
),
310 port
>> 8, port
& 0xff);
313 dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with "
314 "local rpcbind\n", (port
? "" : "un"),
315 map
->r_prog
, map
->r_vers
,
316 map
->r_addr
, map
->r_netid
);
318 msg
->rpc_proc
= &rpcb_procedures4
[RPCBPROC_UNSET
];
320 msg
->rpc_proc
= &rpcb_procedures4
[RPCBPROC_SET
];
322 return rpcb_register_call((struct sockaddr
*)&rpcb_in6addr_loopback
,
323 sizeof(rpcb_in6addr_loopback
),
324 RPCBVERS_4
, msg
, msg
->rpc_resp
);
328 * rpcb_v4_register - set or unset a port registration with the local rpcbind
329 * @program: RPC program number of service to (un)register
330 * @version: RPC version number of service to (un)register
331 * @address: address family, IP address, and port to (un)register
332 * @netid: netid of transport protocol to (un)register
333 * @result: result code from rpcbind RPC call
335 * RPC services invoke this function to advertise their contact
336 * information via the system's rpcbind daemon. RPC services
337 * invoke this function once for each [program, version, address,
338 * netid] tuple they wish to advertise.
340 * Callers may also unregister RPC services that are no longer
341 * available by setting the port number in the passed-in address
342 * to zero. Callers pass a netid of "" to unregister all
343 * transport netids associated with [program, version, address].
345 * Returns zero if the registration request was dispatched
346 * successfully and a reply was received. The rpcbind daemon's
347 * result code is stored in *result.
349 * Returns an errno value and sets *result to zero if there was
350 * some problem that prevented the rpcbind request from being
351 * dispatched, or if the rpcbind daemon did not respond within
354 * This function uses rpcbind protocol version 4 to contact the
355 * local rpcbind daemon. The local rpcbind daemon must support
356 * version 4 of the rpcbind protocol in order for these functions
357 * to register a service successfully.
359 * Supported netids include "udp" and "tcp" for UDP and TCP over
360 * IPv4, and "udp6" and "tcp6" for UDP and TCP over IPv6,
363 * The contents of @address determine the address family and the
364 * port to be registered. The usual practice is to pass INADDR_ANY
365 * as the raw address, but specifying a non-zero address is also
366 * supported by this API if the caller wishes to advertise an RPC
367 * service on a specific network interface.
369 * Note that passing in INADDR_ANY does not create the same service
370 * registration as IN6ADDR_ANY. The former advertises an RPC
371 * service on any IPv4 address, but not on IPv6. The latter
372 * advertises the service on all IPv4 and IPv6 addresses.
374 int rpcb_v4_register(const u32 program
, const u32 version
,
375 const struct sockaddr
*address
, const char *netid
,
378 struct rpcbind_args map
= {
382 .r_owner
= RPCB_OWNER_STRING
,
384 struct rpc_message msg
= {
391 switch (address
->sa_family
) {
393 return rpcb_register_netid4((struct sockaddr_in
*)address
,
396 return rpcb_register_netid6((struct sockaddr_in6
*)address
,
400 return -EAFNOSUPPORT
;
404 * rpcb_getport_sync - obtain the port for an RPC service on a given host
405 * @sin: address of remote peer
406 * @prog: RPC program number to bind
407 * @vers: RPC version number to bind
408 * @prot: transport protocol to use to make this request
410 * Return value is the requested advertised port number,
411 * or a negative errno value.
413 * Called from outside the RPC client in a synchronous task context.
414 * Uses default timeout parameters specified by underlying transport.
416 * XXX: Needs to support IPv6
418 int rpcb_getport_sync(struct sockaddr_in
*sin
, u32 prog
, u32 vers
, int prot
)
420 struct rpcbind_args map
= {
426 struct rpc_message msg
= {
427 .rpc_proc
= &rpcb_procedures2
[RPCBPROC_GETPORT
],
429 .rpc_resp
= &map
.r_port
,
431 struct rpc_clnt
*rpcb_clnt
;
434 dprintk("RPC: %s(" NIPQUAD_FMT
", %u, %u, %d)\n",
435 __func__
, NIPQUAD(sin
->sin_addr
.s_addr
), prog
, vers
, prot
);
437 rpcb_clnt
= rpcb_create(NULL
, (struct sockaddr
*)sin
,
438 sizeof(*sin
), prot
, RPCBVERS_2
);
439 if (IS_ERR(rpcb_clnt
))
440 return PTR_ERR(rpcb_clnt
);
442 status
= rpc_call_sync(rpcb_clnt
, &msg
, 0);
443 rpc_shutdown_client(rpcb_clnt
);
452 EXPORT_SYMBOL_GPL(rpcb_getport_sync
);
454 static struct rpc_task
*rpcb_call_async(struct rpc_clnt
*rpcb_clnt
, struct rpcbind_args
*map
, struct rpc_procinfo
*proc
)
456 struct rpc_message msg
= {
459 .rpc_resp
= &map
->r_port
,
461 struct rpc_task_setup task_setup_data
= {
462 .rpc_client
= rpcb_clnt
,
464 .callback_ops
= &rpcb_getport_ops
,
465 .callback_data
= map
,
466 .flags
= RPC_TASK_ASYNC
,
469 return rpc_run_task(&task_setup_data
);
473 * In the case where rpc clients have been cloned, we want to make
474 * sure that we use the program number/version etc of the actual
475 * owner of the xprt. To do so, we walk back up the tree of parents
476 * to find whoever created the transport and/or whoever has the
479 static struct rpc_clnt
*rpcb_find_transport_owner(struct rpc_clnt
*clnt
)
481 struct rpc_clnt
*parent
= clnt
->cl_parent
;
483 while (parent
!= clnt
) {
484 if (parent
->cl_xprt
!= clnt
->cl_xprt
)
486 if (clnt
->cl_autobind
)
489 parent
= parent
->cl_parent
;
495 * rpcb_getport_async - obtain the port for a given RPC service on a given host
496 * @task: task that is waiting for portmapper request
498 * This one can be called for an ongoing RPC request, and can be used in
499 * an async (rpciod) context.
501 void rpcb_getport_async(struct rpc_task
*task
)
503 struct rpc_clnt
*clnt
;
504 struct rpc_procinfo
*proc
;
506 struct rpc_xprt
*xprt
;
507 struct rpc_clnt
*rpcb_clnt
;
508 static struct rpcbind_args
*map
;
509 struct rpc_task
*child
;
510 struct sockaddr_storage addr
;
511 struct sockaddr
*sap
= (struct sockaddr
*)&addr
;
515 clnt
= rpcb_find_transport_owner(task
->tk_client
);
516 xprt
= clnt
->cl_xprt
;
518 dprintk("RPC: %5u %s(%s, %u, %u, %d)\n",
519 task
->tk_pid
, __func__
,
520 clnt
->cl_server
, clnt
->cl_prog
, clnt
->cl_vers
, xprt
->prot
);
522 /* Put self on the wait queue to ensure we get notified if
523 * some other task is already attempting to bind the port */
524 rpc_sleep_on(&xprt
->binding
, task
, NULL
);
526 if (xprt_test_and_set_binding(xprt
)) {
527 dprintk("RPC: %5u %s: waiting for another binder\n",
528 task
->tk_pid
, __func__
);
532 /* Someone else may have bound if we slept */
533 if (xprt_bound(xprt
)) {
535 dprintk("RPC: %5u %s: already bound\n",
536 task
->tk_pid
, __func__
);
540 salen
= rpc_peeraddr(clnt
, sap
, sizeof(addr
));
542 /* Don't ever use rpcbind v2 for AF_INET6 requests */
543 switch (sap
->sa_family
) {
545 proc
= rpcb_next_version
[xprt
->bind_index
].rpc_proc
;
546 bind_version
= rpcb_next_version
[xprt
->bind_index
].rpc_vers
;
549 proc
= rpcb_next_version6
[xprt
->bind_index
].rpc_proc
;
550 bind_version
= rpcb_next_version6
[xprt
->bind_index
].rpc_vers
;
553 status
= -EAFNOSUPPORT
;
554 dprintk("RPC: %5u %s: bad address family\n",
555 task
->tk_pid
, __func__
);
559 xprt
->bind_index
= 0;
560 status
= -EPFNOSUPPORT
;
561 dprintk("RPC: %5u %s: no more getport versions available\n",
562 task
->tk_pid
, __func__
);
566 dprintk("RPC: %5u %s: trying rpcbind version %u\n",
567 task
->tk_pid
, __func__
, bind_version
);
569 rpcb_clnt
= rpcb_create(clnt
->cl_server
, sap
, salen
, xprt
->prot
,
571 if (IS_ERR(rpcb_clnt
)) {
572 status
= PTR_ERR(rpcb_clnt
);
573 dprintk("RPC: %5u %s: rpcb_create failed, error %ld\n",
574 task
->tk_pid
, __func__
, PTR_ERR(rpcb_clnt
));
578 map
= kzalloc(sizeof(struct rpcbind_args
), GFP_ATOMIC
);
581 dprintk("RPC: %5u %s: no memory available\n",
582 task
->tk_pid
, __func__
);
583 goto bailout_release_client
;
585 map
->r_prog
= clnt
->cl_prog
;
586 map
->r_vers
= clnt
->cl_vers
;
587 map
->r_prot
= xprt
->prot
;
589 map
->r_xprt
= xprt_get(xprt
);
590 map
->r_netid
= rpc_peeraddr2str(clnt
, RPC_DISPLAY_NETID
);
591 map
->r_addr
= rpc_peeraddr2str(rpcb_clnt
, RPC_DISPLAY_UNIVERSAL_ADDR
);
592 map
->r_owner
= RPCB_OWNER_STRING
; /* ignored for GETADDR */
593 map
->r_status
= -EIO
;
595 child
= rpcb_call_async(rpcb_clnt
, map
, proc
);
596 rpc_release_client(rpcb_clnt
);
598 /* rpcb_map_release() has freed the arguments */
599 dprintk("RPC: %5u %s: rpc_run_task failed\n",
600 task
->tk_pid
, __func__
);
604 xprt
->stat
.bind_count
++;
608 bailout_release_client
:
609 rpc_release_client(rpcb_clnt
);
611 rpcb_wake_rpcbind_waiters(xprt
, status
);
612 task
->tk_status
= status
;
614 EXPORT_SYMBOL_GPL(rpcb_getport_async
);
617 * Rpcbind child task calls this callback via tk_exit.
619 static void rpcb_getport_done(struct rpc_task
*child
, void *data
)
621 struct rpcbind_args
*map
= data
;
622 struct rpc_xprt
*xprt
= map
->r_xprt
;
623 int status
= child
->tk_status
;
625 /* Garbage reply: retry with a lesser rpcbind version */
627 status
= -EPROTONOSUPPORT
;
629 /* rpcbind server doesn't support this rpcbind protocol version */
630 if (status
== -EPROTONOSUPPORT
)
634 /* rpcbind server not available on remote host? */
635 xprt
->ops
->set_port(xprt
, 0);
636 } else if (map
->r_port
== 0) {
637 /* Requested RPC service wasn't registered on remote host */
638 xprt
->ops
->set_port(xprt
, 0);
642 xprt
->ops
->set_port(xprt
, map
->r_port
);
643 xprt_set_bound(xprt
);
647 dprintk("RPC: %5u rpcb_getport_done(status %d, port %u)\n",
648 child
->tk_pid
, status
, map
->r_port
);
650 map
->r_status
= status
;
654 * XDR functions for rpcbind
657 static int rpcb_encode_mapping(struct rpc_rqst
*req
, __be32
*p
,
658 struct rpcbind_args
*rpcb
)
660 dprintk("RPC: rpcb_encode_mapping(%u, %u, %d, %u)\n",
661 rpcb
->r_prog
, rpcb
->r_vers
, rpcb
->r_prot
, rpcb
->r_port
);
662 *p
++ = htonl(rpcb
->r_prog
);
663 *p
++ = htonl(rpcb
->r_vers
);
664 *p
++ = htonl(rpcb
->r_prot
);
665 *p
++ = htonl(rpcb
->r_port
);
667 req
->rq_slen
= xdr_adjust_iovec(req
->rq_svec
, p
);
671 static int rpcb_decode_getport(struct rpc_rqst
*req
, __be32
*p
,
672 unsigned short *portp
)
674 *portp
= (unsigned short) ntohl(*p
++);
675 dprintk("RPC: rpcb_decode_getport result %u\n",
680 static int rpcb_decode_set(struct rpc_rqst
*req
, __be32
*p
,
683 *boolp
= (unsigned int) ntohl(*p
++);
684 dprintk("RPC: rpcb_decode_set: call %s\n",
685 (*boolp
? "succeeded" : "failed"));
689 static int rpcb_encode_getaddr(struct rpc_rqst
*req
, __be32
*p
,
690 struct rpcbind_args
*rpcb
)
692 dprintk("RPC: rpcb_encode_getaddr(%u, %u, %s)\n",
693 rpcb
->r_prog
, rpcb
->r_vers
, rpcb
->r_addr
);
694 *p
++ = htonl(rpcb
->r_prog
);
695 *p
++ = htonl(rpcb
->r_vers
);
697 p
= xdr_encode_string(p
, rpcb
->r_netid
);
698 p
= xdr_encode_string(p
, rpcb
->r_addr
);
699 p
= xdr_encode_string(p
, rpcb
->r_owner
);
701 req
->rq_slen
= xdr_adjust_iovec(req
->rq_svec
, p
);
706 static int rpcb_decode_getaddr(struct rpc_rqst
*req
, __be32
*p
,
707 unsigned short *portp
)
711 int c
, i
, f
, first
, val
;
714 addr_len
= ntohl(*p
++);
717 * Simple sanity check. The smallest possible universal
718 * address is an IPv4 address string containing 11 bytes.
720 if (addr_len
< 11 || addr_len
> RPCBIND_MAXUADDRLEN
)
724 * Start at the end and walk backwards until the first dot
725 * is encountered. When the second dot is found, we have
726 * both parts of the port number.
732 for (i
= addr_len
- 1; i
> 0; i
--) {
734 if (c
>= '0' && c
<= '9') {
735 val
+= (c
- '0') * f
;
737 } else if (c
== '.') {
743 *portp
|= (val
<< 8);
750 * Simple sanity check. If we never saw a dot in the reply,
751 * then this was probably just garbage.
756 dprintk("RPC: rpcb_decode_getaddr port=%u\n", *portp
);
760 dprintk("RPC: rpcbind server returned malformed reply\n");
764 #define RPCB_program_sz (1u)
765 #define RPCB_version_sz (1u)
766 #define RPCB_protocol_sz (1u)
767 #define RPCB_port_sz (1u)
768 #define RPCB_boolean_sz (1u)
770 #define RPCB_netid_sz (1+XDR_QUADLEN(RPCBIND_MAXNETIDLEN))
771 #define RPCB_addr_sz (1+XDR_QUADLEN(RPCBIND_MAXUADDRLEN))
772 #define RPCB_ownerstring_sz (1+XDR_QUADLEN(RPCB_MAXOWNERLEN))
774 #define RPCB_mappingargs_sz RPCB_program_sz+RPCB_version_sz+ \
775 RPCB_protocol_sz+RPCB_port_sz
776 #define RPCB_getaddrargs_sz RPCB_program_sz+RPCB_version_sz+ \
777 RPCB_netid_sz+RPCB_addr_sz+ \
780 #define RPCB_setres_sz RPCB_boolean_sz
781 #define RPCB_getportres_sz RPCB_port_sz
784 * Note that RFC 1833 does not put any size restrictions on the
785 * address string returned by the remote rpcbind database.
787 #define RPCB_getaddrres_sz RPCB_addr_sz
789 #define PROC(proc, argtype, restype) \
790 [RPCBPROC_##proc] = { \
791 .p_proc = RPCBPROC_##proc, \
792 .p_encode = (kxdrproc_t) rpcb_encode_##argtype, \
793 .p_decode = (kxdrproc_t) rpcb_decode_##restype, \
794 .p_arglen = RPCB_##argtype##args_sz, \
795 .p_replen = RPCB_##restype##res_sz, \
796 .p_statidx = RPCBPROC_##proc, \
802 * Not all rpcbind procedures described in RFC 1833 are implemented
803 * since the Linux kernel RPC code requires only these.
805 static struct rpc_procinfo rpcb_procedures2
[] = {
806 PROC(SET
, mapping
, set
),
807 PROC(UNSET
, mapping
, set
),
808 PROC(GETPORT
, mapping
, getport
),
811 static struct rpc_procinfo rpcb_procedures3
[] = {
812 PROC(SET
, getaddr
, set
),
813 PROC(UNSET
, getaddr
, set
),
814 PROC(GETADDR
, getaddr
, getaddr
),
817 static struct rpc_procinfo rpcb_procedures4
[] = {
818 PROC(SET
, getaddr
, set
),
819 PROC(UNSET
, getaddr
, set
),
820 PROC(GETADDR
, getaddr
, getaddr
),
821 PROC(GETVERSADDR
, getaddr
, getaddr
),
824 static struct rpcb_info rpcb_next_version
[] = {
826 .rpc_vers
= RPCBVERS_2
,
827 .rpc_proc
= &rpcb_procedures2
[RPCBPROC_GETPORT
],
834 static struct rpcb_info rpcb_next_version6
[] = {
836 .rpc_vers
= RPCBVERS_4
,
837 .rpc_proc
= &rpcb_procedures4
[RPCBPROC_GETADDR
],
840 .rpc_vers
= RPCBVERS_3
,
841 .rpc_proc
= &rpcb_procedures3
[RPCBPROC_GETADDR
],
848 static struct rpc_version rpcb_version2
= {
849 .number
= RPCBVERS_2
,
850 .nrprocs
= RPCB_HIGHPROC_2
,
851 .procs
= rpcb_procedures2
854 static struct rpc_version rpcb_version3
= {
855 .number
= RPCBVERS_3
,
856 .nrprocs
= RPCB_HIGHPROC_3
,
857 .procs
= rpcb_procedures3
860 static struct rpc_version rpcb_version4
= {
861 .number
= RPCBVERS_4
,
862 .nrprocs
= RPCB_HIGHPROC_4
,
863 .procs
= rpcb_procedures4
866 static struct rpc_version
*rpcb_version
[] = {
874 static struct rpc_stat rpcb_stats
;
876 static struct rpc_program rpcb_program
= {
878 .number
= RPCBIND_PROGRAM
,
879 .nrvers
= ARRAY_SIZE(rpcb_version
),
880 .version
= rpcb_version
,
881 .stats
= &rpcb_stats
,