mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing
@ 2026-11-08 14:39 Yongjian Wang via B4 Relay
  2026-11-08 14:39 ` [PATCH net-next v2 1/4] tcp: initialize MTU probing before syncing MSS at connection setup Yongjian Wang via B4 Relay
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Yongjian Wang via B4 Relay @ 2026-11-08 14:39 UTC (permalink / raw)
  To: davem, pabeni, ncardwell, horms, kuba, kuniyu, shuah, edumazet
  Cc: linux-kselftest, linux-kernel, panweiping3, netdev, Yongjian Wang

With tcp_mtu_probing=2, passive TCP connections can start at the full
MSS because they sync MSS before initializing MTU probing. Patch 1
moves initialization next to the existing MSS sync in the passive
paths and in the active SYN-ACK path. Patch 2 adds a regression test.

Patches 3 and 4 add coverage for black hole detection and the MTU
search on active connections.

Tested on x86_64 KVM with all 496 packetdrill cases passing, plus
targeted checks for simultaneous open and Fast Open with MTU probing
enabled. The three affected TCP objects also build with W=1 under
allyesconfig and allmodconfig.

---
Changes in v2:
- Move tcp_mtup_init() before the existing MSS sync in IPv4 and IPv6
  passive opens and in the active SYN-ACK path. Remove the late
  initialization from tcp_init_transfer() (Kuniyuki and Neal).
- Keep the three packetdrill patches unchanged.
- Link to v1: https://lore.kernel.org/netdev/20261103-mtu-probing-series-v1-0-a2809e725aaa@gmail.com/

---
Yongjian Wang (4):
      tcp: initialize MTU probing before syncing MSS at connection setup
      selftests/net: packetdrill: test tcp_base_mss on passive connections
      selftests/net: packetdrill: add TCP black hole detection test
      selftests/net: packetdrill: add TCP MTU probing test

 net/ipv4/tcp_input.c                               |  2 +-
 net/ipv4/tcp_ipv4.c                                |  1 +
 net/ipv6/tcp_ipv6.c                                |  1 +
 .../net/packetdrill/tcp_mtu_probing_blackhole.pkt  | 37 +++++++++++++++++++
 .../net/packetdrill/tcp_mtu_probing_passive.pkt    | 27 ++++++++++++++
 .../net/packetdrill/tcp_mtu_probing_search.pkt     | 43 ++++++++++++++++++++++
 6 files changed, 110 insertions(+), 1 deletion(-)
---
base-commit: fa5196392691051963726787944db872420dfa75
change-id: 20261103-mtu-probing-series-a87b39fdbedf

Best regards,
--  
Yongjian Wang <echoowall@gmail.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v2 1/4] tcp: initialize MTU probing before syncing MSS at connection setup
  2026-11-08 14:39 [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing Yongjian Wang via B4 Relay
@ 2026-11-08 14:39 ` Yongjian Wang via B4 Relay
  2026-11-08 14:39 ` [PATCH net-next v2 2/4] selftests/net: packetdrill: test tcp_base_mss on passive connections Yongjian Wang via B4 Relay
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Yongjian Wang via B4 Relay @ 2026-11-08 14:39 UTC (permalink / raw)
  To: davem, pabeni, ncardwell, horms, kuba, kuniyu, shuah, edumazet
  Cc: linux-kselftest, linux-kernel, panweiping3, netdev, Yongjian Wang

From: Yongjian Wang <echoowall@gmail.com>

With tcp_mtu_probing=2, a passive connection starts at the full MSS
rather than tcp_base_mss. The IPv4 and IPv6 syn_recv_sock() paths
call tcp_sync_mss() before tcp_init_transfer() enables MTU probing.
With tcp_base_mss=1024, the first successful probe can therefore lower
the MSS from 1460 to 1242. On a black hole path, the first reduction
skips 1024 and goes straight to 512.

Commit 4d83e1773031 ("tcp: delete redundant calls of tcp_mtup_init()")
removed tcp_mtup_init() from the passive setup paths.
Commit 27204aaa9dc6
("tcp: uniform the set up of sockets after successful connection")
later moved MTU probing initialization into tcp_init_transfer(),
away from tcp_sync_mss().

Initialize MTU probing immediately before the existing tcp_sync_mss()
calls in the IPv4 and IPv6 passive setup paths and when processing
a SYN-ACK for an active connection. Remove the late initialization
from tcp_init_transfer(). This lets tcp_sync_mss() apply tcp_base_mss
without adding another MSS calculation to connection setup. The
crossed-SYN path already uses this order.

Fixes: 4d83e1773031 ("tcp: delete redundant calls of tcp_mtup_init()")
Suggested-by: Kuniyuki Iwashima <kuniyu@google.com>
Suggested-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Yongjian Wang <echoowall@gmail.com>
---
 net/ipv4/tcp_input.c | 2 +-
 net/ipv4/tcp_ipv4.c  | 1 +
 net/ipv6/tcp_ipv6.c  | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 3fd0e2153..2b54b99f1 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6763,7 +6763,6 @@ void tcp_init_transfer(struct sock *sk, int bpf_op, struct sk_buff *skb)
 	struct inet_connection_sock *icsk = inet_csk(sk);
 	struct tcp_sock *tp = tcp_sk(sk);
 
-	tcp_mtup_init(sk);
 	icsk->icsk_af_ops->rebuild_header(sk);
 	tcp_init_metrics(sk);
 
@@ -7020,6 +7019,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
 			tp->tcp_header_len = sizeof(struct tcphdr);
 		}
 
+		tcp_mtup_init(sk);
 		tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
 		tcp_initialize_rcv_mss(sk);
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 0dc3b0876..fb968798b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1740,6 +1740,7 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
 
 	tcp_ca_openreq_child(newsk, dst);
 
+	tcp_mtup_init(newsk);
 	tcp_sync_mss(newsk, dst4_mtu(dst));
 	newtp->advmss = tcp_mss_clamp(tcp_sk(sk), tcp_dst_advmss(dst));
 
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index b1dec5d86..8ea1ae1ad 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1490,6 +1490,7 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *
 
 	tcp_ca_openreq_child(newsk, dst);
 
+	tcp_mtup_init(newsk);
 	tcp_sync_mss(newsk, dst6_mtu(dst));
 	newtp->advmss = tcp_mss_clamp(tcp_sk(sk), tcp_dst_advmss(dst));
 

-- 
Git-157)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v2 2/4] selftests/net: packetdrill: test tcp_base_mss on passive connections
  2026-11-08 14:39 [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing Yongjian Wang via B4 Relay
  2026-11-08 14:39 ` [PATCH net-next v2 1/4] tcp: initialize MTU probing before syncing MSS at connection setup Yongjian Wang via B4 Relay
