diff mbox series

[net-next,5/6] tcp: rstreason: introduce SK_RST_REASON_TCP_TIMEOUT for active reset

Message ID 20240730133513.99986-6-kerneljasonxing@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series tcp: completely support active reset | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 59 this patch: 59
netdev/build_tools success Errors and warnings before: 10 this patch: 10
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 84 this patch: 84
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2229 this patch: 2229
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 3 this patch: 3
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-07-30--21-00 (tests: 707)

Commit Message

Jason Xing July 30, 2024, 1:35 p.m. UTC
From: Jason Xing <kernelxing@tencent.com>

Only when user sets TCP_USER_TIMEOUT option and there is no left
chance to proceed, we will send an RST to the other side.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
 include/net/rstreason.h | 7 +++++++
 net/ipv4/tcp_timer.c    | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

Kuniyuki Iwashima July 30, 2024, 8 p.m. UTC | #1
From: Jason Xing <kerneljasonxing@gmail.com>
Date: Tue, 30 Jul 2024 21:35:12 +0800
> From: Jason Xing <kernelxing@tencent.com>
> 
> Only when user sets TCP_USER_TIMEOUT option and there is no left
> chance to proceed, we will send an RST to the other side.
> 
> Signed-off-by: Jason Xing <kernelxing@tencent.com>
> ---
>  include/net/rstreason.h | 7 +++++++
>  net/ipv4/tcp_timer.c    | 2 +-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/rstreason.h b/include/net/rstreason.h
> index fecaa57f1634..ca10aaebd768 100644
> --- a/include/net/rstreason.h
> +++ b/include/net/rstreason.h
> @@ -21,6 +21,7 @@
>  	FN(TCP_ABORT_ON_LINGER)		\
>  	FN(TCP_ABORT_ON_MEMORY)		\
>  	FN(TCP_STATE)			\
> +	FN(TCP_TIMEOUT)			\
>  	FN(MPTCP_RST_EUNSPEC)		\
>  	FN(MPTCP_RST_EMPTCP)		\
>  	FN(MPTCP_RST_ERESOURCE)		\
> @@ -108,6 +109,12 @@ enum sk_rst_reason {
>  	 * Please see RFC 793 for all possible reset conditions
>  	 */
>  	SK_RST_REASON_TCP_STATE,
> +	/**
> +	 * @SK_RST_REASON_TCP_TIMEOUT: time to timeout
> +	 * When user sets TCP_USER_TIMEOUT options and run out of all the
> +	 * chance, we have to reset the connection
> +	 */
> +	SK_RST_REASON_TCP_TIMEOUT,

nit: Maybe SK_RST_REASON_TCP_USER_TIMEOUT ?

It's more user-friendly.
Jason Xing July 31, 2024, 12:09 a.m. UTC | #2
On Wed, Jul 31, 2024 at 4:00 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> From: Jason Xing <kerneljasonxing@gmail.com>
> Date: Tue, 30 Jul 2024 21:35:12 +0800
> > From: Jason Xing <kernelxing@tencent.com>
> >
> > Only when user sets TCP_USER_TIMEOUT option and there is no left
> > chance to proceed, we will send an RST to the other side.
> >
> > Signed-off-by: Jason Xing <kernelxing@tencent.com>
> > ---
> >  include/net/rstreason.h | 7 +++++++
> >  net/ipv4/tcp_timer.c    | 2 +-
> >  2 files changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/net/rstreason.h b/include/net/rstreason.h
> > index fecaa57f1634..ca10aaebd768 100644
> > --- a/include/net/rstreason.h
> > +++ b/include/net/rstreason.h
> > @@ -21,6 +21,7 @@
> >       FN(TCP_ABORT_ON_LINGER)         \
> >       FN(TCP_ABORT_ON_MEMORY)         \
> >       FN(TCP_STATE)                   \
> > +     FN(TCP_TIMEOUT)                 \
> >       FN(MPTCP_RST_EUNSPEC)           \
> >       FN(MPTCP_RST_EMPTCP)            \
> >       FN(MPTCP_RST_ERESOURCE)         \
> > @@ -108,6 +109,12 @@ enum sk_rst_reason {
> >        * Please see RFC 793 for all possible reset conditions
> >        */
> >       SK_RST_REASON_TCP_STATE,
> > +     /**
> > +      * @SK_RST_REASON_TCP_TIMEOUT: time to timeout
> > +      * When user sets TCP_USER_TIMEOUT options and run out of all the
> > +      * chance, we have to reset the connection
> > +      */
> > +     SK_RST_REASON_TCP_TIMEOUT,
>
> nit: Maybe SK_RST_REASON_TCP_USER_TIMEOUT ?
>
> It's more user-friendly.

Oh, after you reminding me, I double-check this part and find this
changelog is not that right because there is the other case where user
doesn't set TCP_USER_TIMEOUT option:
"user_timeout == 0 && icsk->icsk_probes_out >= keepalive_probes(tp)"
in tcp_keepalive_timer().

I will correct my comment as well.

I think I can keep SK_RST_REASON_TCP_STATE instead of
SK_RST_REASON_TCP_USER_TIMEOUT to show "we already try as many times
as we can whether TCP_USER_TIMEOUT option is set or not, but we have
to reset".

Thanks,
Jason
diff mbox series

Patch

diff --git a/include/net/rstreason.h b/include/net/rstreason.h
index fecaa57f1634..ca10aaebd768 100644
--- a/include/net/rstreason.h
+++ b/include/net/rstreason.h
@@ -21,6 +21,7 @@ 
 	FN(TCP_ABORT_ON_LINGER)		\
 	FN(TCP_ABORT_ON_MEMORY)		\
 	FN(TCP_STATE)			\
+	FN(TCP_TIMEOUT)			\
 	FN(MPTCP_RST_EUNSPEC)		\
 	FN(MPTCP_RST_EMPTCP)		\
 	FN(MPTCP_RST_ERESOURCE)		\
@@ -108,6 +109,12 @@  enum sk_rst_reason {
 	 * Please see RFC 793 for all possible reset conditions
 	 */
 	SK_RST_REASON_TCP_STATE,
+	/**
+	 * @SK_RST_REASON_TCP_TIMEOUT: time to timeout
+	 * When user sets TCP_USER_TIMEOUT options and run out of all the
+	 * chance, we have to reset the connection
+	 */
+	SK_RST_REASON_TCP_TIMEOUT,
 
 	/* Copy from include/uapi/linux/mptcp.h.
 	 * These reset fields will not be changed since they adhere to
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 3910f6d8614e..bd403300e4c4 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -807,7 +807,7 @@  static void tcp_keepalive_timer (struct timer_list *t)
 		    (user_timeout == 0 &&
 		    icsk->icsk_probes_out >= keepalive_probes(tp))) {
 			tcp_send_active_reset(sk, GFP_ATOMIC,
-					      SK_RST_REASON_NOT_SPECIFIED);
+					      SK_RST_REASON_TCP_TIMEOUT);
 			tcp_write_err(sk);
 			goto out;
 		}