SUNRPC: Simplify socket shutdown when not reusing TCP ports
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Tue, 24 Aug 2021 15:38:17 +0000 (11:38 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Fri, 27 Aug 2021 20:36:21 +0000 (16:36 -0400)
If we're not required to reuse the TCP port, then we can just
immediately close the socket, and leave the cleanup details to the TCP
layer.

Fixes: e6237b6feb37 ("NFSv4.1: Don't rebind to the same source port when reconnecting to the server")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprtsock.c

index 02b071dbdd225b49c4d7ea4fe215013c3a3e847e..5fb969f8a5adf96daeb485020fac23816756b7bc 100644 (file)
@@ -2099,6 +2099,10 @@ static void xs_tcp_shutdown(struct rpc_xprt *xprt)
 
        if (sock == NULL)
                return;
+       if (!xprt->reuseport) {
+               xs_close(xprt);
+               return;
+       }
        switch (skst) {
        default:
                kernel_sock_shutdown(sock, SHUT_RDWR);