From: Trond Myklebust <trond.myklebust@hammerspace.com>
Date: Tue, 24 Aug 2021 11:38:17 -0400
Subject: [PATCH] SUNRPC: Simplify socket shutdown when not reusing TCP ports
Git-commit: 0a6ff58edbfb26469a095ab964095506352fc960
Patch-mainline: v5.15
References: git-fixes
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>
Acked-by: NeilBrown <neilb@suse.com>
---
net/sunrpc/xprtsock.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2099,6 +2099,10 @@ static void xs_tcp_shutdown(struct rpc_x
if (sock == NULL)
return;
+ if (!xprt->reuseport) {
+ xs_close(xprt);
+ return;
+ }
switch (skst) {
default:
kernel_sock_shutdown(sock, SHUT_RDWR);