@ 2026-11-08 14:39 ` Yongjian Wang via B4 Relay
  2026-11-08 14:39 ` [PATCH net-next v2 3/4] selftests/net: packetdrill: add TCP black hole detection test Yongjian Wang via B4 Relay
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Yongjian Wang via B4 Relay @ 2026-11-08 14:39 UTC (permalink / raw)
  To: davem, pabeni, ncardwell, horms, kuba, kuniyu, shuah, edumazet
  Cc: linux-kselftest, linux-kernel, panweiping3, netdev, Yongjian Wang

From: Yongjian Wang <echoowall@gmail.com>

Check that a passive connection starts at tcp_base_mss with
net.ipv4.tcp_mtu_probing=2, as an active connection does.

Signed-off-by: Yongjian Wang <echoowall@gmail.com>
---
 .../net/packetdrill/tcp_mtu_probing_passive.pkt    | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_passive.pkt b/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_passive.pkt
new file mode 100644
index 000000000..14bae144c
--- /dev/null
+++ b/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_passive.pkt
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test that a passive connection starts at tcp_base_mss with tcp_mtu_probing=2,
+// the same way as an active connection.
+
+`./defaults.sh
+sysctl -q net.ipv4.tcp_mtu_probing=2
+sysctl -q net.ipv4.tcp_base_mss=1024
+sysctl -q net.ipv4.tcp_timestamps=0`
+
+    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+   +0 bind(3, ..., ...) = 0
+   +0 listen(3, 1) = 0
+
+   +0 < S 0:0(0) win 65535 <mss 1460,nop,nop,sackOK>
+   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
+  +.1 < . 1:1(0) ack 1 win 65535
+   +0 accept(3, ..., ...) = 4
+
+// The initial window is sent with tcp_base_mss, not the peer's MSS.
+   +0 write(4, ..., 10240) = 10240
+   +0 > P. 1:2049(2048) ack 1
+   +0 > P. 2049:4097(2048) ack 1
+   +0 > P. 4097:6145(2048) ack 1
+   +0 > P. 6145:8193(2048) ack 1
+   +0 > P. 8193:10241(2048) ack 1
+  +.1 < . 1:1(0) ack 10241 win 65535

