Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * In-kernel rpcbind client supporting versions 2, 3, and 4 of the rpcbind
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * Based on RFC 1833: "Binding Protocols for ONC RPC Version 2" and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  * RFC 3530: "Network File System (NFS) version 4 Protocol"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  * Original: Gilles Quillard, Bull Open Source, 2005 <gilles.quillard@bull.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  * Updated: Chuck Lever, Oracle Corporation, 2007 <chuck.lever@oracle.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  * Descended from net/sunrpc/pmap_clnt.c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  *  Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include <linux/socket.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <linux/un.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <linux/in6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #include <net/ipv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #include <linux/sunrpc/clnt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #include <linux/sunrpc/addr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) #include <linux/sunrpc/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #include <linux/sunrpc/xprtsock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) #include <trace/events/sunrpc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #include "netns.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #define RPCBIND_SOCK_PATHNAME	"/var/run/rpcbind.sock"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) #define RPCBIND_PROGRAM		(100000u)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) #define RPCBIND_PORT		(111u)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) #define RPCBVERS_2		(2u)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) #define RPCBVERS_3		(3u)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #define RPCBVERS_4		(4u)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 	RPCBPROC_NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) 	RPCBPROC_SET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 	RPCBPROC_UNSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 	RPCBPROC_GETPORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 	RPCBPROC_GETADDR = 3,		/* alias for GETPORT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 	RPCBPROC_DUMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 	RPCBPROC_CALLIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 	RPCBPROC_BCAST = 5,		/* alias for CALLIT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 	RPCBPROC_GETTIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 	RPCBPROC_UADDR2TADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 	RPCBPROC_TADDR2UADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	RPCBPROC_GETVERSADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 	RPCBPROC_INDIRECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 	RPCBPROC_GETADDRLIST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 	RPCBPROC_GETSTAT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66)  * r_owner
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68)  * The "owner" is allowed to unset a service in the rpcbind database.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70)  * For AF_LOCAL SET/UNSET requests, rpcbind treats this string as a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71)  * UID which it maps to a local user name via a password lookup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72)  * In all other cases it is ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74)  * For SET/UNSET requests, user space provides a value, even for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75)  * network requests, and GETADDR uses an empty string.  We follow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76)  * those precedents here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) #define RPCB_OWNER_STRING	"0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) #define RPCB_MAXOWNERLEN	sizeof(RPCB_OWNER_STRING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82)  * XDR data type sizes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) #define RPCB_program_sz		(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) #define RPCB_version_sz		(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) #define RPCB_protocol_sz	(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) #define RPCB_port_sz		(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) #define RPCB_boolean_sz		(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) #define RPCB_netid_sz		(1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) #define RPCB_addr_sz		(1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) #define RPCB_ownerstring_sz	(1 + XDR_QUADLEN(RPCB_MAXOWNERLEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95)  * XDR argument and result sizes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) #define RPCB_mappingargs_sz	(RPCB_program_sz + RPCB_version_sz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 				RPCB_protocol_sz + RPCB_port_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) #define RPCB_getaddrargs_sz	(RPCB_program_sz + RPCB_version_sz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 				RPCB_netid_sz + RPCB_addr_sz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 				RPCB_ownerstring_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) #define RPCB_getportres_sz	RPCB_port_sz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) #define RPCB_setres_sz		RPCB_boolean_sz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107)  * Note that RFC 1833 does not put any size restrictions on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108)  * address string returned by the remote rpcbind database.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) #define RPCB_getaddrres_sz	RPCB_addr_sz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) static void			rpcb_getport_done(struct rpc_task *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) static void			rpcb_map_release(void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) static const struct rpc_program	rpcb_program;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) struct rpcbind_args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	struct rpc_xprt *	r_xprt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	u32			r_prog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 	u32			r_vers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	u32			r_prot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	unsigned short		r_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	const char *		r_netid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 	const char *		r_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	const char *		r_owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	int			r_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) static const struct rpc_procinfo rpcb_procedures2[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) static const struct rpc_procinfo rpcb_procedures3[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) static const struct rpc_procinfo rpcb_procedures4[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) struct rpcb_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	u32			rpc_vers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	const struct rpc_procinfo *rpc_proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) static const struct rpcb_info rpcb_next_version[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) static const struct rpcb_info rpcb_next_version6[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) static const struct rpc_call_ops rpcb_getport_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	.rpc_call_done		= rpcb_getport_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 	.rpc_release		= rpcb_map_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) static void rpcb_wake_rpcbind_waiters(struct rpc_xprt *xprt, int status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 	xprt_clear_binding(xprt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	rpc_wake_up_status(&xprt->binding, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) static void rpcb_map_release(void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	struct rpcbind_args *map = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	rpcb_wake_rpcbind_waiters(map->r_xprt, map->r_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	xprt_put(map->r_xprt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 	kfree(map->r_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	kfree(map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) static int rpcb_get_local(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 	int cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	spin_lock(&sn->rpcb_clnt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	if (sn->rpcb_users)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 		sn->rpcb_users++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 	cnt = sn->rpcb_users;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	spin_unlock(&sn->rpcb_clnt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	return cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) void rpcb_put_local(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 	struct rpc_clnt *clnt = sn->rpcb_local_clnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 	struct rpc_clnt *clnt4 = sn->rpcb_local_clnt4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	int shutdown = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	spin_lock(&sn->rpcb_clnt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	if (sn->rpcb_users) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 		if (--sn->rpcb_users == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 			sn->rpcb_local_clnt = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 			sn->rpcb_local_clnt4 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 		shutdown = !sn->rpcb_users;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	spin_unlock(&sn->rpcb_clnt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	if (shutdown) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 		 * cleanup_rpcb_clnt - remove xprtsock's sysctls, unregister
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 		if (clnt4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 			rpc_shutdown_client(clnt4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 		if (clnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 			rpc_shutdown_client(clnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) static void rpcb_set_local(struct net *net, struct rpc_clnt *clnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 			struct rpc_clnt *clnt4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 			bool is_af_local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 	/* Protected by rpcb_create_local_mutex */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	sn->rpcb_local_clnt = clnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	sn->rpcb_local_clnt4 = clnt4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	sn->rpcb_is_af_local = is_af_local ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	smp_wmb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	sn->rpcb_users = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220)  * Returns zero on success, otherwise a negative errno value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221)  * is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) static int rpcb_create_local_unix(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	static const struct sockaddr_un rpcb_localaddr_rpcbind = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 		.sun_family		= AF_LOCAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 		.sun_path		= RPCBIND_SOCK_PATHNAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	struct rpc_create_args args = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 		.net		= net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 		.protocol	= XPRT_TRANSPORT_LOCAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 		.address	= (struct sockaddr *)&rpcb_localaddr_rpcbind,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 		.addrsize	= sizeof(rpcb_localaddr_rpcbind),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 		.servername	= "localhost",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 		.program	= &rpcb_program,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 		.version	= RPCBVERS_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 		.authflavor	= RPC_AUTH_NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 		.cred		= current_cred(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 		 * We turn off the idle timeout to prevent the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 		 * from automatically disconnecting the socket.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 		 * Otherwise, we'd have to cache the mount namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 		 * of the caller and somehow pass that to the socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 		 * reconnect code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 		.flags		= RPC_CLNT_CREATE_NO_IDLE_TIMEOUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	struct rpc_clnt *clnt, *clnt4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	int result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	 * Because we requested an RPC PING at transport creation time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	 * this works only if the user space portmapper is rpcbind, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	 * it's listening on AF_LOCAL on the named socket.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	clnt = rpc_create(&args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	if (IS_ERR(clnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 		result = PTR_ERR(clnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	clnt4 = rpc_bind_new_program(clnt, &rpcb_program, RPCBVERS_4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	if (IS_ERR(clnt4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 		clnt4 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	rpcb_set_local(net, clnt, clnt4, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273)  * Returns zero on success, otherwise a negative errno value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274)  * is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) static int rpcb_create_local_net(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 	static const struct sockaddr_in rpcb_inaddr_loopback = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 		.sin_family		= AF_INET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 		.sin_addr.s_addr	= htonl(INADDR_LOOPBACK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 		.sin_port		= htons(RPCBIND_PORT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 	struct rpc_create_args args = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 		.net		= net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 		.protocol	= XPRT_TRANSPORT_TCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 		.address	= (struct sockaddr *)&rpcb_inaddr_loopback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 		.addrsize	= sizeof(rpcb_inaddr_loopback),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 		.servername	= "localhost",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 		.program	= &rpcb_program,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 		.version	= RPCBVERS_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 		.authflavor	= RPC_AUTH_UNIX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 		.cred		= current_cred(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 		.flags		= RPC_CLNT_CREATE_NOPING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	struct rpc_clnt *clnt, *clnt4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 	int result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	clnt = rpc_create(&args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	if (IS_ERR(clnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 		result = PTR_ERR(clnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	 * This results in an RPC ping.  On systems running portmapper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	 * the v4 ping will fail.  Proceed anyway, but disallow rpcb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 	 * v4 upcalls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	clnt4 = rpc_bind_new_program(clnt, &rpcb_program, RPCBVERS_4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	if (IS_ERR(clnt4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 		clnt4 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	rpcb_set_local(net, clnt, clnt4, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320)  * Returns zero on success, otherwise a negative errno value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321)  * is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) int rpcb_create_local(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	static DEFINE_MUTEX(rpcb_create_local_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	int result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	if (rpcb_get_local(net))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 		return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	mutex_lock(&rpcb_create_local_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	if (rpcb_get_local(net))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	if (rpcb_create_local_unix(net) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 		result = rpcb_create_local_net(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	mutex_unlock(&rpcb_create_local_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) static struct rpc_clnt *rpcb_create(struct net *net, const char *nodename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 				    const char *hostname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 				    struct sockaddr *srvaddr, size_t salen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 				    int proto, u32 version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 				    const struct cred *cred)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	struct rpc_create_args args = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 		.net		= net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 		.protocol	= proto,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 		.address	= srvaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 		.addrsize	= salen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 		.servername	= hostname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 		.nodename	= nodename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 		.program	= &rpcb_program,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 		.version	= version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 		.authflavor	= RPC_AUTH_UNIX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 		.cred		= cred,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 		.flags		= (RPC_CLNT_CREATE_NOPING |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 					RPC_CLNT_CREATE_NONPRIVPORT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 	switch (srvaddr->sa_family) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 	case AF_INET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 		((struct sockaddr_in *)srvaddr)->sin_port = htons(RPCBIND_PORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	case AF_INET6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 		((struct sockaddr_in6 *)srvaddr)->sin6_port = htons(RPCBIND_PORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 		return ERR_PTR(-EAFNOSUPPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	return rpc_create(&args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) static int rpcb_register_call(struct sunrpc_net *sn, struct rpc_clnt *clnt, struct rpc_message *msg, bool is_set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 	int flags = RPC_TASK_NOCONNECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 	int error, result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	if (is_set || !sn->rpcb_is_af_local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 		flags = RPC_TASK_SOFTCONN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	msg->rpc_resp = &result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 	error = rpc_call_sync(clnt, msg, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	if (!result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 		return -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397)  * rpcb_register - set or unset a port registration with the local rpcbind svc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398)  * @net: target network namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399)  * @prog: RPC program number to bind
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400)  * @vers: RPC version number to bind
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401)  * @prot: transport protocol to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402)  * @port: port value to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404)  * Returns zero if the registration request was dispatched successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405)  * and the rpcbind daemon returned success.  Otherwise, returns an errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406)  * value that reflects the nature of the error (request could not be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407)  * dispatched, timed out, or rpcbind returned an error).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409)  * RPC services invoke this function to advertise their contact
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410)  * information via the system's rpcbind daemon.  RPC services
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411)  * invoke this function once for each [program, version, transport]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412)  * tuple they wish to advertise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414)  * Callers may also unregister RPC services that are no longer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415)  * available by setting the passed-in port to zero.  This removes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416)  * all registered transports for [program, version] from the local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417)  * rpcbind database.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419)  * This function uses rpcbind protocol version 2 to contact the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420)  * local rpcbind daemon.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422)  * Registration works over both AF_INET and AF_INET6, and services
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423)  * registered via this function are advertised as available for any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424)  * address.  If the local rpcbind daemon is listening on AF_INET6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425)  * services registered via this function will be advertised on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426)  * IN6ADDR_ANY (ie available for all AF_INET and AF_INET6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427)  * addresses).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) int rpcb_register(struct net *net, u32 prog, u32 vers, int prot, unsigned short port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 	struct rpcbind_args map = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 		.r_prog		= prog,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 		.r_vers		= vers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 		.r_prot		= prot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 		.r_port		= port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 		.rpc_argp	= &map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	bool is_set = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	trace_pmap_register(prog, vers, prot, port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 	msg.rpc_proc = &rpcb_procedures2[RPCBPROC_UNSET];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	if (port != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 		msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 		is_set = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 	return rpcb_register_call(sn, sn->rpcb_local_clnt, &msg, is_set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455)  * Fill in AF_INET family-specific arguments to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) static int rpcb_register_inet4(struct sunrpc_net *sn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 			       const struct sockaddr *sap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 			       struct rpc_message *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	const struct sockaddr_in *sin = (const struct sockaddr_in *)sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	struct rpcbind_args *map = msg->rpc_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	unsigned short port = ntohs(sin->sin_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	bool is_set = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	if (port != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 		msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 		is_set = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 	result = rpcb_register_call(sn, sn->rpcb_local_clnt4, msg, is_set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	kfree(map->r_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481)  * Fill in AF_INET6 family-specific arguments to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) static int rpcb_register_inet6(struct sunrpc_net *sn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 			       const struct sockaddr *sap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 			       struct rpc_message *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	struct rpcbind_args *map = msg->rpc_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	unsigned short port = ntohs(sin6->sin6_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	bool is_set = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	if (port != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 		msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 		is_set = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 	result = rpcb_register_call(sn, sn->rpcb_local_clnt4, msg, is_set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	kfree(map->r_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) static int rpcb_unregister_all_protofamilies(struct sunrpc_net *sn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 					     struct rpc_message *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 	struct rpcbind_args *map = msg->rpc_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	trace_rpcb_unregister(map->r_prog, map->r_vers, map->r_netid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	map->r_addr = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	return rpcb_register_call(sn, sn->rpcb_local_clnt4, msg, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520)  * rpcb_v4_register - set or unset a port registration with the local rpcbind
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521)  * @net: target network namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522)  * @program: RPC program number of service to (un)register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523)  * @version: RPC version number of service to (un)register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524)  * @address: address family, IP address, and port to (un)register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525)  * @netid: netid of transport protocol to (un)register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527)  * Returns zero if the registration request was dispatched successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528)  * and the rpcbind daemon returned success.  Otherwise, returns an errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529)  * value that reflects the nature of the error (request could not be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530)  * dispatched, timed out, or rpcbind returned an error).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532)  * RPC services invoke this function to advertise their contact
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533)  * information via the system's rpcbind daemon.  RPC services
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534)  * invoke this function once for each [program, version, address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535)  * netid] tuple they wish to advertise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537)  * Callers may also unregister RPC services that are registered at a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538)  * specific address by setting the port number in @address to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539)  * They may unregister all registered protocol families at once for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540)  * a service by passing a NULL @address argument.  If @netid is ""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541)  * then all netids for [program, version, address] are unregistered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543)  * This function uses rpcbind protocol version 4 to contact the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544)  * local rpcbind daemon.  The local rpcbind daemon must support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545)  * version 4 of the rpcbind protocol in order for these functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546)  * to register a service successfully.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548)  * Supported netids include "udp" and "tcp" for UDP and TCP over
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549)  * IPv4, and "udp6" and "tcp6" for UDP and TCP over IPv6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550)  * respectively.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552)  * The contents of @address determine the address family and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553)  * port to be registered.  The usual practice is to pass INADDR_ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554)  * as the raw address, but specifying a non-zero address is also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555)  * supported by this API if the caller wishes to advertise an RPC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556)  * service on a specific network interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558)  * Note that passing in INADDR_ANY does not create the same service
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559)  * registration as IN6ADDR_ANY.  The former advertises an RPC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560)  * service on any IPv4 address, but not on IPv6.  The latter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561)  * advertises the service on all IPv4 and IPv6 addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) int rpcb_v4_register(struct net *net, const u32 program, const u32 version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 		     const struct sockaddr *address, const char *netid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	struct rpcbind_args map = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 		.r_prog		= program,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 		.r_vers		= version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 		.r_netid	= netid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 		.r_owner	= RPCB_OWNER_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 		.rpc_argp	= &map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	if (sn->rpcb_local_clnt4 == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 		return -EPROTONOSUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	if (address == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 		return rpcb_unregister_all_protofamilies(sn, &msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	trace_rpcb_register(map.r_prog, map.r_vers, map.r_addr, map.r_netid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 	switch (address->sa_family) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	case AF_INET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 		return rpcb_register_inet4(sn, address, &msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	case AF_INET6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 		return rpcb_register_inet6(sn, address, &msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 	return -EAFNOSUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 		struct rpcbind_args *map, const struct rpc_procinfo *proc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 		.rpc_proc = proc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 		.rpc_argp = map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 		.rpc_resp = map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 	struct rpc_task_setup task_setup_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 		.rpc_client = rpcb_clnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 		.rpc_message = &msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 		.callback_ops = &rpcb_getport_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		.callback_data = map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 		.flags = RPC_TASK_ASYNC | RPC_TASK_SOFTCONN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	return rpc_run_task(&task_setup_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615)  * In the case where rpc clients have been cloned, we want to make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616)  * sure that we use the program number/version etc of the actual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617)  * owner of the xprt. To do so, we walk back up the tree of parents
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618)  * to find whoever created the transport and/or whoever has the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619)  * autobind flag set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) static struct rpc_clnt *rpcb_find_transport_owner(struct rpc_clnt *clnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	struct rpc_clnt *parent = clnt->cl_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	struct rpc_xprt_switch *xps = rcu_access_pointer(clnt->cl_xpi.xpi_xpswitch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	while (parent != clnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 		if (rcu_access_pointer(parent->cl_xpi.xpi_xpswitch) != xps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 		if (clnt->cl_autobind)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 		clnt = parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 		parent = parent->cl_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 	return clnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638)  * rpcb_getport_async - obtain the port for a given RPC service on a given host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639)  * @task: task that is waiting for portmapper request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641)  * This one can be called for an ongoing RPC request, and can be used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642)  * an async (rpciod) context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) void rpcb_getport_async(struct rpc_task *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	struct rpc_clnt *clnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	const struct rpc_procinfo *proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	u32 bind_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	struct rpc_xprt *xprt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	struct rpc_clnt	*rpcb_clnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	struct rpcbind_args *map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 	struct rpc_task	*child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	struct sockaddr_storage addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 	struct sockaddr *sap = (struct sockaddr *)&addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 	size_t salen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	clnt = rpcb_find_transport_owner(task->tk_client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	xprt = xprt_get(task->tk_xprt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	/* Put self on the wait queue to ensure we get notified if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	 * some other task is already attempting to bind the port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	rpc_sleep_on_timeout(&xprt->binding, task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 			NULL, jiffies + xprt->bind_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 	if (xprt_test_and_set_binding(xprt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 		xprt_put(xprt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	/* Someone else may have bound if we slept */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	if (xprt_bound(xprt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 		status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 		goto bailout_nofree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	/* Parent transport's destination address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 	salen = rpc_peeraddr(clnt, sap, sizeof(addr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 	/* Don't ever use rpcbind v2 for AF_INET6 requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 	switch (sap->sa_family) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	case AF_INET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 		proc = rpcb_next_version[xprt->bind_index].rpc_proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 		bind_version = rpcb_next_version[xprt->bind_index].rpc_vers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	case AF_INET6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 		proc = rpcb_next_version6[xprt->bind_index].rpc_proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 		bind_version = rpcb_next_version6[xprt->bind_index].rpc_vers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 		status = -EAFNOSUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 		goto bailout_nofree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	if (proc == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 		xprt->bind_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 		status = -EPFNOSUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 		goto bailout_nofree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	trace_rpcb_getport(clnt, task, bind_version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	rpcb_clnt = rpcb_create(xprt->xprt_net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 				clnt->cl_nodename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 				xprt->servername, sap, salen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 				xprt->prot, bind_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 				clnt->cl_cred);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	if (IS_ERR(rpcb_clnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 		status = PTR_ERR(rpcb_clnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 		goto bailout_nofree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 	map = kzalloc(sizeof(struct rpcbind_args), GFP_NOFS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 	if (!map) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 		status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 		goto bailout_release_client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	map->r_prog = clnt->cl_prog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	map->r_vers = clnt->cl_vers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	map->r_prot = xprt->prot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	map->r_port = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 	map->r_xprt = xprt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	map->r_status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	switch (bind_version) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	case RPCBVERS_4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	case RPCBVERS_3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 		map->r_netid = xprt->address_strings[RPC_DISPLAY_NETID];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 		map->r_addr = rpc_sockaddr2uaddr(sap, GFP_NOFS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 		if (!map->r_addr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 			status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 			goto bailout_free_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 		map->r_owner = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	case RPCBVERS_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 		map->r_addr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 		BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	child = rpcb_call_async(rpcb_clnt, map, proc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	rpc_release_client(rpcb_clnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	xprt->stat.bind_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	rpc_put_task(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) bailout_free_args:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	kfree(map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) bailout_release_client:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 	rpc_release_client(rpcb_clnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) bailout_nofree:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	rpcb_wake_rpcbind_waiters(xprt, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	task->tk_status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	xprt_put(xprt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) EXPORT_SYMBOL_GPL(rpcb_getport_async);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763)  * Rpcbind child task calls this callback via tk_exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) static void rpcb_getport_done(struct rpc_task *child, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	struct rpcbind_args *map = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	struct rpc_xprt *xprt = map->r_xprt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	map->r_status = child->tk_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	/* Garbage reply: retry with a lesser rpcbind version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	if (map->r_status == -EIO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 		map->r_status = -EPROTONOSUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	/* rpcbind server doesn't support this rpcbind protocol version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	if (map->r_status == -EPROTONOSUPPORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 		xprt->bind_index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	if (map->r_status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 		/* rpcbind server not available on remote host? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 		map->r_port = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	} else if (map->r_port == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 		/* Requested RPC service wasn't registered on remote host */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 		map->r_status = -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 		/* Succeeded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 		map->r_status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	trace_rpcb_setport(child, map->r_status, map->r_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	xprt->ops->set_port(xprt, map->r_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	if (map->r_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 		xprt_set_bound(xprt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799)  * XDR functions for rpcbind
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) static void rpcb_enc_mapping(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 			     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	const struct rpcbind_args *rpcb = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	p = xdr_reserve_space(xdr, RPCB_mappingargs_sz << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 	*p++ = cpu_to_be32(rpcb->r_prog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 	*p++ = cpu_to_be32(rpcb->r_vers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	*p++ = cpu_to_be32(rpcb->r_prot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	*p   = cpu_to_be32(rpcb->r_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) static int rpcb_dec_getport(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 			    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	struct rpcbind_args *rpcb = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	unsigned long port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	rpcb->r_port = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	if (unlikely(p == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	port = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 	if (unlikely(port > USHRT_MAX))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 	rpcb->r_port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) static int rpcb_dec_set(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 			void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	unsigned int *boolp = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 	if (unlikely(p == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	*boolp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	if (*p != xdr_zero)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 		*boolp = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) static void encode_rpcb_string(struct xdr_stream *xdr, const char *string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 			       const u32 maxstrlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	len = strlen(string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 	WARN_ON_ONCE(len > maxstrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 	if (len > maxstrlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 		/* truncate and hope for the best */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		len = maxstrlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	p = xdr_reserve_space(xdr, 4 + len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 	xdr_encode_opaque(p, string, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) static void rpcb_enc_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 			     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	const struct rpcbind_args *rpcb = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 	p = xdr_reserve_space(xdr, (RPCB_program_sz + RPCB_version_sz) << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	*p++ = cpu_to_be32(rpcb->r_prog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 	*p = cpu_to_be32(rpcb->r_vers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	encode_rpcb_string(xdr, rpcb->r_netid, RPCBIND_MAXNETIDLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	encode_rpcb_string(xdr, rpcb->r_addr, RPCBIND_MAXUADDRLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 	encode_rpcb_string(xdr, rpcb->r_owner, RPCB_MAXOWNERLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 			    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 	struct rpcbind_args *rpcb = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	struct sockaddr_storage address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	struct sockaddr *sap = (struct sockaddr *)&address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	rpcb->r_port = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	if (unlikely(p == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 		goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	 * If the returned universal address is a null string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 	 * the requested RPC service was not registered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 	if (len == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	if (unlikely(len > RPCBIND_MAXUADDRLEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 		goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	p = xdr_inline_decode(xdr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 	if (unlikely(p == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 		goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 	if (rpc_uaddr2sockaddr(req->rq_xprt->xprt_net, (char *)p, len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 				sap, sizeof(address)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 		goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 	rpcb->r_port = rpc_get_port(sap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) out_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924)  * Not all rpcbind procedures described in RFC 1833 are implemented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925)  * since the Linux kernel RPC code requires only these.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) static const struct rpc_procinfo rpcb_procedures2[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	[RPCBPROC_SET] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 		.p_proc		= RPCBPROC_SET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 		.p_encode	= rpcb_enc_mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 		.p_decode	= rpcb_dec_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 		.p_arglen	= RPCB_mappingargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 		.p_replen	= RPCB_setres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 		.p_statidx	= RPCBPROC_SET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 		.p_timer	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 		.p_name		= "SET",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	[RPCBPROC_UNSET] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 		.p_proc		= RPCBPROC_UNSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 		.p_encode	= rpcb_enc_mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 		.p_decode	= rpcb_dec_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 		.p_arglen	= RPCB_mappingargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 		.p_replen	= RPCB_setres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 		.p_statidx	= RPCBPROC_UNSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 		.p_timer	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 		.p_name		= "UNSET",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 	[RPCBPROC_GETPORT] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 		.p_proc		= RPCBPROC_GETPORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 		.p_encode	= rpcb_enc_mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 		.p_decode	= rpcb_dec_getport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 		.p_arglen	= RPCB_mappingargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 		.p_replen	= RPCB_getportres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 		.p_statidx	= RPCBPROC_GETPORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 		.p_timer	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 		.p_name		= "GETPORT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) static const struct rpc_procinfo rpcb_procedures3[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 	[RPCBPROC_SET] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 		.p_proc		= RPCBPROC_SET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 		.p_encode	= rpcb_enc_getaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 		.p_decode	= rpcb_dec_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 		.p_arglen	= RPCB_getaddrargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 		.p_replen	= RPCB_setres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 		.p_statidx	= RPCBPROC_SET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 		.p_timer	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 		.p_name		= "SET",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	[RPCBPROC_UNSET] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 		.p_proc		= RPCBPROC_UNSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 		.p_encode	= rpcb_enc_getaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 		.p_decode	= rpcb_dec_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 		.p_arglen	= RPCB_getaddrargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 		.p_replen	= RPCB_setres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 		.p_statidx	= RPCBPROC_UNSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 		.p_timer	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 		.p_name		= "UNSET",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	[RPCBPROC_GETADDR] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 		.p_proc		= RPCBPROC_GETADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 		.p_encode	= rpcb_enc_getaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 		.p_decode	= rpcb_dec_getaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 		.p_arglen	= RPCB_getaddrargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 		.p_replen	= RPCB_getaddrres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 		.p_statidx	= RPCBPROC_GETADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 		.p_timer	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 		.p_name		= "GETADDR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) static const struct rpc_procinfo rpcb_procedures4[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 	[RPCBPROC_SET] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 		.p_proc		= RPCBPROC_SET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 		.p_encode	= rpcb_enc_getaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 		.p_decode	= rpcb_dec_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 		.p_arglen	= RPCB_getaddrargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 		.p_replen	= RPCB_setres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 		.p_statidx	= RPCBPROC_SET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 		.p_timer	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 		.p_name		= "SET",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 	[RPCBPROC_UNSET] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 		.p_proc		= RPCBPROC_UNSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 		.p_encode	= rpcb_enc_getaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 		.p_decode	= rpcb_dec_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 		.p_arglen	= RPCB_getaddrargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 		.p_replen	= RPCB_setres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 		.p_statidx	= RPCBPROC_UNSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 		.p_timer	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 		.p_name		= "UNSET",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	[RPCBPROC_GETADDR] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 		.p_proc		= RPCBPROC_GETADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 		.p_encode	= rpcb_enc_getaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 		.p_decode	= rpcb_dec_getaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 		.p_arglen	= RPCB_getaddrargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 		.p_replen	= RPCB_getaddrres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 		.p_statidx	= RPCBPROC_GETADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 		.p_timer	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 		.p_name		= "GETADDR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) static const struct rpcb_info rpcb_next_version[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 		.rpc_vers	= RPCBVERS_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 		.rpc_proc	= &rpcb_procedures2[RPCBPROC_GETPORT],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 		.rpc_proc	= NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) static const struct rpcb_info rpcb_next_version6[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 		.rpc_vers	= RPCBVERS_4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 		.rpc_proc	= &rpcb_procedures4[RPCBPROC_GETADDR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 		.rpc_vers	= RPCBVERS_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 		.rpc_proc	= &rpcb_procedures3[RPCBPROC_GETADDR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 		.rpc_proc	= NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) static unsigned int rpcb_version2_counts[ARRAY_SIZE(rpcb_procedures2)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) static const struct rpc_version rpcb_version2 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	.number		= RPCBVERS_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	.nrprocs	= ARRAY_SIZE(rpcb_procedures2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	.procs		= rpcb_procedures2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	.counts		= rpcb_version2_counts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) static unsigned int rpcb_version3_counts[ARRAY_SIZE(rpcb_procedures3)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) static const struct rpc_version rpcb_version3 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 	.number		= RPCBVERS_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 	.nrprocs	= ARRAY_SIZE(rpcb_procedures3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	.procs		= rpcb_procedures3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 	.counts		= rpcb_version3_counts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) static unsigned int rpcb_version4_counts[ARRAY_SIZE(rpcb_procedures4)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) static const struct rpc_version rpcb_version4 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 	.number		= RPCBVERS_4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 	.nrprocs	= ARRAY_SIZE(rpcb_procedures4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 	.procs		= rpcb_procedures4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	.counts		= rpcb_version4_counts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) static const struct rpc_version *rpcb_version[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 	NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 	&rpcb_version2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 	&rpcb_version3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 	&rpcb_version4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) static struct rpc_stat rpcb_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) static const struct rpc_program rpcb_program = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 	.name		= "rpcbind",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	.number		= RPCBIND_PROGRAM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 	.nrvers		= ARRAY_SIZE(rpcb_version),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 	.version	= rpcb_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 	.stats		= &rpcb_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) };