SUNRPC: rpcbind should never reset the port to the value '0'
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 24 Mar 2025 23:05:48 +0000 (19:05 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 26 Mar 2025 16:17:38 +0000 (12:17 -0400)
If we already had a valid port number for the RPC service, then we
should not allow the rpcbind client to set it to the invalid value '0'.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
net/sunrpc/rpcb_clnt.c

index 102c3818bc54d4f9a1fc5f854c3a841289974869..53bcca365fb1cdb51a650f237b40514cf24b7952 100644 (file)
@@ -820,9 +820,10 @@ static void rpcb_getport_done(struct rpc_task *child, void *data)
        }
 
        trace_rpcb_setport(child, map->r_status, map->r_port);
-       xprt->ops->set_port(xprt, map->r_port);
-       if (map->r_port)
+       if (map->r_port) {
+               xprt->ops->set_port(xprt, map->r_port);
                xprt_set_bound(xprt);
+       }
 }
 
 /*