Skip to content

Commit

Permalink
SUNRPC: Only save the TCP source port after the connection is complete
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Trond Myklebust committed Mar 22, 2022
1 parent 89f4249 commit 3b21f75
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/sunrpc/xprtsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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(). */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3b21f75

Please sign in to comment.