提交 d5a8620f 编写于 作者: C Chuck Lever 提交者: Trond Myklebust

SUNRPC: Simplify svc_unregister()

Our initial implementation of svc_unregister() assumed that PMAP_UNSET
cleared all rpcbind registrations for a [program, version] tuple.
However, we now have evidence that PMAP_UNSET clears only "inet"
entries, and not "inet6" entries, in the rpcbind database.

For backwards compatibility with the legacy portmapper, the
svc_unregister() function also must work if user space doesn't support
rpcbind version 4 at all.

Thus we'll send an rpcbind v4 UNSET, and if that fails, we'll send a
PMAP_UNSET.

This simplifies the code in svc_unregister() and provides better
backwards compatibility with legacy user space that does not support
rpcbind version 4.  We can get rid of the conditional compilation in
here as well.

This patch is part of a series that addresses
   http://bugzilla.kernel.org/show_bug.cgi?id=12256Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 1673d0de
...@@ -896,38 +896,31 @@ int svc_register(const struct svc_serv *serv, const int family, ...@@ -896,38 +896,31 @@ int svc_register(const struct svc_serv *serv, const int family,
return error; return error;
} }
#ifdef CONFIG_SUNRPC_REGISTER_V4 /*
* If user space is running rpcbind, it should take the v4 UNSET
* and clear everything for this [program, version]. If user space
* is running portmap, it will reject the v4 UNSET, but won't have
* any "inet6" entries anyway. So a PMAP_UNSET should be sufficient
* in this case to clear all existing entries for [program, version].
*/
static void __svc_unregister(const u32 program, const u32 version, static void __svc_unregister(const u32 program, const u32 version,
const char *progname) const char *progname)
{ {
struct sockaddr_in6 sin6 = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_ANY_INIT,
.sin6_port = 0,
};
int error; int error;
error = rpcb_v4_register(program, version, error = rpcb_v4_register(program, version, NULL, "");
(struct sockaddr *)&sin6, "");
dprintk("svc: %s(%sv%u), error %d\n",
__func__, progname, version, error);
}
#else /* CONFIG_SUNRPC_REGISTER_V4 */
static void __svc_unregister(const u32 program, const u32 version, /*
const char *progname) * User space didn't support rpcbind v4, so retry this
{ * request with the legacy rpcbind v2 protocol.
int error; */
if (error == -EPROTONOSUPPORT)
error = rpcb_register(program, version, 0, 0);
error = rpcb_register(program, version, 0, 0);
dprintk("svc: %s(%sv%u), error %d\n", dprintk("svc: %s(%sv%u), error %d\n",
__func__, progname, version, error); __func__, progname, version, error);
} }
#endif /* CONFIG_SUNRPC_REGISTER_V4 */
/* /*
* All netids, bind addresses and ports registered for [program, version] * All netids, bind addresses and ports registered for [program, version]
* are removed from the local rpcbind database (if the service is not * are removed from the local rpcbind database (if the service is not
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册