aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2009-03-18 20:47:21 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-03-28 15:57:00 -0400
commit1673d0de40ab46cac3b456ad50e1c8d6a31bfd66 (patch)
tree0d643ac1b4ad99d6d1bdee3cadfe9d6cf07810b1 /net
parent126e4bc3b3b446482696377f67a634c76eaf2e9c (diff)
SUNRPC: Allow callers to pass rpcb_v4_register a NULL address
The user space TI-RPC library uses an empty string for the universal address when unregistering all target addresses for [program, version]. The kernel's rpcb client should behave the same way. 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, as well, are switched on protocol family. In /etc/netconfig, this is either "inet" or "inet6". NB: The loopback protocol families are not supported in the kernel. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/rpcb_clnt.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index d550d0b967db..8ea8907d4b8d 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -262,8 +262,8 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port)
262/* 262/*
263 * Fill in AF_INET family-specific arguments to register 263 * Fill in AF_INET family-specific arguments to register
264 */ 264 */
265static int rpcb_register_netid4(const struct sockaddr *sap, 265static int rpcb_register_inet4(const struct sockaddr *sap,
266 struct rpc_message *msg) 266 struct rpc_message *msg)
267{ 267{
268 const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; 268 const struct sockaddr_in *sin = (const struct sockaddr_in *)sap;
269 struct rpcbind_args *map = msg->rpc_argp; 269 struct rpcbind_args *map = msg->rpc_argp;
@@ -290,8 +290,8 @@ static int rpcb_register_netid4(const struct sockaddr *sap,
290/* 290/*
291 * Fill in AF_INET6 family-specific arguments to register 291 * Fill in AF_INET6 family-specific arguments to register
292 */ 292 */
293static int rpcb_register_netid6(const struct sockaddr *sap, 293static int rpcb_register_inet6(const struct sockaddr *sap,
294 struct rpc_message *msg) 294 struct rpc_message *msg)
295{ 295{
296 const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap; 296 const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap;
297 struct rpcbind_args *map = msg->rpc_argp; 297 struct rpcbind_args *map = msg->rpc_argp;
@@ -319,6 +319,20 @@ static int rpcb_register_netid6(const struct sockaddr *sap,
319 return rpcb_register_call(RPCBVERS_4, msg); 319 return rpcb_register_call(RPCBVERS_4, msg);
320} 320}
321 321
322static int rpcb_unregister_all_protofamilies(struct rpc_message *msg)
323{
324 struct rpcbind_args *map = msg->rpc_argp;
325
326 dprintk("RPC: unregistering [%u, %u, '%s'] with "
327 "local rpcbind\n",
328 map->r_prog, map->r_vers, map->r_netid);
329
330 map->r_addr = "";
331 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
332
333 return rpcb_register_call(RPCBVERS_4, msg);
334}
335
322/** 336/**
323 * rpcb_v4_register - set or unset a port registration with the local rpcbind 337 * rpcb_v4_register - set or unset a port registration with the local rpcbind
324 * @program: RPC program number of service to (un)register 338 * @program: RPC program number of service to (un)register
@@ -336,10 +350,11 @@ static int rpcb_register_netid6(const struct sockaddr *sap,
336 * invoke this function once for each [program, version, address, 350 * invoke this function once for each [program, version, address,
337 * netid] tuple they wish to advertise. 351 * netid] tuple they wish to advertise.
338 * 352 *
339 * Callers may also unregister RPC services that are no longer 353 * Callers may also unregister RPC services that are registered at a
340 * available by setting the port number in the passed-in address 354 * specific address by setting the port number in @address to zero.
341 * to zero. Callers pass a netid of "" to unregister all 355 * They may unregister all registered protocol families at once for
342 * transport netids associated with [program, version, address]. 356 * a service by passing a NULL @address argument. If @netid is ""
357 * then all netids for [program, version, address] are unregistered.
343 * 358 *
344 * This function uses rpcbind protocol version 4 to contact the 359 * This function uses rpcbind protocol version 4 to contact the
345 * local rpcbind daemon. The local rpcbind daemon must support 360 * local rpcbind daemon. The local rpcbind daemon must support
@@ -374,11 +389,14 @@ int rpcb_v4_register(const u32 program, const u32 version,
374 .rpc_argp = &map, 389 .rpc_argp = &map,
375 }; 390 };
376 391
392 if (address == NULL)
393 return rpcb_unregister_all_protofamilies(&msg);
394
377 switch (address->sa_family) { 395 switch (address->sa_family) {
378 case AF_INET: 396 case AF_INET:
379 return rpcb_register_netid4(address, &msg); 397 return rpcb_register_inet4(address, &msg);
380 case AF_INET6: 398 case AF_INET6:
381 return rpcb_register_netid6(address, &msg); 399 return rpcb_register_inet6(address, &msg);
382 } 400 }
383 401
384 return -EAFNOSUPPORT; 402 return -EAFNOSUPPORT;