Skip to contentSkip to conversation

selftests/net: packetdrill: add tcp_syncookies_ip6_9k

PATCH In review Eric Dumazet 3 participants 9 messages Apr 29 – Apr 30

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/net: packetdrill: add tcp_syncookies_ip6_9k

This test checks syncookie mode is able to reconstruct some client options when TCP TS are used:

- wscale option.
- sackOK.
- MSS (in a limited way).
- ECN (not tested, because of limited value).

---
 .../net/packetdrill/tcp_syncookies_ip6_9k.pkt | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_syncookies_ip6_9k.pkt
tools/testing/selftests/net/packetdrill/tcp_syncookies_ip6_9k.pkt new file +30 -0
new file mode 100644
index 0000000000000000000000000000000000000000..15d03992a99140ecc4241edae58693dc5098fece
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Check syncookies.
+//
+// Check we are able to rebuild client sack, wscale 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 8940 mss, wscale 10 and sackOK
+   +0 %{ assert tcpi_snd_mss == 8928, tcpi_snd_mss }%
+   +0 %{ assert tcpi_snd_wscale = 10, tcpi_snd_wscale }%
+   +0 %{ assert (tcpi_options & TCPI_OPT_WSCALE) != 0, tcpi_options }%
+
Signature · 1 line
2.54.0.545.g6539524ca2-goog
#1 lore raw
Quoted 40 lines · Eric Dumazet

This test checks syncookie mode is able to reconstruct some client options when TCP TS are used:

- wscale option.
- sackOK.
- MSS (in a limited way).
- ECN (not tested, because of limited value).

---
 .../net/packetdrill/tcp_syncookies_ip6_9k.pkt | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_syncookies_ip6_9k.pkt
tools/testing/selftests/net/packetdrill/tcp_syncookies_ip6_9k.pkt new file +19 -0
new file mode 100644
index 0000000000000000000000000000000000000000..15d03992a99140ecc4241edae58693dc5098fece
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Check syncookies.
+//
+// Check we are able to rebuild client sack, wscale 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
+

tools/testing/selftests/net/packetdrill/tcp_syncookies_ip6_9k.pkt line 29

Quoted 10 lines
tools/testing/selftests/net/packetdrill/tcp_syncookies_ip6_9k.pkt new file +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 8940 mss, wscale 10 and sackOK
+   +0 %{ assert tcpi_snd_mss == 8928, tcpi_snd_mss }%
+   +0 %{ assert tcpi_snd_wscale = 10, tcpi_snd_wscale }%
+   +0 %{ assert (tcpi_options & TCPI_OPT_WSCALE) != 0, tcpi_options }%

The comment mentions checking sackOK but the script does not seem to do that? Probably want to check the TCPI_OPT_SACK bit as well? Maybe TCPI_OPT_TIMESTAMPS as well, for completeness?

Thanks for the test!

neal

#2 lore raw
Quoted 48 lines · Neal Cardwell
Quoted 46 lines · Eric Dumazet

This test checks syncookie mode is able to reconstruct some client options when TCP TS are used:

- wscale option.
- sackOK.
- MSS (in a limited way).
- ECN (not tested, because of limited value).

---
 .../net/packetdrill/tcp_syncookies_ip6_9k.pkt | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_syncookies_ip6_9k.pkt
tools/testing/selftests/net/packetdrill/tcp_syncookies_ip6_9k.pkt new file +25 -0
new file mode 100644
index 0000000000000000000000000000000000000000..15d03992a99140ecc4241edae58693dc5098fece
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Check syncookies.
+//
+// Check we are able to rebuild client sack, wscale 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
+
Quoted 8 lines

tools/testing/selftests/net/packetdrill/tcp_syncookies_ip6_9k.pkt line 29

Quoted 4 lines
tools/testing/selftests/net/packetdrill/tcp_syncookies_ip6_9k.pkt new file +4 -0
+// Check we properly infer from the final packet the other peer wanted 8940 mss, wscale 10 and sackOK
+   +0 %{ assert tcpi_snd_mss == 8928, tcpi_snd_mss }%
+   +0 %{ assert tcpi_snd_wscale = 10, tcpi_snd_wscale }%
+   +0 %{ assert (tcpi_options & TCPI_OPT_WSCALE) != 0, tcpi_options }%

