Netdev List
 help / color / mirror / Atom feed
From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Kuniyuki Iwashima <kuniyu@google.com>,
	Eric Dumazet <edumazet@kernel.org>,
	Neal Cardwell <ncardwell@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>
Cc: Simon Horman <horms@kernel.org>,
	Yuchung Cheng <ycheng@google.com>,
	Kuniyuki Iwashima <kuni1840@gmail.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH v1 net] tcp: Skip active TFO blackhole detection for passive sockets.
Date: Tue, 1 Dec 2026 20:24:06 +0800	[thread overview]
Message-ID: <3ead136c-b984-4558-8ee0-4ad6143fca8a@linux.dev> (raw)
In-Reply-To: <20261201104011.2286047-1-kuniyu@google.com>



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);


      reply	other threads:[~2026-12-01 12:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ead136c-b984-4558-8ee0-4ad6143fca8a@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=kuniyu@google.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    --cc=ycheng@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox