* [PATCH net] tcp: fix TFO max_qlen accounting across reuseport migration
@ 2026-08-03 6:17 Jiayuan Chen
2026-08-05 5:15 ` Kuniyuki Iwashima
2026-08-06 0:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Jiayuan Chen @ 2026-08-03 6:17 UTC (permalink / raw)
To: netdev
Cc: Jiayuan Chen, Eric Dumazet, Neal Cardwell, Kuniyuki Iwashima,
David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Martin KaFai Lau, Daniel Borkmann, linux-kernel
A listener's TCP_FASTOPEN max_qlen stops being accurate and lets through
far more pending Fast Open requests than it was configured for.
This only shows up with SO_REUSEPORT listener migration, where closing a
listener hands its still-pending TFO children over to a surviving one.
fastopenq.qlen is charged in tcp_fastopen_create_child() when the child
is created and uncharged in reqsk_fastopen_remove() when the handshake
completes. The uncharge follows rsk_listener of the request the child
points at, and inet_reqsk_clone() has repointed the child at a new
request owned by the new listener, so the ++ and the -- land on two
different sockets. The new listener's qlen drifts negative and its
limit no longer binds.
Charge the new listener during migration, like reqsk_queue_migrated()
already does for queue->young and queue->qlen.
Fixes: 54b92e841937 ("tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.")
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
fastopenq.qlen is read without the lock in tcp_fastopen_queue_check() and
has been since long before this patch, but as this is meant to be
backported I left the READ_ONCE()/WRITE_ONCE() conversion to a separate
patch.
---
net/ipv4/inet_connection_sock.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 56902bba5483..6257459bcee2 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -943,11 +943,23 @@ static struct request_sock *inet_reqsk_clone(struct request_sock *req,
nreq->rsk_listener = sk;
- /* We need not acquire fastopenq->lock
- * because the child socket is locked in inet_csk_listen_stop().
- */
- if (sk->sk_protocol == IPPROTO_TCP && tcp_rsk(nreq)->tfo_listener)
+ if (sk->sk_protocol == IPPROTO_TCP && tcp_rsk(nreq)->tfo_listener) {
+ struct fastopen_queue *fastopenq;
+
+ /* reqsk_fastopen_remove() will uncharge nreq->rsk_listener,
+ * that is @sk, so charge it here. Unlike the listener
+ * being closed, @sk is live and needs its lock.
+ */
+ fastopenq = &inet_csk(sk)->icsk_accept_queue.fastopenq;
+ spin_lock_bh(&fastopenq->lock);
+ fastopenq->qlen++;
+ spin_unlock_bh(&fastopenq->lock);
+
+ /* We need not acquire fastopenq->lock
+ * because the child socket is locked in inet_csk_listen_stop().
+ */
rcu_assign_pointer(tcp_sk(nreq->sk)->fastopen_rsk, nreq);
+ }
return nreq;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] tcp: fix TFO max_qlen accounting across reuseport migration
2026-08-03 6:17 [PATCH net] tcp: fix TFO max_qlen accounting across reuseport migration Jiayuan Chen
@ 2026-08-05 5:15 ` Kuniyuki Iwashima
2026-08-05 13:16 ` Eric Dumazet
2026-08-06 0:20 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Kuniyuki Iwashima @ 2026-08-05 5:15 UTC (permalink / raw)
To: Jiayuan Chen
Cc: netdev, Eric Dumazet, Neal Cardwell, David S. Miller,
Jakub Kicinski, Paolo Abeni, Simon Horman, Martin KaFai Lau,
Daniel Borkmann, linux-kernel
On Sun, Aug 2, 2026 at 11:18 PM Jiayuan Chen <jiayuan.chen@linux.dev> wrote:
>
> A listener's TCP_FASTOPEN max_qlen stops being accurate and lets through
> far more pending Fast Open requests than it was configured for.
>
> This only shows up with SO_REUSEPORT listener migration, where closing a
> listener hands its still-pending TFO children over to a surviving one.
>
> fastopenq.qlen is charged in tcp_fastopen_create_child() when the child
> is created and uncharged in reqsk_fastopen_remove() when the handshake
> completes. The uncharge follows rsk_listener of the request the child
> points at, and inet_reqsk_clone() has repointed the child at a new
> request owned by the new listener, so the ++ and the -- land on two
> different sockets. The new listener's qlen drifts negative and its
> limit no longer binds.
>
> Charge the new listener during migration, like reqsk_queue_migrated()
> already does for queue->young and queue->qlen.
>
> Fixes: 54b92e841937 ("tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.")
> Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] tcp: fix TFO max_qlen accounting across reuseport migration
2026-08-05 5:15 ` Kuniyuki Iwashima
@ 2026-08-05 13:16 ` Eric Dumazet
0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-08-05 13:16 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: Jiayuan Chen, netdev, Neal Cardwell, David S. Miller,
Jakub Kicinski, Paolo Abeni, Simon Horman, Martin KaFai Lau,
Daniel Borkmann, linux-kernel
On Wed, Aug 5, 2026 at 7:15 AM Kuniyuki Iwashima <kuniyu@google.com> wrote:
>
> On Sun, Aug 2, 2026 at 11:18 PM Jiayuan Chen <jiayuan.chen@linux.dev> wrote:
> >
> > A listener's TCP_FASTOPEN max_qlen stops being accurate and lets through
> > far more pending Fast Open requests than it was configured for.
> >
> > This only shows up with SO_REUSEPORT listener migration, where closing a
> > listener hands its still-pending TFO children over to a surviving one.
> >
> > fastopenq.qlen is charged in tcp_fastopen_create_child() when the child
> > is created and uncharged in reqsk_fastopen_remove() when the handshake
> > completes. The uncharge follows rsk_listener of the request the child
> > points at, and inet_reqsk_clone() has repointed the child at a new
> > request owned by the new listener, so the ++ and the -- land on two
> > different sockets. The new listener's qlen drifts negative and its
> > limit no longer binds.
> >
> > Charge the new listener during migration, like reqsk_queue_migrated()
> > already does for queue->young and queue->qlen.
> >
> > Fixes: 54b92e841937 ("tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.")
> > Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
>
> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] tcp: fix TFO max_qlen accounting across reuseport migration
2026-08-03 6:17 [PATCH net] tcp: fix TFO max_qlen accounting across reuseport migration Jiayuan Chen
2026-08-05 5:15 ` Kuniyuki Iwashima
@ 2026-08-06 0:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-08-06 0:20 UTC (permalink / raw)
To: Jiayuan Chen
Cc: netdev, edumazet, ncardwell, kuniyu, davem, kuba, pabeni, horms,
kafai, daniel, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 3 Aug 2026 14:17:38 +0800 you wrote:
> A listener's TCP_FASTOPEN max_qlen stops being accurate and lets through
> far more pending Fast Open requests than it was configured for.
>
> This only shows up with SO_REUSEPORT listener migration, where closing a
> listener hands its still-pending TFO children over to a surviving one.
>
> fastopenq.qlen is charged in tcp_fastopen_create_child() when the child
> is created and uncharged in reqsk_fastopen_remove() when the handshake
> completes. The uncharge follows rsk_listener of the request the child
> points at, and inet_reqsk_clone() has repointed the child at a new
> request owned by the new listener, so the ++ and the -- land on two
> different sockets. The new listener's qlen drifts negative and its
> limit no longer binds.
>
> [...]
Here is the summary with links:
- [net] tcp: fix TFO max_qlen accounting across reuseport migration
https://git.kernel.org/netdev/net/c/a0ab2ba83e35
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-06 0:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-03 6:17 [PATCH net] tcp: fix TFO max_qlen accounting across reuseport migration Jiayuan Chen
2026-08-05 5:15 ` Kuniyuki Iwashima
2026-08-05 13:16 ` Eric Dumazet
2026-08-06 0:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox