[PATCH 1/2] SUNRPC: Allow callers to pass rpcb_v4_register a NULL

Steve Dickson SteveD at redhat.com
Wed Feb 11 20:04:47 UTC 2009


The user space TI-RPC library uses an empty string for the universal
address when unregistering all target addresses for [program, version].
Allow the kernel's rpcb client to support the same.

Here, we are switching between several registration methods based on
the protocol family of the incoming address.  Rename the other rpcbind
v4 registration functions to make it clear that they are switched on
protocol family as well.  In /etc/netconfig, this is either "inet" or
"inet6".  The loopback protocol families are not supported in the
kernel.

Signed-off-by: Chuck Lever <chuck.lever at oracle.com>
Signed-off-by: Steve Dickson <steved at redhat.com>
---

 net/sunrpc/rpcb_clnt.c |   38 ++++++++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 10 deletions(-)

diff -up linux-2.6.28.x86_64/net/sunrpc/rpcb_clnt.c.orig linux-2.6.28.x86_64/net/sunrpc/rpcb_clnt.c
--- linux-2.6.28.x86_64/net/sunrpc/rpcb_clnt.c.orig	2009-02-10 13:14:34.000000000 -0500
+++ linux-2.6.28.x86_64/net/sunrpc/rpcb_clnt.c	2009-02-11 14:50:47.000000000 -0500
@@ -255,8 +255,8 @@ int rpcb_register(u32 prog, u32 vers, in
 /*
  * Fill in AF_INET family-specific arguments to register
  */
-static int rpcb_register_netid4(struct sockaddr_in *address_to_register,
-				struct rpc_message *msg)
+static int rpcb_register_inet4(struct sockaddr_in *address_to_register,
+			       struct rpc_message *msg)
 {
 	struct rpcbind_args *map = msg->rpc_argp;
 	unsigned short port = ntohs(address_to_register->sin_port);
@@ -283,8 +283,8 @@ static int rpcb_register_netid4(struct s
 /*
  * Fill in AF_INET6 family-specific arguments to register
  */
-static int rpcb_register_netid6(struct sockaddr_in6 *address_to_register,
-				struct rpc_message *msg)
+static int rpcb_register_inet6(struct sockaddr_in6 *address_to_register,
+			       struct rpc_message *msg)
 {
 	struct rpcbind_args *map = msg->rpc_argp;
 	unsigned short port = ntohs(address_to_register->sin6_port);
@@ -312,6 +312,20 @@ static int rpcb_register_netid6(struct s
 	return rpcb_register_call(RPCBVERS_4, msg);
 }
 
+static int rpcb_unregister_all_protofamilies(struct rpc_message *msg)
+{
+	struct rpcbind_args *map = msg->rpc_argp;
+
+	dprintk("RPC:       unregistering [%u, %u, '%s'] with "
+		"local rpcbind\n",
+			map->r_prog, map->r_vers, map->r_netid);
+
+	map->r_addr = "";
+	msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
+
+	return rpcb_register_call(RPCBVERS_4, msg);
+}
+
 /**
  * rpcb_v4_register - set or unset a port registration with the local rpcbind
  * @program: RPC program number of service to (un)register
@@ -329,10 +343,11 @@ static int rpcb_register_netid6(struct s
  * invoke this function once for each [program, version, address,
  * netid] tuple they wish to advertise.
  *
- * Callers may also unregister RPC services that are no longer
- * available by setting the port number in the passed-in address
- * to zero.  Callers pass a netid of "" to unregister all
- * transport netids associated with [program, version, address].
+ * Callers may also unregister RPC services that are registered at a
+ * specific address by setting the port number in @address to zero.
+ * They may unregister all registered protocol families at once for
+ * a service by passing a NULL @address argument.  If @netid is ""
+ * then all netids for [program, version, address] are unregistered.
  *
  * This function uses rpcbind protocol version 4 to contact the
  * local rpcbind daemon.  The local rpcbind daemon must support
@@ -367,12 +382,15 @@ int rpcb_v4_register(const u32 program, 
 		.rpc_argp	= &map,
 	};
 
+	if (address == NULL)
+		return rpcb_unregister_all_protofamilies(&msg);
+
 	switch (address->sa_family) {
 	case AF_INET:
-		return rpcb_register_netid4((struct sockaddr_in *)address,
+		return rpcb_register_inet4((struct sockaddr_in *)address,
 					    &msg);
 	case AF_INET6:
-		return rpcb_register_netid6((struct sockaddr_in6 *)address,
+		return rpcb_register_inet6((struct sockaddr_in6 *)address,
 					    &msg);
 	}
 




More information about the Fedora-kernel-list mailing list