-- 
Git-157)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v2 3/4] selftests/net: packetdrill: add TCP black hole detection test
  2026-11-08 14:39 [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing Yongjian Wang via B4 Relay
  2026-11-08 14:39 ` [PATCH net-next v2 1/4] tcp: initialize MTU probing before syncing MSS at connection setup Yongjian Wang via B4 Relay
  2026-11-08 14:39 ` [PATCH net-next v2 2/4] selftests/net: packetdrill: test tcp_base_mss on passive connections Yongjian Wang via B4 Relay
@ 2026-11-08 14:39 ` Yongjian Wang via B4 Relay
  2026-11-08 14:39 ` [PATCH net-next v2 4/4] selftests/net: packetdrill: add TCP MTU probing test Yongjian Wang via B4 Relay
  2026-11-08 14:42 ` [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing netdev-bot+sinfo
  4 siblings, 0 replies; 7+ messages in thread
From: Yongjian Wang via B4 Relay @ 2026-11-08 14:39 UTC (permalink / raw)
  To: davem, pabeni, ncardwell, horms, kuba, kuniyu, shuah, edumazet
  Cc: linux-kselftest, linux-kernel, panweiping3, netdev, Yongjian Wang

From: Yongjian Wang <echoowall@gmail.com>

Black hole detection (net.ipv4.tcp_mtu_probing=1) has no selftest
coverage.

Add a test where a full-sized segment keeps timing out without any ICMP
feedback. Check that the MSS drops to tcp_base_mss once tcp_retries1 is
exceeded, and that the smaller MSS is also used for new data after the
retransmission is acknowledged.

Set tcp_retries1 to 1 to keep the test short, and disable TLP so that
every retransmission comes from the RTO timer, which is what
tcp_write_timeout() counts.

Signed-off-by: Yongjian Wang <echoowall@gmail.com>
---
 .../net/packetdrill/tcp_mtu_probing_blackhole.pkt  | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_blackhole.pkt b/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_blackhole.pkt
new file mode 100644
index 000000000..f10dbb36d
--- /dev/null
+++ b/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_blackhole.pkt
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test black hole detection with tcp_mtu_probing=1: when full-sized segments
+// keep timing out and no ICMP arrives, TCP falls back to tcp_base_mss.
+
+`./defaults.sh
+sysctl -q net.ipv4.tcp_mtu_probing=1
+sysctl -q net.ipv4.tcp_base_mss=1024
+sysctl -q net.ipv4.tcp_retries1=1
+sysctl -q net.ipv4.tcp_early_retrans=0`
+
+    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+   +0 bind(3, ..., ...) = 0
+   +0 listen(3, 1) = 0
+
+   +0 < S 0:0(0) win 65535 <mss 1460,nop,nop,sackOK>
+   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
+  +.1 < . 1:1(0) ack 1 win 65535
+   +0 accept(3, ..., ...) = 4
+
+   +0 write(4, ..., 1460) = 1460
+   +0 > P. 1:1461(1460) ack 1
+
+// The first retransmission keeps the full size.
+  +.3 > P. 1:1461(1460) ack 1
+
+// Once tcp_retries1 is exceeded the MSS drops to tcp_base_mss.
+  +.6 > . 1:1025(1024) ack 1
+  +.1 < . 1:1(0) ack 1025 win 65535
+   +0 > P. 1025:1461(436) ack 1
+  +.1 < . 1:1(0) ack 1461 win 65535
+
+// New data keeps using the smaller MSS.
+   +0 write(4, ..., 1460) = 1460
+   +0 > . 1461:2485(1024) ack 1
+   +0 > P. 2485:2921(436) ack 1
+  +.1 < . 1:1(0) ack 2921 win 65535

-- 
Git-157)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v2 4/4] selftests/net: packetdrill: add TCP MTU probing test
  2026-11-08 14:39 [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing Yongjian Wang via B4 Relay
                   ` (2 preceding siblings ...)
  2026-11-08 14:39 ` [PATCH net-next v2 3/4] selftests/net: packetdrill: add TCP black hole detection test Yongjian Wang via B4 Relay
@ 2026-11-08 14:39 ` Yongjian Wang via B4 Relay
  2026-11-08 14:42 ` [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing netdev-bot+sinfo
  4 siblings, 0 replies; 7+ messages in thread
From: Yongjian Wang via B4 Relay @ 2026-11-08 14:39 UTC (permalink / raw)
  To: davem, pabeni, ncardwell, horms, kuba, kuniyu, shuah, edumazet
  Cc: linux-kselftest, linux-kernel, panweiping3, netdev, Yongjian Wang

From: Yongjian Wang <echoowall@gmail.com>

Packetization layer path MTU discovery (net.ipv4.tcp_mtu_probing=2) has
no selftest coverage.

Add a test for an active connection. Check that it starts at
tcp_base_mss, that it sends the first probe half way between
tcp_base_mss and the peer's MSS once cwnd allows it, and that an
acknowledged probe raises the MSS and leads to a larger probe.

Disable TCP timestamps since the MTU search range is computed before the
timestamp option is negotiated, which would otherwise make the MSS
depend on the header length at connect time.

Signed-off-by: Yongjian Wang <echoowall@gmail.com>
---
 .../net/packetdrill/tcp_mtu_probing_search.pkt     | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_search.pkt b/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_search.pkt
new file mode 100644
index 000000000..65e466fbf
--- /dev/null
+++ b/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_search.pkt
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test packetization layer path MTU discovery with tcp_mtu_probing=2: an
+// active connection starts at tcp_base_mss and raises its MSS by binary search
+// as probes are acknowledged.
+
+`./defaults.sh
+sysctl -q net.ipv4.tcp_mtu_probing=2
+sysctl -q net.ipv4.tcp_base_mss=1024
+sysctl -q net.ipv4.tcp_timestamps=0`
+
+    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+   +0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+   +0 connect(3, ..., ...) = -1 EINPROGRESS (Operation is now in progress)
+   +0 > S 0:0(0) <...>
+  +.1 < S. 0:0(0) ack 1 win 65535 <mss 1460,nop,nop,sackOK>
+   +0 > . 1:1(0) ack 1
+   +0 fcntl(3, F_SETFL, O_RDWR) = 0
+
+// The initial window is sent with tcp_base_mss. No probe yet, cwnd is below 11.
+   +0 write(3, ..., 40000) = 40000
+   +0 > P. 1:2049(2048) ack 1
+   +0 > P. 2049:4097(2048) ack 1
+   +0 > P. 4097:6145(2048) ack 1
+   +0 > P. 6145:8193(2048) ack 1
+   +0 > P. 8193:10241(2048) ack 1
+
+// The first probe is half way between tcp_base_mss and the peer's MSS.
+  +.1 < . 1:1(0) ack 10241 win 65535
+   +0 > . 10241:11483(1242) ack 1
+   +0 > P. 11483:13531(2048) ack 1
+   +0 > P. 13531:15579(2048) ack 1
+   +0 > P. 15579:17627(2048) ack 1
+   +0 > P. 17627:19675(2048) ack 1
+   +0 > P. 19675:21723(2048) ack 1
+   +0 > P. 21723:23771(2048) ack 1
+   +0 > P. 23771:25819(2048) ack 1
+   +0 > P. 25819:27867(2048) ack 1
+   +0 > P. 27867:29915(2048) ack 1
+
+// Acknowledging the probe raises the MSS, and the next probe is larger.
+  +.1 < . 1:1(0) ack 29915 win 65535
+   +0 > . 29915:31266(1351) ack 1
+   +0 > P. 31266:33750(2484) ack 1

-- 
Git-157)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing
  2026-11-08 14:39 [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing Yongjian Wang via B4 Relay
                   ` (3 preceding siblings ...)
  2026-11-08 14:39 ` [PATCH net-next v2 4/4] selftests/net: packetdrill: add TCP MTU probing test Yongjian Wang via B4 Relay
@ 2026-11-08 14:42 ` netdev-bot+sinfo
  2026-11-08 14:58   ` Esko Mobius
  4 siblings, 1 reply; 7+ messages in thread
From: netdev-bot+sinfo @ 2026-11-08 14:42 UTC (permalink / raw)
  To: Yongjian Wang
  Cc: davem, pabeni, ncardwell, horms, kuba, kuniyu, shuah, edumazet,
	linux-kselftest, linux-kernel, panweiping3, netdev

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.

The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing
  2026-11-08 14:42 ` [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing netdev-bot+sinfo
@ 2026-11-08 14:58   ` Esko Mobius
  0 siblings, 0 replies; 7+ messages in thread
From: Esko Mobius @ 2026-11-08 14:58 UTC (permalink / raw)
  To: netdev-bot+sinfo
  Cc: davem, pabeni, ncardwell, horms, kuba, kuniyu, shuah, edumazet,
	linux-kselftest, linux-kernel, panweiping3, netdev

> How the issue was discovered
Hi,

This came up while adding packetdrill coverage for tcp_mtu_probing=2.
The test work involved comparing the initial send MSS and what happened
after the first probe was acknowledged on active and passive IPv4
connections.

With tcp_base_mss=1024, the active connection started at 1024 as
expected. The passive connection started at 1460, and its send MSS
dropped to 1242 after the first probe was acknowledged. That led to
checking the passive setup path, where tcp_v4_syn_recv_sock() called
tcp_sync_mss() before tcp_init_transfer() enabled MTU probing.

Thanks,
Yongjian

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-08 14:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 14:39 [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing Yongjian Wang via B4 Relay
2026-11-08 14:39 ` [PATCH net-next v2 1/4] tcp: initialize MTU probing before syncing MSS at connection setup Yongjian Wang via B4 Relay
2026-11-08 14:39 ` [PATCH net-next v2 2/4] selftests/net: packetdrill: test tcp_base_mss on passive connections Yongjian Wang via B4 Relay
2026-11-08 14:39 ` [PATCH net-next v2 3/4] selftests/net: packetdrill: add TCP black hole detection test Yongjian Wang via B4 Relay
2026-11-08 14:39 ` [PATCH net-next v2 4/4] selftests/net: packetdrill: add TCP MTU probing test Yongjian Wang via B4 Relay
2026-11-08 14:42 ` [PATCH net-next v2 0/4] tcp: fix tcp_base_mss on passive connections and test MTU probing netdev-bot+sinfo
2026-11-08 14:58   ` Esko Mobius

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®