Skip to content

Commit e880f8b

Browse files
Manoj Basapathidavem330
authored andcommitted
tcp: Reset tcp connections in SYN-SENT state
Userspace sends tcp connection (sock) destroy on network switch i.e switching the default network of the device between multiple networks(Cellular/Wifi/Ethernet). Kernel though doesn't send reset for the connections in SYN-SENT state and these connections continue to remain. Even as per RFC 793, there is no hard rule to not send RST on ABORT in this state. Modify tcp_abort and tcp_disconnect behavior to send RST for connections in syn-sent state to avoid lingering connections on network switch. Signed-off-by: Manoj Basapathi <manojbm@codeaurora.org> Signed-off-by: Sauvik Saha <ssaha@codeaurora.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent cc0626c commit e880f8b

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

net/ipv4/tcp.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,7 +2888,7 @@ static inline bool tcp_need_reset(int state)
28882888
{
28892889
return (1 << state) &
28902890
(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_FIN_WAIT1 |
2891-
TCPF_FIN_WAIT2 | TCPF_SYN_RECV);
2891+
TCPF_FIN_WAIT2 | TCPF_SYN_RECV | TCPF_SYN_SENT);
28922892
}
28932893

28942894
static void tcp_rtx_queue_purge(struct sock *sk)
@@ -2954,8 +2954,7 @@ int tcp_disconnect(struct sock *sk, int flags)
29542954
*/
29552955
tcp_send_active_reset(sk, gfp_any());
29562956
sk->sk_err = ECONNRESET;
2957-
} else if (old_state == TCP_SYN_SENT)
2958-
sk->sk_err = ECONNRESET;
2957+
}
29592958

29602959
tcp_clear_xmit_timers(sk);
29612960
__skb_queue_purge(&sk->sk_receive_queue);

0 commit comments

Comments
 (0)