Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd: unregister with rpcbind when deleting a transport

When a listener is added, a part of creation of transport also registers
program/port with rpcbind. However, when the listener is removed,
while transport goes away, rpcbind still has the entry for that
port/type.

When deleting the transport, unregister with rpcbind when appropriate.

---v2 created a new xpt_flag XPT_RPCB_UNREG to mark TCP and UDP
transport and at xprt destroy send rpcbind unregister if flag set.

Suggested-by: Chuck Lever <chuck.lever@oracle.com>
Fixes: d093c9089260 ("nfsd: fix management of listener transports")
Cc: stable@vger.kernel.org
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

authored by

Olga Kornievskaia and committed by
Chuck Lever
898374fd f64397e0

+18
+3
include/linux/sunrpc/svc_xprt.h
··· 104 104 * it has access to. It is NOT counted 105 105 * in ->sv_tmpcnt. 106 106 */ 107 + XPT_RPCB_UNREG, /* transport that needs unregistering 108 + * with rpcbind (TCP, UDP) on destroy 109 + */ 107 110 }; 108 111 109 112 /*
+13
net/sunrpc/svc_xprt.c
··· 1014 1014 struct svc_serv *serv = xprt->xpt_server; 1015 1015 struct svc_deferred_req *dr; 1016 1016 1017 + /* unregister with rpcbind for when transport type is TCP or UDP. 1018 + */ 1019 + if (test_bit(XPT_RPCB_UNREG, &xprt->xpt_flags)) { 1020 + struct svc_sock *svsk = container_of(xprt, struct svc_sock, 1021 + sk_xprt); 1022 + struct socket *sock = svsk->sk_sock; 1023 + 1024 + if (svc_register(serv, xprt->xpt_net, sock->sk->sk_family, 1025 + sock->sk->sk_protocol, 0) < 0) 1026 + pr_warn("failed to unregister %s with rpcbind\n", 1027 + xprt->xpt_class->xcl_name); 1028 + } 1029 + 1017 1030 if (test_and_set_bit(XPT_DEAD, &xprt->xpt_flags)) 1018 1031 return; 1019 1032
+2
net/sunrpc/svcsock.c
··· 836 836 /* data might have come in before data_ready set up */ 837 837 set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); 838 838 set_bit(XPT_CHNGBUF, &svsk->sk_xprt.xpt_flags); 839 + set_bit(XPT_RPCB_UNREG, &svsk->sk_xprt.xpt_flags); 839 840 840 841 /* make sure we get destination address info */ 841 842 switch (svsk->sk_sk->sk_family) { ··· 1351 1350 if (sk->sk_state == TCP_LISTEN) { 1352 1351 strcpy(svsk->sk_xprt.xpt_remotebuf, "listener"); 1353 1352 set_bit(XPT_LISTENER, &svsk->sk_xprt.xpt_flags); 1353 + set_bit(XPT_RPCB_UNREG, &svsk->sk_xprt.xpt_flags); 1354 1354 sk->sk_data_ready = svc_tcp_listen_data_ready; 1355 1355 set_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags); 1356 1356 } else {