* Re: [PATCH v1 net] tcp: Skip active TFO blackhole detection for passive sockets.
2026-12-01 10:40 [PATCH v1 net] tcp: Skip active TFO blackhole detection for passive sockets Kuniyuki Iwashima
@ 2026-12-01 12:24 ` Jiayuan Chen
2026-12-01 17:28 ` Yuchung Cheng
2026-12-02 22:42 ` netdev-bot+sashiko
2 siblings, 0 replies; 4+ messages in thread
From: Jiayuan Chen @ 2026-12-01 12:24 UTC (permalink / raw)
To: Kuniyuki Iwashima, Eric Dumazet, Neal Cardwell, David S. Miller,
Jakub Kicinski, Paolo Abeni, Willem de Bruijn
Cc: Simon Horman, Yuchung Cheng, Kuniyuki Iwashima, netdev
On 12/1/26 6:40 PM, Kuniyuki Iwashima wrote:
> tcp_fastopen_active_detect_blackhole() checks tp->syn_fastopen,
> tp->syn_data, and tp->syn_data_acked to pause active Fast Open
> globally when an outbound TFO connection hits consecutive timeouts.
>
> However, tcp_fastopen_add_skb() also sets tp->syn_data_acked
> to 1 on passive child sockets when accepting data in SYN.
>
> When such a passive socket later hits consecutive RTOs,
> tcp_fastopen_active_detect_blackhole() misidentifies it as an
> active client socket and calls tcp_fastopen_active_disable(),
> disabling active TFO for the entire netns.
>
> This can be reproduced with the script below:
>
> 0 `sysctl -q net.ipv4.tcp_fastopen=0x203 \
> net.ipv4.tcp_fastopen_blackhole_timeout_sec=3600 \
> net.ipv4.tcp_early_retrans=0`
> +0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3
> +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
> +0 bind(3, ..., ...) = 0
> +0 listen(3, 1) = 0
> +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0
> +0 < S 0:1000(1000) win 32792 <mss 1460,sackOK,nop,nop>
> +0 > S. 0:0(0) ack 1001 <...>
> +0 accept(3, ..., ...) = 4
> +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) != 0, tcpi_options }%
> +0 read(4, ..., 1024) = 1000
> +0 < . 1001:1001(0) ack 1 win 5840
> +0 write(4, ..., 1000) = 1000
> +0 > P. 1:1001(1000) ack 1001
> +.2 > P. 1:1001(1000) ack 1001
> +.4 > P. 1:1001(1000) ack 1001
> +.8 > P. 1:1001(1000) ack 1001
> +0 `nstat -z -a TcpExtTCPFastOpenBlackhole TcpExtTCPFastOpenActiveFail \
> | grep -E "TcpExtTCPFastOpen(Blackhole|ActiveFail)\s+1"`
>
> Without the fix, the last nstat shows these incremented by
> a passive TFO sk:
>
> TcpExtTCPFastOpenActiveFail 1 0.0
> TcpExtTCPFastOpenBlackhole 1 0.0
>
> Let's skip passive TFO sk in tcp_fastopen_active_detect_blackhole().
>
> Note that tcp_rcv_fastopen_synack() sets tp->syn_data_acked to
> tp->syn_data so there is no path where only tp->syn_data_acked
> is set to 1 on the active side.
>
> We could check tp->syn_fastopen_child and return early but removing
> tp->syn_data_acked check is stable-friendly.
>
> Fixes: 7268586baa53 ("tcp: pause Fast Open globally after third consecutive timeout")
tp->syn_data_acked was already used in tcp_write_timeout before this commit.
But I think it's ok for backport. We do not backport 4.x anymore.
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
> ---
> Found by LLM with packetdrill
> ---
> net/ipv4/tcp_fastopen.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
> index 7f7eb3cc1c04..61e57f21e4e4 100644
> --- a/net/ipv4/tcp_fastopen.c
> +++ b/net/ipv4/tcp_fastopen.c
> @@ -685,7 +685,7 @@ void tcp_fastopen_active_detect_blackhole(struct sock *sk, bool expired)
> * Fast Open globally after hitting the third consecutive timeout or
> * exceeding the configured timeout limit.
> */
> - if ((tp->syn_fastopen || tp->syn_data || tp->syn_data_acked) &&
> + if ((tp->syn_fastopen || tp->syn_data) &&
> (timeouts == 2 || (timeouts < 2 && expired))) {
> tcp_fastopen_active_disable(sk);
> NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPFASTOPENACTIVEFAIL);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v1 net] tcp: Skip active TFO blackhole detection for passive sockets.
2026-12-01 10:40 [PATCH v1 net] tcp: Skip active TFO blackhole detection for passive sockets Kuniyuki Iwashima
2026-12-01 12:24 ` Jiayuan Chen
@ 2026-12-01 17:28 ` Yuchung Cheng
2026-12-02 22:42 ` netdev-bot+sashiko
2 siblings, 0 replies; 4+ messages in thread
From: Yuchung Cheng @ 2026-12-01 17:28 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: Eric Dumazet, Neal Cardwell, David S. Miller, Jakub Kicinski,
Paolo Abeni, Willem de Bruijn, Simon Horman, Kuniyuki Iwashima,
netdev
On Tue, Dec 1, 2026 at 2:40 AM Kuniyuki Iwashima <kuniyu@google.com> wrote:
>
> tcp_fastopen_active_detect_blackhole() checks tp->syn_fastopen,
> tp->syn_data, and tp->syn_data_acked to pause active Fast Open
> globally when an outbound TFO connection hits consecutive timeouts.
>
> However, tcp_fastopen_add_skb() also sets tp->syn_data_acked
> to 1 on passive child sockets when accepting data in SYN.
>
> When such a passive socket later hits consecutive RTOs,
> tcp_fastopen_active_detect_blackhole() misidentifies it as an
> active client socket and calls tcp_fastopen_active_disable(),
> disabling active TFO for the entire netns.
>
> This can be reproduced with the script below:
>
> 0 `sysctl -q net.ipv4.tcp_fastopen=0x203 \
> net.ipv4.tcp_fastopen_blackhole_timeout_sec=3600 \
> net.ipv4.tcp_early_retrans=0`
> +0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3
> +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
> +0 bind(3, ..., ...) = 0
> +0 listen(3, 1) = 0
> +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0
> +0 < S 0:1000(1000) win 32792 <mss 1460,sackOK,nop,nop>
> +0 > S. 0:0(0) ack 1001 <...>
> +0 accept(3, ..., ...) = 4
> +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) != 0, tcpi_options }%
> +0 read(4, ..., 1024) = 1000
> +0 < . 1001:1001(0) ack 1 win 5840
> +0 write(4, ..., 1000) = 1000
> +0 > P. 1:1001(1000) ack 1001
> +.2 > P. 1:1001(1000) ack 1001
> +.4 > P. 1:1001(1000) ack 1001
> +.8 > P. 1:1001(1000) ack 1001
> +0 `nstat -z -a TcpExtTCPFastOpenBlackhole TcpExtTCPFastOpenActiveFail \
> | grep -E "TcpExtTCPFastOpen(Blackhole|ActiveFail)\s+1"`
>
> Without the fix, the last nstat shows these incremented by
> a passive TFO sk:
>
> TcpExtTCPFastOpenActiveFail 1 0.0
> TcpExtTCPFastOpenBlackhole 1 0.0
>
> Let's skip passive TFO sk in tcp_fastopen_active_detect_blackhole().
>
> Note that tcp_rcv_fastopen_synack() sets tp->syn_data_acked to
> tp->syn_data so there is no path where only tp->syn_data_acked
> is set to 1 on the active side.
>
> We could check tp->syn_fastopen_child and return early but removing
> tp->syn_data_acked check is stable-friendly.
>
> Fixes: 7268586baa53 ("tcp: pause Fast Open globally after third consecutive timeout")
> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Great catch!
> ---
> Found by LLM with packetdrill
> ---
> net/ipv4/tcp_fastopen.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
> index 7f7eb3cc1c04..61e57f21e4e4 100644
> --- a/net/ipv4/tcp_fastopen.c
> +++ b/net/ipv4/tcp_fastopen.c
> @@ -685,7 +685,7 @@ void tcp_fastopen_active_detect_blackhole(struct sock *sk, bool expired)
> * Fast Open globally after hitting the third consecutive timeout or
> * exceeding the configured timeout limit.
> */
> - if ((tp->syn_fastopen || tp->syn_data || tp->syn_data_acked) &&
> + if ((tp->syn_fastopen || tp->syn_data) &&
> (timeouts == 2 || (timeouts < 2 && expired))) {
> tcp_fastopen_active_disable(sk);
> NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPFASTOPENACTIVEFAIL);
> --
> 2.56.1.839.g22a8290db9-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v1 net] tcp: Skip active TFO blackhole detection for passive sockets.
2026-12-01 10:40 [PATCH v1 net] tcp: Skip active TFO blackhole detection for passive sockets Kuniyuki Iwashima
2026-12-01 12:24 ` Jiayuan Chen
2026-12-01 17:28 ` Yuchung Cheng
@ 2026-12-02 22:42 ` netdev-bot+sashiko
2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-12-02 22:42 UTC (permalink / raw)
To: kuniyu
Cc: edumazet, ncardwell, davem, kuba, pabeni, willemb, horms, ycheng,
kuni1840, netdev
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch only partly achieves what its subject says, "Skip
active TFO blackhole detection for passive sockets".
--
tcp: Skip active TFO blackhole detection for passive sockets.
This patch removes the tp->syn_data_acked term from the check in
tcp_fastopen_active_detect_blackhole(). tcp_fastopen_add_skb() sets that
bit on passive TFO children, so consecutive RTOs on a passive socket
could pause active TFO for the whole netns.
> diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
> index 7f7eb3cc1c04c..61e57f21e4e41 100644
> --- a/net/ipv4/tcp_fastopen.c
> +++ b/net/ipv4/tcp_fastopen.c
> @@ -685,7 +685,7 @@ void tcp_fastopen_active_detect_blackhole(struct sock *sk, bool expired)
> * Fast Open globally after hitting the third consecutive timeout or
> * exceeding the configured timeout limit.
> */
> - if ((tp->syn_fastopen || tp->syn_data || tp->syn_data_acked) &&
> + if ((tp->syn_fastopen || tp->syn_data) &&
> (timeouts == 2 || (timeouts < 2 && expired))) {
> tcp_fastopen_active_disable(sk);
> NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPFASTOPENACTIVEFAIL);
[Severity: Medium]
Can tp->syn_fastopen or tp->syn_data still be set on a passive socket
here?
The active side sets these bits in tcp_syn_options() and
tcp_send_syn_data(). The only place either one gets cleared is the
transmit error path in tcp_send_syn_data():
net/ipv4/tcp_output.c:tcp_send_syn_data() {
...
if (!err) {
tp->syn_data = (fo->copied > 0);
...
if (err)
tp->syn_fastopen = 0;
...
}
tcp_disconnect() only resets the other two bits:
net/ipv4/tcp.c:tcp_disconnect() {
...
tp->syn_data_acked = 0;
tp->syn_fastopen_child = 0;
...
}
Consider a socket that does an active TFO connect (MSG_FASTOPEN or
TCP_FASTOPEN_CONNECT), then connect(AF_UNSPEC), then listen().
__inet_stream_connect() calls tcp_disconnect() and moves the socket back
to SS_UNCONNECTED / TCP_CLOSE, so listen() is allowed. The new listener
still has syn_fastopen and syn_data set.
Every child of that listener gets a copy of those bits, because the
whole tcp_sock is copied:
tcp_create_openreq_child()
inet_csk_clone_lock()
sk_clone_lock()
sock_copy()
tcp_create_openreq_child() does not clear syn_fastopen or syn_data.
Suppose one of these children, TFO or not, hits its third consecutive
RTO:
tcp_write_timeout()
tcp_fastopen_active_detect_blackhole()
tcp_fastopen_active_disable()
In that case the check above still passes. Active TFO is then paused for
the whole netns when tcp_fastopen_blackhole_timeout_sec is non-zero, and
TCPFastOpenActiveFail is incremented either way. This is the symptom the
commit message describes.
A reused active socket that later reconnects without TFO keeps the same
stale bits, so it would be treated as a TFO connection in the same way.
The syn_fastopen_child early return mentioned in the commit message would
only cover the TFO children of such a listener. Would it make sense to
also clear syn_fastopen and syn_data in tcp_disconnect(), or on the child
in tcp_create_openreq_child()?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201104011.2286047-1-kuniyu%40google.com
^ permalink raw reply [flat|nested] 4+ messages in thread