Skip to contentSkip to conversation

TCP: Fast-Open observability

RFC PATCH Superseded Jeremy Harris 1 participant 3 messages Mar 13, 2025

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

cover TCP: Fast-Open observability

Whether TCP Fast Open was used, or not, for a connection is not reliably observable by an accepting application.

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

Jeremy Harris (2):
TCP: note received valid-cookie Fast Open option
TCP: pass accepted-TFO indication through getsockopt

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

base-commit: 5a1dddd2944492edb1e61c5db1cc386e5419fcf4

Signature · 1 line
2.48.1
#1 lore raw

RFC PATCH 1/2 TCP: note received valid-cookie Fast Open option

---
 include/linux/tcp.h     | 3 ++-
 net/ipv4/tcp_fastopen.c | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
include/linux/tcp.h +2 -1
index 159b2c59e..c32c8ba59 100644
@@ -382,7 +382,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_in:1; /* Received SYN includes Fast Open option */
 
 	u8	keepalive_probes; /* num of allowed keep alive probes	*/
 	u32	tcp_tx_delay;	/* delay (in usec) added to TX packets */
net/ipv4/tcp_fastopen.c +1 -0
index 1a6b1bc54..004d0024c 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_in = 1;
 				return child;
 			}
 			NET_INC_STATS(sock_net(sk),
Signature · 1 line
2.48.1
#2 lore raw

RFC PATCH 2/2 TCP: pass accepted-TFO indication through getsockopt

In reply to Jeremy Harris
---
 include/uapi/linux/tcp.h | 1 +
 net/ipv4/tcp.c           | 2 ++
 2 files changed, 3 insertions(+)
include/uapi/linux/tcp.h +1 -0
index 32a27b4a5..e958a145d 100644
@@ -179,6 +179,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
net/ipv4/tcp.c +2 -0
index 46951e749..407bdfb12 100644
@@ -4146,6 +4146,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,
Signature · 1 line
2.48.1