[PATCH net-next v4 3/4] selftests/net: packetdrill: add TCP black hole detection tests
From: Yongjian Wang via B4 Relay
Date: Tue Nov 10 2026 - 12:53:52 EST
From: Yongjian Wang <echoowall@xxxxxxxxx>
Black hole detection (net.ipv4.tcp_mtu_probing=1) has no selftest
coverage.
Add a test that only sets tcp_mtu_probing=1 on top of the default
settings. 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.
Add a shorter variant with tcp_retries1=1 and TLP disabled, so that
every retransmission comes from the RTO timer, which is what
tcp_write_timeout() counts.
Signed-off-by: Yongjian Wang <echoowall@xxxxxxxxx>
---
.../net/packetdrill/tcp_mtu_probing_blackhole.pkt | 38 ++++++++++++++++++++++
..._mtu_probing_blackhole_no_tlp_retries1_is_1.pkt | 38 ++++++++++++++++++++++
2 files changed, 76 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 000000000000..95309cb4d872
--- /dev/null
+++ b/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_blackhole.pkt
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test black hole detection with default settings and 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`
+
+ 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
+
+// TLP and the first RTO retransmissions keep the full size.
+ +.3 > P. 1:1461(1460) ack 1
+ +.3 > P. 1:1461(1460) ack 1
+ +.6 > P. 1:1461(1460) ack 1
+ +1.2 > P. 1:1461(1460) ack 1
+
+// Once tcp_retries1 is exceeded the MSS drops to tcp_base_mss.
+ +2.4 > . 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
diff --git a/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_blackhole_no_tlp_retries1_is_1.pkt b/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_blackhole_no_tlp_retries1_is_1.pkt
new file mode 100644
index 000000000000..0421458fba45
--- /dev/null
+++ b/tools/testing/selftests/net/packetdrill/tcp_mtu_probing_blackhole_no_tlp_retries1_is_1.pkt
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test black hole detection with tcp_mtu_probing=1, tcp_retries1=1 and TLP
+// disabled: 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)