[PATCH 2/2] SUNRPC: Reconnect with new port on server initiated connection termination

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Server initiated socket close can corrupt connection state tracking
table in conjunction with other network middle boxes. In situations
like these, client connection hangs till connection state tracking
table entries age out and get purged. Client reconnection with a new
port in such a situation will avoid connection hang.

Reviewed-by: Jacob Strauss <jsstraus@xxxxxxxxxx>
Reviewed-by: Alakesh Haloi <alakeshh@xxxxxxxxxx>
Signed-off-by: Vallish Vaidyeshwara <vallish@xxxxxxxxxx>
---
 net/sunrpc/xprtsock.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 5bf75b3..d293c8d 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1629,6 +1629,8 @@ static void xs_tcp_state_change(struct sock *sk)
 		/* The server initiated a shutdown of the socket */
 		xprt->connect_cookie++;
 		clear_bit(XPRT_CONNECTED, &xprt->state);
+		/* Server sent FIN, reconnect with a new port */
+		transport->srcport = 0;
 		xs_tcp_force_close(xprt);
 		/* fall through */
 	case TCP_CLOSING:
@@ -1650,6 +1652,9 @@ static void xs_tcp_state_change(struct sock *sk)
 					&transport->sock_state))
 			xprt_clear_connecting(xprt);
 		clear_bit(XPRT_CLOSING, &xprt->state);
+		/* Server sent RST, reconnect with a new port */
+		if (sk->sk_err == ECONNRESET)
+			transport->srcport = 0;
 		if (sk->sk_err)
 			xprt_wake_pending_tasks(xprt, -sk->sk_err);
 		/* Trigger the socket release */
-- 
2.7.3.AMZN

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux