[PATCH net-next 3/4] selftests/net: packetdrill: add TCP black hole detection test

From: Yongjian Wang via B4 Relay

Date: Tue Nov 03 2026 - 02:14:39 EST


From: Yongjian Wang <echoowall@xxxxxxxxx>

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@xxxxxxxxx>
---
.../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)