[Devel] [PATCH hci-8.2 v2 13/15] ms/tcp: initialize send sequence numbers before deferring TFO
Eva Kurchatova
eva.kurchatova at virtuozzo.com
Tue Dec 1 15:10:28 MSK 2026
From: Qingfang Deng <qingfang.deng at linux.dev>
[ Upstream commit 57889a8f6d49fc153aa0017d13086ab736567f8a ]
TCP_FASTOPEN_CONNECT can return from connect() before tcp_connect_init()
when a cached cookie or cookieless Fast Open allows deferring the SYN.
At this point write_seq contains the initial sequence number, while
snd_una and snd_nxt have not been initialized to that sequence number.
Consequently, inet_diag and /proc/net/tcp{,6} report the initial
sequence number as the send queue length despite no SYN or payload being
queued.
Initialize snd_una and snd_nxt to write_seq before marking the
connection as deferred. Both sequence-based queue lengths then remain
zero until the first write starts the connection and runs
tcp_connect_init().
Fixes: 19f6d3f3c842 ("net/tcp-fastopen: Add new API support")
Signed-off-by: Qingfang Deng <qingfang.deng at linux.dev>
Reviewed-by: Eric Dumazet <edumazet at kernel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu at google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu at google.com>
Reviewed-by: Neal Cardwell <ncardwell at google.com>
Link: https://patch.msgid.link/20261102035943.9700-1-qingfang.deng@linux.dev
Signed-off-by: Paolo Abeni <pabeni at redhat.com>
Signed-off-by: Sasha Levin <sashal at kernel.org>
(cherry picked from commit 916558a87f1bd163562cad85af1e75f088306abf)
https://virtuozzo.atlassian.net/browse/VSTOR-158164
Feature: fix ms/net
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
---
net/ipv4/tcp_fastopen.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index 9178d5ef1a78..79ccd3bbc20b 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -456,6 +456,8 @@ bool tcp_fastopen_defer_connect(struct sock *sk, int *err)
if (tp->fastopen_connect && !tp->fastopen_req) {
if (tcp_fastopen_cookie_check(sk, &mss, &cookie)) {
+ WRITE_ONCE(tp->snd_una, tp->write_seq);
+ WRITE_ONCE(tp->snd_nxt, tp->write_seq);
inet_set_bit(DEFER_CONNECT, sk);
return true;
}
--
2.56.1
More information about the Devel
mailing list