diff mbox series

[RESEND,2/2] TCP: pass accepted-TFO indication through getsockopt

Message ID 20250416091538.7902-1-jgh@exim.org (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series TCP: Fast-Open observability | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next, async
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: 21 this patch: 21
netdev/build_tools success Errors and warnings before: 26 (+2) this patch: 26 (+2)
netdev/cc_maintainers warning 5 maintainers not CCed: dsahern@kernel.org kuba@kernel.org pabeni@redhat.com horms@kernel.org kuniyu@amazon.com
netdev/build_clang success Errors and warnings before: 35 this patch: 35
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: 2058 this patch: 2058
netdev/checkpatch warning WARNING: Missing commit description - Add an appropriate one
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-04-18--09-00 (tests: 916)

Commit Message

Jeremy Harris April 16, 2025, 9:15 a.m. UTC
Signed-off-by: Jeremy Harris <jgh@exim.org>
---
 include/uapi/linux/tcp.h | 1 +
 net/ipv4/tcp.c           | 2 ++
 2 files changed, 3 insertions(+)

Comments

Kuniyuki Iwashima April 16, 2025, 7:26 p.m. UTC | #1
From: Jeremy Harris <jgh@exim.org>
Date: Wed, 16 Apr 2025 10:15:38 +0100
> Signed-off-by: Jeremy Harris <jgh@exim.org>
> ---
>  include/uapi/linux/tcp.h | 1 +
>  net/ipv4/tcp.c           | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
> index dc8fdc80e16b..ae8c5a8af0e5 100644
> --- a/include/uapi/linux/tcp.h
> +++ b/include/uapi/linux/tcp.h
> @@ -184,6 +184,7 @@ enum tcp_fastopen_client_fail {
>  #define TCPI_OPT_ECN_SEEN	16 /* we received at least one packet with ECT */
>  #define TCPI_OPT_SYN_DATA	32 /* SYN-ACK acked data in SYN sent or rcvd */
>  #define TCPI_OPT_USEC_TS	64 /* usec timestamps */
> +#define TCPI_OPT_TFO_SEEN	128 /* we accepted a Fast Open option on SYN */

This is the last bit of tcpi_options.

We can add another field at the end of the struct if necessary in
the future, but from the cover letter and commit message, I didn't
get why this info is needed at per-socket granurality.

Also, This can be retrieved with BPF.


>  
>  /*
>   * Sender's congestion state indicating normal or abnormal situations
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index e0e96f8fd47c..b45eb7cb2909 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -4164,6 +4164,8 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
>  		info->tcpi_options |= TCPI_OPT_SYN_DATA;
>  	if (tp->tcp_usec_ts)
>  		info->tcpi_options |= TCPI_OPT_USEC_TS;
> +	if (tp->syn_fastopen_in)
> +		info->tcpi_options |= TCPI_OPT_TFO_SEEN;
>  
>  	info->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto);
>  	info->tcpi_ato = jiffies_to_usecs(min_t(u32, icsk->icsk_ack.ato,
> -- 
> 2.49.0
Jeremy Harris April 17, 2025, 10:26 a.m. UTC | #2
On 2025/04/16 8:26 PM, Kuniyuki Iwashima wrote:
>> +#define TCPI_OPT_TFO_SEEN	128 /* we accepted a Fast Open option on SYN */
> 
> This is the last bit of tcpi_options.
> 
> We can add another field at the end of the struct if necessary in
> the future, but from the cover letter and commit message, I didn't
> get why this info is needed at per-socket granurality.

An application is operating at socket granularity.  The provision is
so that an application can tell what is going on with each one of
its comms channels independently, rather than (for instance) the
rolled-up information on the entire system that the existing
statistics counter offers.

> Also, This can be retrieved with BPF.

If I understand correctly, BPF is aimed at sysadminss probing
or modifying system operations rather than production use by
an application.  While your point is true, I don't think BPF
is a good fit.
diff mbox series

Patch

diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index dc8fdc80e16b..ae8c5a8af0e5 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -184,6 +184,7 @@  enum tcp_fastopen_client_fail {
 #define TCPI_OPT_ECN_SEEN	16 /* we received at least one packet with ECT */
 #define TCPI_OPT_SYN_DATA	32 /* SYN-ACK acked data in SYN sent or rcvd */
 #define TCPI_OPT_USEC_TS	64 /* usec timestamps */
+#define TCPI_OPT_TFO_SEEN	128 /* we accepted a Fast Open option on SYN */
 
 /*
  * Sender's congestion state indicating normal or abnormal situations
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e0e96f8fd47c..b45eb7cb2909 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -4164,6 +4164,8 @@  void tcp_get_info(struct sock *sk, struct tcp_info *info)
 		info->tcpi_options |= TCPI_OPT_SYN_DATA;
 	if (tp->tcp_usec_ts)
 		info->tcpi_options |= TCPI_OPT_USEC_TS;
+	if (tp->syn_fastopen_in)
+		info->tcpi_options |= TCPI_OPT_TFO_SEEN;
 
 	info->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto);
 	info->tcpi_ato = jiffies_to_usecs(min_t(u32, icsk->icsk_ack.ato,