Skip to content

Commit 898374f

Browse files
Olga Kornievskaiachucklever
authored andcommitted
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 <[email protected]> Fixes: d093c90 ("nfsd: fix management of listener transports") Cc: [email protected] Signed-off-by: Olga Kornievskaia <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent f64397e commit 898374f

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

include/linux/sunrpc/svc_xprt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ enum {
104104
* it has access to. It is NOT counted
105105
* in ->sv_tmpcnt.
106106
*/
107+
XPT_RPCB_UNREG, /* transport that needs unregistering
108+
* with rpcbind (TCP, UDP) on destroy
109+
*/
107110
};
108111

109112
/*

net/sunrpc/svc_xprt.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,19 @@ static void svc_delete_xprt(struct svc_xprt *xprt)
10141014
struct svc_serv *serv = xprt->xpt_server;
10151015
struct svc_deferred_req *dr;
10161016

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+
10171030
if (test_and_set_bit(XPT_DEAD, &xprt->xpt_flags))
10181031
return;
10191032

net/sunrpc/svcsock.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,7 @@ static void svc_udp_init(struct svc_sock *svsk, struct svc_serv *serv)
836836
/* data might have come in before data_ready set up */
837837
set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
838838
set_bit(XPT_CHNGBUF, &svsk->sk_xprt.xpt_flags);
839+
set_bit(XPT_RPCB_UNREG, &svsk->sk_xprt.xpt_flags);
839840

840841
/* make sure we get destination address info */
841842
switch (svsk->sk_sk->sk_family) {
@@ -1350,6 +1351,7 @@ static void svc_tcp_init(struct svc_sock *svsk, struct svc_serv *serv)
13501351
if (sk->sk_state == TCP_LISTEN) {
13511352
strcpy(svsk->sk_xprt.xpt_remotebuf, "listener");
13521353
set_bit(XPT_LISTENER, &svsk->sk_xprt.xpt_flags);
1354+
set_bit(XPT_RPCB_UNREG, &svsk->sk_xprt.xpt_flags);
13531355
sk->sk_data_ready = svc_tcp_listen_data_ready;
13541356
set_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags);
13551357
} else {

0 commit comments

Comments
 (0)