summaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2022-03-17 00:18:25 +0100
committerTrond Myklebust <trond.myklebust@hammerspace.com>2022-03-22 20:52:55 +0100
commit3b21f757c309c84a23a26d8cab20b743e0719705 (patch)
tree4018fdd451aeabb697457df769e3662d66a64051 /net/sunrpc/xprtsock.c
parentSUNRPC: Don't call connect() more than once on a TCP socket (diff)
downloadlinux-3b21f757c309c84a23a26d8cab20b743e0719705.tar.xz
linux-3b21f757c309c84a23a26d8cab20b743e0719705.zip
SUNRPC: Only save the TCP source port after the connection is complete
Since the RPC client uses a non-blocking connect(), we do not expect to see it return '0' under normal circumstances. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r--net/sunrpc/xprtsock.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 8f8a03c3315a..d2bf3b49dbf4 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -58,6 +58,7 @@
#include "sunrpc.h"
static void xs_close(struct rpc_xprt *xprt);
+static void xs_set_srcport(struct sock_xprt *transport, struct socket *sock);
static void xs_tcp_set_socket_timeouts(struct rpc_xprt *xprt,
struct socket *sock);
@@ -1025,6 +1026,8 @@ static int xs_tcp_send_request(struct rpc_rqst *req)
if (test_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state))
xs_tcp_set_socket_timeouts(xprt, transport->sock);
+ xs_set_srcport(transport, transport->sock);
+
/* Continue transmitting the packet/record. We must be careful
* to cope with writespace callbacks arriving _after_ we have
* called sendmsg(). */
@@ -2263,8 +2266,6 @@ static void xs_tcp_setup_socket(struct work_struct *work)
sock->sk->sk_state);
switch (status) {
case 0:
- xs_set_srcport(transport, sock);
- fallthrough;
case -EINPROGRESS:
/* SYN_SENT! */
set_bit(XPRT_SOCK_CONNECT_SENT, &transport->sock_state);