selftests/net: packetdrill: add tcp_syncookies_ip[46]_9k

These tests check syncookie mode is able to reconstruct some
client options when TCP TS are used:

- wscale option.
- sackOK.
- MSS (in a limited way, especially for IPv4).
- ECN : not enabled.

Note that IPv4 and IPv6 have different msstab[] values:

IPv4 msstab[4] = { 536, 1300, 1440, 1460 }
IPv6 msstab[4] = { 1280 - 60, 1480 - 60, 1500 - 60, 9000 - 60 }

IPv4 is currently capping SND_MSS to 1460, even on a 9K MTU network.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Neal Cardwell <ncardwell@google.com>
Link: https://patch.msgid.link/20260430021444.2929534-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Eric Dumazet 2026-04-30 02:14:44 +00:00 committed by Jakub Kicinski
parent 4e37987362
commit bc6a9b667f
2 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,37 @@
// SPDX-License-Identifier: GPL-2.0
//
// Check syncookies.
//
// Check we are able to rebuild client sack, wscale, ecn and mss options.
// IPv4 msstab[4] = { 536, 1300, 1440, 1460 }
--ip_version=ipv4
`./defaults.sh
sysctl -q net.ipv4.tcp_syncookies=2
ip link set dev tun0 mtu 9000
`
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0 bind(3, ..., ...) = 0
+0 listen(3, 10) = 0
+0 < S 0:0(0) win 32792 <mss 8960,sackOK,TS val 100 ecr 0,nop,wscale 10>
+0 > S. 0:0(0) ack 1 <mss 8960,sackOK,TS val 4000 ecr 100,nop,wscale 8>
+.01 < . 1:1(0) ack 1 win 1024 <nop,nop,TS val 110 ecr 4000>
+0 accept(3, ..., ...) = 4
// Check we properly infer from the final packet the other peer wanted mss >= 1460, wscale 10, sackOK and no ECN.
// Note that mss is limited to 1460 - 12 because of IPv4 msstab[]
// This is only possible because TCP TS option was used.
// Linux uses the SYNACK TS.val 6 low order bits to encode the options.
+0 %{ assert tcpi_snd_mss == 1460 - 12, tcpi_snd_mss; \
assert tcpi_snd_wscale == 10, tcpi_snd_wscale; \
assert (tcpi_options & TCPI_OPT_SACK) != 0, tcpi_options; \
assert (tcpi_options & TCPI_OPT_TIMESTAMPS) != 0, tcpi_options; \
assert (tcpi_options & TCPI_OPT_WSCALE) != 0, tcpi_options; \
assert (tcpi_options & TCPI_OPT_ECN) == 0, tcpi_options
}%

View File

@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-2.0
//
// Check syncookies.
//
// Check we are able to rebuild client sack, wscale, ecn and mss options.
// IPv6 msstab[4] = { 1280 - 60, 1480 - 60, 1500 - 60, 9000 - 60 }
--ip_version=ipv6
`./defaults.sh
sysctl -q net.ipv4.tcp_syncookies=2
ip link set dev tun0 mtu 9000
`
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0 bind(3, ..., ...) = 0
+0 listen(3, 10) = 0
+0 < S 0:0(0) win 32792 <mss 8940,sackOK,TS val 100 ecr 0,nop,wscale 10>
+0 > S. 0:0(0) ack 1 <mss 8940,sackOK,TS val 4000 ecr 100,nop,wscale 8>
+.01 < . 1:1(0) ack 1 win 1024 <nop,nop,TS val 110 ecr 4000>
+0 accept(3, ..., ...) = 4
// Check we properly infer from the final packet the other peer wanted mss >= 8940, wscale 10, sackOK and no ECN.
// This is only possible because TCP TS option was used.
// Linux uses the SYNACK TS.val 6 low order bits to encode the options.
+0 %{ assert tcpi_snd_mss == 8940 - 12, tcpi_snd_mss; \
assert tcpi_snd_wscale == 10, tcpi_snd_wscale; \
assert (tcpi_options & TCPI_OPT_SACK) != 0, tcpi_options; \
assert (tcpi_options & TCPI_OPT_TIMESTAMPS) != 0, tcpi_options; \
assert (tcpi_options & TCPI_OPT_WSCALE) != 0, tcpi_options; \
assert (tcpi_options & TCPI_OPT_ECN) == 0, tcpi_options
}%