From: Manoj Basapathi <manojbm@codeaurora.org>
To: netfilter-devel@vger.kernel.org
Cc: fw@strlen.de, pablo@netfilter.org, sharathv@qti.qualcomm.com,
ssaha@qti.qualcomm.com, vidulak@qti.qualcomm.com,
manojbm@qti.qualcomm.com, subashab@quicinc.com,
rpavan@qti.qualcomm.com, Manoj Basapathi <manojbm@codeaurora.org>,
Sauvik Saha <ssaha@codeaurora.org>
Subject: [PATCH] tcp: Reset tcp connections in SYN-SENT state
Date: Wed, 31 Mar 2021 12:55:22 +0530 [thread overview]
Message-ID: <20210331072522.8576-1-manojbm@codeaurora.org> (raw)
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>
---
net/ipv4/tcp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e14fd0c50c10..627a472161fb 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2888,7 +2888,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)
@@ -2954,8 +2954,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);
--
2.29.0
next reply other threads:[~2021-03-31 7:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-31 7:25 Manoj Basapathi [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-04-05 17:02 [PATCH] tcp: Reset tcp connections in SYN-SENT state Manoj Basapathi
2021-04-09 16:52 ` Eric Dumazet
[not found] <20190220142754.GA5073@dendluri-linux.qualcomm.com>
2019-02-20 15:47 ` Eric Dumazet
2019-02-21 11:01 ` Devi Sandeep Endluri V V
2019-02-21 15:17 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210331072522.8576-1-manojbm@codeaurora.org \
--to=manojbm@codeaurora.org \
--cc=fw@strlen.de \
--cc=manojbm@qti.qualcomm.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=rpavan@qti.qualcomm.com \
--cc=sharathv@qti.qualcomm.com \
--cc=ssaha@codeaurora.org \
--cc=ssaha@qti.qualcomm.com \
--cc=subashab@quicinc.com \
--cc=vidulak@qti.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.