selftests: net: packetdrill: add tests for advertised MSS with PMTU exceptions

Add packetdrill tests for IPv4 and IPv6 to verify that the advertised
MSS in SYN-ACK is derived from the configured interface/route MTU,
and is not shrunk by learned Path MTU exceptions from previous
outbound connections.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20260815071532.301908-1-jiayuan.chen@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Eric Dumazet 2026-08-15 15:15:08 +08:00 committed by Jakub Kicinski
parent 2640e64195
commit e5c8e301b4
2 changed files with 134 additions and 0 deletions

View File

@ -0,0 +1,67 @@
// SPDX-License-Identifier: GPL-2.0
//
// Test that IPv4 advertised MSS in SYN-ACK is derived from the configured
// interface MTU (1500 -> MSS 1460), not the ICMP-learned Path MTU.
--ip_version=ipv4
`./defaults.sh
ethtool -K tun0 tso off
`
//
// Connection 1: Learn PMTU exception (MTU 1200 -> MSS 1160)
//
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,sackOK,nop,nop,nop,wscale 8>
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+.1 < . 1:1(0) ack 1 win 257
+0 accept(3, ..., ...) = 4
// Send a full 1460-byte segment
+0 write(4, ..., 1460) = 1460
+0 > P. 1:1461(1460) ack 1
// ICMP Fragmentation Needed arrives indicating next-hop MTU 1200
+0 < icmp unreachable frag_needed mtu 1200 [1:1461(1460)]
// Local host retransmits using the learned MTU 1200 (MSS = 1200 - 40 = 1160)
+0 > . 1:1161(1160) ack 1
+0 > P. 1161:1461(300) ack 1
+0 < R 1:1(0) ack 1461 win 0
// Close connection 1 and listener
+0 close(4) = 0
+0 close(3) = 0
//
// Connection 2: New connection from the same peer
//
+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,sackOK,nop,nop,nop,wscale 8>
// Verify: SYN-ACK MUST advertise configured MSS 1460, NOT the learned PMTU MSS 1160
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+0 < . 1:1(0) ack 1 win 257
+0 accept(3, ..., ...) = 4
// Verify: Outgoing transmit MSS is still constrained by the learned PMTU 1200
+0 write(4, ..., 1460) = 1460
+0 > . 1:1161(1160) ack 1
+0 > P. 1161:1461(300) ack 1
+0 < . 1:1(0) ack 1461 win 257
// Clean up
+0 close(4) = 0
+0 > F. 1461:1461(0) ack 1
+0 < F. 1:1(0) ack 1462 win 257
+0 > . 1462:1462(0) ack 2
+0 close(3) = 0

View File

@ -0,0 +1,67 @@
// SPDX-License-Identifier: GPL-2.0
//
// Test that IPv6 advertised MSS in SYN-ACK is derived from the configured
// interface MTU (1520 -> MSS 1460), not the ICMPv6-learned Path MTU.
--ip_version=ipv6
`./defaults.sh
ethtool -K tun0 tso off
`
//
// Connection 1: Learn PMTU exception (MTU 1280 -> MSS 1220)
//
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,sackOK,nop,nop,nop,wscale 8>
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+.1 < . 1:1(0) ack 1 win 257
+0 accept(3, ..., ...) = 4
// Send a full 1460-byte segment
+0 write(4, ..., 1460) = 1460
+0 > P. 1:1461(1460) ack 1
// ICMPv6 Packet Too Big arrives indicating next-hop MTU 1280
+0 < icmp packet_too_big mtu 1280 [1:1461(1460)]
// Local host retransmits using the learned MTU 1280 (MSS = 1280 - 40 - 20 = 1220)
+0 > . 1:1221(1220) ack 1
+0 > P. 1221:1461(240) ack 1
+0 < R 1:1(0) ack 1461 win 0
// Close connection 1 and listener
+0 close(4) = 0
+0 close(3) = 0
//
// Connection 2: New connection from the same peer
//
+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,sackOK,nop,nop,nop,wscale 8>
// Verify: SYN-ACK MUST advertise configured MSS 1460, NOT the learned PMTU MSS 1220
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+0 < . 1:1(0) ack 1 win 257
+0 accept(3, ..., ...) = 4
// Verify: Outgoing transmit MSS is still constrained by the learned PMTU 1280
+0 write(4, ..., 1460) = 1460
+0 > . 1:1221(1220) ack 1
+0 > P. 1221:1461(240) ack 1
+0 < . 1:1(0) ack 1461 win 257
// Clean up
+0 close(4) = 0
+0 > F. 1461:1461(0) ack 1
+0 < F. 1:1(0) ack 1462 win 257
+0 > . 1462:1462(0) ack 2
+0 close(3) = 0