Skip to content

Commit 1f4c17a

Browse files
committed
SUNRPC: Handle EADDRNOTAVAIL on connection failures
If the connect attempt immediately fails with an EADDRNOTAVAIL error, then that means our choice of source port number was bad. This error is expected when we set the SO_REUSEPORT socket option and we have 2 sockets sharing the same source and destination address and port combinations. Signed-off-by: Trond Myklebust <[email protected]> Fixes: 402e23b ("SUNRPC: Fix stupid typo in xs_sock_set_reuseport") Cc: [email protected] # v4.0+
1 parent 944171c commit 1f4c17a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/sunrpc/xprtsock.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,6 +2295,10 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
22952295
/* SYN_SENT! */
22962296
if (xprt->reestablish_timeout < XS_TCP_INIT_REEST_TO)
22972297
xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
2298+
break;
2299+
case -EADDRNOTAVAIL:
2300+
/* Source port number is unavailable. Try a new one! */
2301+
transport->srcport = 0;
22982302
}
22992303
out:
23002304
return ret;

0 commit comments

Comments
 (0)