Message ID | 20240730133513.99986-5-kerneljasonxing@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | tcp: completely support active reset | expand |
From: Jason Xing <kerneljasonxing@gmail.com> Date: Tue, 30 Jul 2024 21:35:11 +0800 > From: Jason Xing <kernelxing@tencent.com> > > Introducing a new type TCP_STATE to handle some reset conditions > appearing in RFC 793 due to its socket state. Why not RFC 9293 ? Was there any discrepancy ? > > Signed-off-by: Jason Xing <kernelxing@tencent.com> > --- > include/net/rstreason.h | 6 ++++++ > net/ipv4/tcp.c | 4 ++-- > net/ipv4/tcp_timer.c | 2 +- > 3 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/include/net/rstreason.h b/include/net/rstreason.h > index eef658da8952..fecaa57f1634 100644 > --- a/include/net/rstreason.h > +++ b/include/net/rstreason.h > @@ -20,6 +20,7 @@ > FN(TCP_ABORT_ON_CLOSE) \ > FN(TCP_ABORT_ON_LINGER) \ > FN(TCP_ABORT_ON_MEMORY) \ > + FN(TCP_STATE) \ > FN(MPTCP_RST_EUNSPEC) \ > FN(MPTCP_RST_EMPTCP) \ > FN(MPTCP_RST_ERESOURCE) \ > @@ -102,6 +103,11 @@ enum sk_rst_reason { > * corresponding to LINUX_MIB_TCPABORTONMEMORY > */ > SK_RST_REASON_TCP_ABORT_ON_MEMORY, > + /** > + * @SK_RST_REASON_TCP_STATE: abort on tcp state > + * Please see RFC 793 for all possible reset conditions > + */ > + SK_RST_REASON_TCP_STATE, Same here.
Hello Kuniyuki, On Wed, Jul 31, 2024 at 4:06 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote: > > From: Jason Xing <kerneljasonxing@gmail.com> > Date: Tue, 30 Jul 2024 21:35:11 +0800 > > From: Jason Xing <kernelxing@tencent.com> > > > > Introducing a new type TCP_STATE to handle some reset conditions > > appearing in RFC 793 due to its socket state. > > Why not RFC 9293 ? > Was there any discrepancy ? Thanks for the review. My intention is to keep consistency with the comment in tcp_need_reset(). I have no strong preference here. Either way is fine with me. Thanks, Jason > > > > > > Signed-off-by: Jason Xing <kernelxing@tencent.com> > > --- > > include/net/rstreason.h | 6 ++++++ > > net/ipv4/tcp.c | 4 ++-- > > net/ipv4/tcp_timer.c | 2 +- > > 3 files changed, 9 insertions(+), 3 deletions(-) > > > > diff --git a/include/net/rstreason.h b/include/net/rstreason.h > > index eef658da8952..fecaa57f1634 100644 > > --- a/include/net/rstreason.h > > +++ b/include/net/rstreason.h > > @@ -20,6 +20,7 @@ > > FN(TCP_ABORT_ON_CLOSE) \ > > FN(TCP_ABORT_ON_LINGER) \ > > FN(TCP_ABORT_ON_MEMORY) \ > > + FN(TCP_STATE) \ > > FN(MPTCP_RST_EUNSPEC) \ > > FN(MPTCP_RST_EMPTCP) \ > > FN(MPTCP_RST_ERESOURCE) \ > > @@ -102,6 +103,11 @@ enum sk_rst_reason { > > * corresponding to LINUX_MIB_TCPABORTONMEMORY > > */ > > SK_RST_REASON_TCP_ABORT_ON_MEMORY, > > + /** > > + * @SK_RST_REASON_TCP_STATE: abort on tcp state > > + * Please see RFC 793 for all possible reset conditions > > + */ > > + SK_RST_REASON_TCP_STATE, > > Same here.
diff --git a/include/net/rstreason.h b/include/net/rstreason.h index eef658da8952..fecaa57f1634 100644 --- a/include/net/rstreason.h +++ b/include/net/rstreason.h @@ -20,6 +20,7 @@ FN(TCP_ABORT_ON_CLOSE) \ FN(TCP_ABORT_ON_LINGER) \ FN(TCP_ABORT_ON_MEMORY) \ + FN(TCP_STATE) \ FN(MPTCP_RST_EUNSPEC) \ FN(MPTCP_RST_EMPTCP) \ FN(MPTCP_RST_ERESOURCE) \ @@ -102,6 +103,11 @@ enum sk_rst_reason { * corresponding to LINUX_MIB_TCPABORTONMEMORY */ SK_RST_REASON_TCP_ABORT_ON_MEMORY, + /** + * @SK_RST_REASON_TCP_STATE: abort on tcp state + * Please see RFC 793 for all possible reset conditions + */ + SK_RST_REASON_TCP_STATE, /* Copy from include/uapi/linux/mptcp.h. * These reset fields will not be changed since they adhere to diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index fd928c447ce8..64a49cb714e1 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3031,7 +3031,7 @@ int tcp_disconnect(struct sock *sk, int flags) /* The last check adjusts for discrepancy of Linux wrt. RFC * states */ - tcp_send_active_reset(sk, gfp_any(), SK_RST_REASON_NOT_SPECIFIED); + tcp_send_active_reset(sk, gfp_any(), SK_RST_REASON_TCP_STATE); WRITE_ONCE(sk->sk_err, ECONNRESET); } else if (old_state == TCP_SYN_SENT) WRITE_ONCE(sk->sk_err, ECONNRESET); @@ -4649,7 +4649,7 @@ int tcp_abort(struct sock *sk, int err) if (!sock_flag(sk, SOCK_DEAD)) { if (tcp_need_reset(sk->sk_state)) tcp_send_active_reset(sk, GFP_ATOMIC, - SK_RST_REASON_NOT_SPECIFIED); + SK_RST_REASON_TCP_STATE); tcp_done_with_error(sk, err); } diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 0fba4a4fb988..3910f6d8614e 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -779,7 +779,7 @@ static void tcp_keepalive_timer (struct timer_list *t) goto out; } } - tcp_send_active_reset(sk, GFP_ATOMIC, SK_RST_REASON_NOT_SPECIFIED); + tcp_send_active_reset(sk, GFP_ATOMIC, SK_RST_REASON_TCP_STATE); goto death; }