The comment mentions checking sackOK but the script does not seem to do that? Probably want to check the TCPI_OPT_SACK bit as well? Maybe TCPI_OPT_TIMESTAMPS as well, for completeness?

Oh right, last minute typo, I was testing (tcpi_options & 2) != 0, then wanted to replace with the symbolic version, which should have been TCPI_OPT_SACK.

maintainer
#3 lore raw
In reply to Eric Dumazet
Quoted 7 lines · On Wed, 29 Apr 2026 08:00:36 +0000 Eric Dumazet wrote:

This test checks syncookie mode is able to reconstruct some client options when TCP TS are used:

- wscale option.
- sackOK.
- MSS (in a limited way).
- ECN (not tested, because of limited value).

We're getting:

# TAP version 13
# 1..1
# File "/tmp/code_oyWax9", line 223
# assert tcpi_snd_wscale = 10, tcpi_snd_wscale
# ^
# SyntaxError: invalid syntax
# tcp_syncookies_ip6_9k.pkt: error executing code: 'python3' returned non-zero status 1

do we need to update packetdrill ?

#4 lore raw
Quoted 20 lines · Jakub Kicinski
Quoted 7 lines · On Wed, 29 Apr 2026 08:00:36 +0000 Eric Dumazet wrote:

This test checks syncookie mode is able to reconstruct some client options when TCP TS are used:

- wscale option.
- sackOK.
- MSS (in a limited way).
- ECN (not tested, because of limited value).

We're getting:

# TAP version 13
# 1..1
# File "/tmp/code_oyWax9", line 223
# assert tcpi_snd_wscale = 10, tcpi_snd_wscale
# ^
# SyntaxError: invalid syntax
# tcp_syncookies_ip6_9k.pkt: error executing code: 'python3' returned non-zero status 1

Quoted 1 line

do we need to update packetdrill ?

No, this should have been

assert tcpi_snd_wscale == 10, tcpi_snd_wscale

I initially had a value of 8, and decided going to 10 just to make it different than the output wscale value.

Sorry for the confusion.

#5 lore raw
Quoted 24 lines · Eric Dumazet
Quoted 20 lines · Jakub Kicinski
Quoted 7 lines · On Wed, 29 Apr 2026 08:00:36 +0000 Eric Dumazet wrote:

This test checks syncookie mode is able to reconstruct some client options when TCP TS are used:

- wscale option.
- sackOK.
- MSS (in a limited way).
- ECN (not tested, because of limited value).

We're getting:

# TAP version 13
# 1..1
# File "/tmp/code_oyWax9", line 223
# assert tcpi_snd_wscale = 10, tcpi_snd_wscale
# ^
# SyntaxError: invalid syntax
# tcp_syncookies_ip6_9k.pkt: error executing code: 'python3' returned non-zero status 1

Quoted 1 line

do we need to update packetdrill ?

Quoted 8 lines

No, this should have been

assert tcpi_snd_wscale == 10, tcpi_snd_wscale

I initially had a value of 8, and decided going to 10 just to make it different than the output wscale value.

Sorry for the confusion.

Neal, can you take care of adding TCPI_OPT_SACK to packetdrill ?

Thanks!

gtests/net/packetdrill/code.c +1 -0
index d90bffabcfe6..6d8d20e64d8c 100644
@@ -129,6 +129,7 @@ static void write_symbols(struct code_state *code)
        emit_var(code, "TCPI_OPT_WSCALE",       TCPI_OPT_WSCALE);
        emit_var(code, "TCPI_OPT_ECN",          TCPI_OPT_ECN);
        emit_var(code, "TCPI_OPT_SYN_DATA",     TCPI_OPT_SYN_DATA);
+       emit_var(code, "TCPI_OPT_SACK", TCPI_OPT_SACK);
 #endif  /* linux */
 }
#6 lore raw
Quoted 44 lines · Eric Dumazet
Quoted 24 lines · Eric Dumazet
Quoted 20 lines · Jakub Kicinski
Quoted 7 lines · On Wed, 29 Apr 2026 08:00:36 +0000 Eric Dumazet wrote:

This test checks syncookie mode is able to reconstruct some client options when TCP TS are used:

- wscale option.
- sackOK.
- MSS (in a limited way).
- ECN (not tested, because of limited value).

We're getting:

