Skip to contentSkip to conversation

tcp: fastopen: observability

PATCH Applied Jeremy Harris 4 participants 8 messages Apr 23, 2025 – Apr 25, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover tcp: fastopen: observability

Whether TCP Fast Open was used for a connection is not reliably observable by an accepting application when the SYN passed no data.

Fix this by noting during SYN receive processing that an acceptable Fast Open option was used, and provide this to userland via getsockopt TCP_INFO.

Jeremy Harris (2):
tcp: fastopen: note that a child socket was created
tcp: fastopen: pass TFO child indication through getsockopt

 include/linux/tcp.h      | 3 ++-
 include/uapi/linux/tcp.h | 1 +
 net/ipv4/tcp.c           | 3 +++
 net/ipv4/tcp_fastopen.c  | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)

base-commit: 0e0a7e3719bc8cbe6d6e30b3e81f21472ecba5bc

Signature · 1 line
2.49.0
#1 lore raw

PATCH v2 1/2 tcp: fastopen: note that a child socket was created

tcp: fastopen: note that a child socket was created

This uses up the last bit in a field of tcp_sock.

---
 include/linux/tcp.h     | 3 ++-
 net/ipv4/tcp.c          | 1 +
 net/ipv4/tcp_fastopen.c | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)
include/linux/tcp.h +2 -1
index 1669d95bb0f9..a8af71623ba7 100644
@@ -385,7 +385,8 @@ struct tcp_sock {
 		syn_fastopen:1,	/* SYN includes Fast Open option */
 		syn_fastopen_exp:1,/* SYN includes Fast Open exp. option */
 		syn_fastopen_ch:1, /* Active TFO re-enabling probe */
-		syn_data_acked:1;/* data in SYN is acked by SYN-ACK */
+		syn_data_acked:1,/* data in SYN is acked by SYN-ACK */
+		syn_fastopen_child:1; /* created TFO passive child socket */
 
 	u8	keepalive_probes; /* num of allowed keep alive probes	*/
 	u32	tcp_tx_delay;	/* delay (in usec) added to TX packets */
net/ipv4/tcp.c +1 -0
index e0e96f8fd47c..df3eb0fb7cb3 100644
@@ -3409,6 +3409,7 @@ int tcp_disconnect(struct sock *sk, int flags)
 	tp->rack.reo_wnd_persist = 0;
 	tp->rack.dsack_seen = 0;
 	tp->syn_data_acked = 0;
+	tp->syn_fastopen_child = 0;
 	tp->rx_opt.saw_tstamp = 0;
 	tp->rx_opt.dsack = 0;
 	tp->rx_opt.num_sacks = 0;
net/ipv4/tcp_fastopen.c +1 -0
index 1a6b1bc54245..9b83d639b5ac 100644
@@ -401,6 +401,7 @@ struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb,
 				}
 				NET_INC_STATS(sock_net(sk),
 					      LINUX_MIB_TCPFASTOPENPASSIVE);
+				tcp_sk(child)->syn_fastopen_child = 1;
 				return child;
 			}
 			NET_INC_STATS(sock_net(sk),
Signature · 1 line
2.49.0
#4 lore raw

PATCH v2 2/2 tcp: fastopen: pass TFO child indication through getsockopt

In reply to Jeremy Harris

tcp: fastopen: pass TFO child indication through getsockopt

Note that this uses up the last bit of a field in struct tcp_info

---
 include/uapi/linux/tcp.h | 1 +
 net/ipv4/tcp.c           | 2 ++
 2 files changed, 3 insertions(+)
include/uapi/linux/tcp.h +1 -0
index dc8fdc80e16b..bdac8c42fa82 100644
@@ -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_CHILD	128 /* child from a Fast Open option on SYN */
 
 /*
  * Sender's congestion state indicating normal or abnormal situations
net/ipv4/tcp.c +2 -0
index df3eb0fb7cb3..86c427f16636 100644
@@ -4165,6 +4165,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_child)
+		info->tcpi_options |= TCPI_OPT_TFO_CHILD;
 
 	info->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto);
 	info->tcpi_ato = jiffies_to_usecs(min_t(u32, icsk->icsk_ack.ato,
Signature · 1 line
2.49.0
#7 lore raw
In reply to Jeremy Harris
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Wed, 23 Apr 2025 13:43:32 +0100 you wrote:

Whether TCP Fast Open was used for a connection is not reliably observable by an accepting application when the SYN passed no data.

Fix this by noting during SYN receive processing that an acceptable Fast Open option was used, and provide this to userland via getsockopt TCP_INFO.

Jeremy Harris (2):
tcp: fastopen: note that a child socket was created
tcp: fastopen: pass TFO child indication through getsockopt

[...]

Here is the summary with links:
- [v2,1/2] tcp: fastopen: note that a child socket was created

    https://git.kernel.org/netdev/net-next/c/bc2550b4e195
  - [v2,2/2] tcp: fastopen: pass TFO child indication through getsockopt
    https://git.kernel.org/netdev/net-next/c/2b13042d3636

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html