xref: /linux/tools/testing/selftests/net/packetdrill/tcp_advmss_pmtu_ipv4.pkt (revision 67f8bc848ee31831336bd478e57d2f993551902e)
1*e5c8e301SEric Dumazet// SPDX-License-Identifier: GPL-2.0
2*e5c8e301SEric Dumazet//
3*e5c8e301SEric Dumazet// Test that IPv4 advertised MSS in SYN-ACK is derived from the configured
4*e5c8e301SEric Dumazet// interface MTU (1500 -> MSS 1460), not the ICMP-learned Path MTU.
5*e5c8e301SEric Dumazet
6*e5c8e301SEric Dumazet--ip_version=ipv4
7*e5c8e301SEric Dumazet
8*e5c8e301SEric Dumazet`./defaults.sh
9*e5c8e301SEric Dumazetethtool -K tun0 tso off
10*e5c8e301SEric Dumazet`
11*e5c8e301SEric Dumazet
12*e5c8e301SEric Dumazet//
13*e5c8e301SEric Dumazet// Connection 1: Learn PMTU exception (MTU 1200 -> MSS 1160)
14*e5c8e301SEric Dumazet//
15*e5c8e301SEric Dumazet    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
16*e5c8e301SEric Dumazet   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
17*e5c8e301SEric Dumazet   +0 bind(3, ..., ...) = 0
18*e5c8e301SEric Dumazet   +0 listen(3, 1) = 0
19*e5c8e301SEric Dumazet
20*e5c8e301SEric Dumazet   +0 < S 0:0(0) win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 8>
21*e5c8e301SEric Dumazet   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
22*e5c8e301SEric Dumazet  +.1 < . 1:1(0) ack 1 win 257
23*e5c8e301SEric Dumazet   +0 accept(3, ..., ...) = 4
24*e5c8e301SEric Dumazet
25*e5c8e301SEric Dumazet// Send a full 1460-byte segment
26*e5c8e301SEric Dumazet   +0 write(4, ..., 1460) = 1460
27*e5c8e301SEric Dumazet   +0 > P. 1:1461(1460) ack 1
28*e5c8e301SEric Dumazet
29*e5c8e301SEric Dumazet// ICMP Fragmentation Needed arrives indicating next-hop MTU 1200
30*e5c8e301SEric Dumazet   +0 < icmp unreachable frag_needed mtu 1200 [1:1461(1460)]
31*e5c8e301SEric Dumazet
32*e5c8e301SEric Dumazet// Local host retransmits using the learned MTU 1200 (MSS = 1200 - 40 = 1160)
33*e5c8e301SEric Dumazet   +0 > . 1:1161(1160) ack 1
34*e5c8e301SEric Dumazet   +0 > P. 1161:1461(300) ack 1
35*e5c8e301SEric Dumazet   +0 < R 1:1(0) ack 1461 win 0
36*e5c8e301SEric Dumazet
37*e5c8e301SEric Dumazet// Close connection 1 and listener
38*e5c8e301SEric Dumazet   +0 close(4) = 0
39*e5c8e301SEric Dumazet   +0 close(3) = 0
40*e5c8e301SEric Dumazet
41*e5c8e301SEric Dumazet//
42*e5c8e301SEric Dumazet// Connection 2: New connection from the same peer
43*e5c8e301SEric Dumazet//
44*e5c8e301SEric Dumazet   +0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
45*e5c8e301SEric Dumazet   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
46*e5c8e301SEric Dumazet   +0 bind(3, ..., ...) = 0
47*e5c8e301SEric Dumazet   +0 listen(3, 1) = 0
48*e5c8e301SEric Dumazet
49*e5c8e301SEric Dumazet   +0 < S 0:0(0) win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 8>
50*e5c8e301SEric Dumazet
51*e5c8e301SEric Dumazet// Verify: SYN-ACK MUST advertise configured MSS 1460, NOT the learned PMTU MSS 1160
52*e5c8e301SEric Dumazet   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
53*e5c8e301SEric Dumazet   +0 < . 1:1(0) ack 1 win 257
54*e5c8e301SEric Dumazet   +0 accept(3, ..., ...) = 4
55*e5c8e301SEric Dumazet
56*e5c8e301SEric Dumazet// Verify: Outgoing transmit MSS is still constrained by the learned PMTU 1200
57*e5c8e301SEric Dumazet   +0 write(4, ..., 1460) = 1460
58*e5c8e301SEric Dumazet   +0 > . 1:1161(1160) ack 1
59*e5c8e301SEric Dumazet   +0 > P. 1161:1461(300) ack 1
60*e5c8e301SEric Dumazet   +0 < . 1:1(0) ack 1461 win 257
61*e5c8e301SEric Dumazet
62*e5c8e301SEric Dumazet// Clean up
63*e5c8e301SEric Dumazet   +0 close(4) = 0
64*e5c8e301SEric Dumazet   +0 > F. 1461:1461(0) ack 1
65*e5c8e301SEric Dumazet   +0 < F. 1:1(0) ack 1462 win 257
66*e5c8e301SEric Dumazet   +0 > . 1462:1462(0) ack 2
67*e5c8e301SEric Dumazet   +0 close(3) = 0
68