tcp: Reset tcp connections in SYN-SENT state

Userspace sends tcp connection (sock) destroy on network permission
change. 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.

CRs-Fixed: 2396964
Change-Id: If931fb979e519c474697d82d8c9dbaf0edb626e3
Signed-off-by: Devi Sandeep Endluri V V <dendluri@codeaurora.org>
This commit is contained in:
Devi Sandeep Endluri V V 2019-02-14 02:25:24 +05:30 committed by Gerrit - the friendly Code Review server
parent 80d0f458e2
commit d836ab70f5

View file

@ -2510,7 +2510,7 @@ static inline bool tcp_need_reset(int state)
{
return (1 << state) &
(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_FIN_WAIT1 |
TCPF_FIN_WAIT2 | TCPF_SYN_RECV);
TCPF_FIN_WAIT2 | TCPF_SYN_RECV | TCPF_SYN_SENT);
}
static void tcp_rtx_queue_purge(struct sock *sk)
@ -2572,8 +2572,7 @@ int tcp_disconnect(struct sock *sk, int flags)
*/
tcp_send_active_reset(sk, gfp_any());
sk->sk_err = ECONNRESET;
} else if (old_state == TCP_SYN_SENT)
sk->sk_err = ECONNRESET;
}
tcp_clear_xmit_timers(sk);
__skb_queue_purge(&sk->sk_receive_queue);