Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftest: packetdrill: Import TFO server basic tests.

This imports basic TFO server tests from google/packetdrill.

The repository has two versions of tests for most scenarios; one uses
the non-experimental option (34), and the other uses the experimental
option (255) with 0xF989.

This only imports the following tests of the non-experimental version
placed in [0]. I will add a specific test for the experimental option
handling later.

| TFO | Cookie | Payload |
---------------------------+-----+--------+---------+
basic-rw.pkt | yes | yes | yes |
basic-zero-payload.pkt | yes | yes | no |
basic-cookie-not-reqd.pkt | yes | no | yes |
basic-non-tfo-listener.pkt | no | yes | yes |
pure-syn-data.pkt | yes | no | yes |

The original pure-syn-data.pkt missed setsockopt(TCP_FASTOPEN) and did
not test TFO server in some scenarios unintentionally, so setsockopt()
is added where needed. In addition, non-TFO scenario is stripped as
it is covered by basic-non-tfo-listener.pkt. Also, I added basic- prefix.

Link: https://github.com/google/packetdrill/tree/bfc96251310f/gtests/net/tcp/fastopen/server/opt34 #[0]
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250927213022.1850048-5-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
0b8f164e 97b3b830

+157
+26
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-non-tfo-listener.pkt
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // 3 + // Basic TFO server test 4 + // 5 + // Server w/o TCP_FASTOPEN socket option 6 + 7 + `./defaults.sh` 8 + 9 + 0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3 10 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 11 + +0 bind(3, ..., ...) = 0 12 + +0 listen(3, 1) = 0 13 + 14 + +0 < S 0:10(10) win 32792 <mss 1460,sackOK,FO TFO_COOKIE> 15 + 16 + // Data is ignored since TCP_FASTOPEN is not set on the listener 17 + +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK> 18 + 19 + +0 accept(3, ..., ...) = -1 EAGAIN (Resource temporarily unavailable) 20 + 21 + // The above should block until ack comes in below. 22 + +0 < . 1:31(30) ack 1 win 5840 23 + +0 accept(3, ..., ...) = 4 24 + 25 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) == 0, tcpi_options }% 26 + +0 read(4, ..., 512) = 30
+50
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-pure-syn-data.pkt
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // 3 + // Basic TFO server test 4 + // 5 + // Test that TFO-enabled server would not respond SYN-ACK with any TFO option 6 + // when receiving a pure SYN-data. It should respond a pure SYN-ack. 7 + 8 + `./defaults.sh` 9 + 10 + 0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3 11 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 12 + +0 bind(3, ..., ...) = 0 13 + +0 listen(3, 1) = 0 14 + +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0 15 + 16 + +0 < S 999000:999040(40) win 32792 <mss 1460,sackOK,TS val 100 ecr 100,nop,wscale 6> 17 + +0 > S. 1234:1234(0) ack 999001 <mss 1460,sackOK,TS val 100 ecr 100,nop,wscale 8> 18 + +0 < . 1:1(0) ack 1 win 100 19 + +0 accept(3, ..., ...) = 4 20 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) == 0, tcpi_options }% 21 + +0 close(3) = 0 22 + 23 + // Test ECN-setup SYN with ECN disabled because this has happened in reality 24 + +0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3 25 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 26 + +0 bind(3, ..., ...) = 0 27 + +0 listen(3, 1) = 0 28 + +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0 29 + 30 + +0 < SEW 999000:999040(40) win 32792 <mss 1460,sackOK,TS val 100 ecr 100,nop,wscale 6> 31 + +0 > S. 1234:1234(0) ack 999001 <mss 1460,sackOK,TS val 100 ecr 100,nop,wscale 8> 32 + +0 < . 1:1(0) ack 1 win 100 33 + +0 accept(3, ..., ...) = 4 34 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) == 0, tcpi_options }% 35 + +0 close(3) = 0 36 + 37 + // Test ECN-setup SYN w/ ECN enabled 38 + +0 `sysctl -q net.ipv4.tcp_ecn=2` 39 + +0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3 40 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 41 + +0 bind(3, ..., ...) = 0 42 + +0 listen(3, 1) = 0 43 + +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0 44 + 45 + +0 < SEW 999000:999040(40) win 32792 <mss 1460,sackOK,TS val 100 ecr 100,nop,wscale 6> 46 + +0 > SE. 1234:1234(0) ack 999001 <mss 1460,sackOK,TS val 100 ecr 100,nop,wscale 8> 47 + +0 < . 1:1(0) ack 1 win 100 48 + +0 accept(3, ..., ...) = 4 49 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) == 0, tcpi_options }% 50 + +0 close(3) = 0
+23
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-rw.pkt
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // 3 + // Basic TFO server test 4 + // 5 + // Test TFO server with SYN that has TFO cookie and data. 6 + 7 + `./defaults.sh` 8 + 9 + 0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3 10 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 11 + +0 bind(3, ..., ...) = 0 12 + +0 listen(3, 1) = 0 13 + +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0 14 + 15 + +0 < S 0:10(10) win 32792 <mss 1460,sackOK,nop,nop,FO TFO_COOKIE,nop,nop> 16 + +0 > S. 0:0(0) ack 11 <mss 1460,nop,nop,sackOK> 17 + 18 + +0 accept(3, ..., ...) = 4 19 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) != 0, tcpi_options }% 20 + 21 + +0 read(4, ..., 512) = 10 22 + +0 write(4, ..., 100) = 100 23 + +0 > P. 1:101(100) ack 11
+26
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-zero-payload.pkt
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // 3 + // Basic TFO server test 4 + // 5 + // Test zero-payload packet w/ valid TFO cookie - a TFO socket will 6 + // still be created and accepted but read() will not return until a 7 + // later pkt with 10 byte. 8 + 9 + `./defaults.sh` 10 + 11 + 0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3 12 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 13 + +0 bind(3, ..., ...) = 0 14 + +0 listen(3, 1) = 0 15 + +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0 16 + 17 + +0 < S 0:0(0) win 32792 <mss 1460,sackOK,nop,nop,FO TFO_COOKIE,nop,nop> 18 + +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK> 19 + +0 accept(3, ..., ...) = 4 20 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) == 0, tcpi_options }% 21 + 22 + // A TFO socket is created and is writable. 23 + +0 write(4, ..., 100) = 100 24 + +0 > P. 1:101(100) ack 1 25 + +0...0.300 read(4, ..., 512) = 10 26 + +.3 < P. 1:11(10) ack 1 win 5840