# TAP version 13
# 1..1
# File "/tmp/code_oyWax9", line 223
# assert tcpi_snd_wscale = 10, tcpi_snd_wscale
# ^
# SyntaxError: invalid syntax
# tcp_syncookies_ip6_9k.pkt: error executing code: 'python3' returned non-zero status 1

Quoted 1 line

do we need to update packetdrill ?

Quoted 8 lines

No, this should have been

assert tcpi_snd_wscale == 10, tcpi_snd_wscale

I initially had a value of 8, and decided going to 10 just to make it different than the output wscale value.

Sorry for the confusion.

Neal, can you take care of adding TCPI_OPT_SACK to packetdrill ?

Thanks!

gtests/net/packetdrill/code.c +0 -0
index d90bffabcfe6..6d8d20e64d8c 100644

gtests/net/packetdrill/code.c static void write_symbols(struct code_state *code) · line 134

Quoted 6 lines
gtests/net/packetdrill/code.c +1 -0
@@ -129,6 +129,7 @@ static void write_symbols(struct code_state *code)
        emit_var(code, "TCPI_OPT_WSCALE",       TCPI_OPT_WSCALE);
        emit_var(code, "TCPI_OPT_ECN",          TCPI_OPT_ECN);
        emit_var(code, "TCPI_OPT_SYN_DATA",     TCPI_OPT_SYN_DATA);
+       emit_var(code, "TCPI_OPT_SACK", TCPI_OPT_SACK);
 #endif  /* linux */
 }

Sure! Done. I added all the missing bit values in the following commit:

https://github.com/google/packetdrill/commit/faa0dfb54065118625e169d3111ce09c65b20229

This can be picked up with the following, or similar:

git clone https://github.com/google/packetdrill.git

neal

maintainer
#7 lore raw
Quoted 14 lines · On Wed, 29 Apr 2026 16:47:14 -0400 Neal Cardwell wrote:

gtests/net/packetdrill/code.c static void write_symbols(struct code_state *code) · line 134

Quoted 11 lines
gtests/net/packetdrill/code.c +1 -0
index d90bffabcfe6..6d8d20e64d8c 100644
@@ -129,6 +129,7 @@ static void write_symbols(struct code_state *code)
        emit_var(code, "TCPI_OPT_WSCALE",       TCPI_OPT_WSCALE);
        emit_var(code, "TCPI_OPT_ECN",          TCPI_OPT_ECN);
        emit_var(code, "TCPI_OPT_SYN_DATA",     TCPI_OPT_SYN_DATA);
+       emit_var(code, "TCPI_OPT_SACK", TCPI_OPT_SACK);
 #endif  /* linux */
 }  

Sure! Done. I added all the missing bit values in the following commit:

Quoted 5 lines

https://github.com/google/packetdrill/commit/faa0dfb54065118625e169d3111ce09c65b20229

This can be picked up with the following, or similar:

git clone https://github.com/google/packetdrill.git

Updated in netdev CI.

#8 lore raw
Quoted 16 lines · Jakub Kicinski
Quoted 14 lines · On Wed, 29 Apr 2026 16:47:14 -0400 Neal Cardwell wrote:

gtests/net/packetdrill/code.c static void write_symbols(struct code_state *code) · line 134

Quoted 11 lines
gtests/net/packetdrill/code.c +1 -0
index d90bffabcfe6..6d8d20e64d8c 100644
@@ -129,6 +129,7 @@ static void write_symbols(struct code_state *code)
        emit_var(code, "TCPI_OPT_WSCALE",       TCPI_OPT_WSCALE);
        emit_var(code, "TCPI_OPT_ECN",          TCPI_OPT_ECN);
        emit_var(code, "TCPI_OPT_SYN_DATA",     TCPI_OPT_SYN_DATA);
+       emit_var(code, "TCPI_OPT_SACK", TCPI_OPT_SACK);
 #endif  /* linux */
 }

Sure! Done. I added all the missing bit values in the following commit:

Quoted 7 lines
Quoted 5 lines

https://github.com/google/packetdrill/commit/faa0dfb54065118625e169d3111ce09c65b20229

This can be picked up with the following, or similar:

git clone https://github.com/google/packetdrill.git

Updated in netdev CI.

Excellent, thanks Neal and Jakub.

I am sending a V2 right now, because I am OOO for the rest of the week.