Commit 4363d182 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'selftest-packetdrill-import-tfo-server-tests'

Kuniyuki Iwashima says:

====================
selftest: packetdrill: Import TFO server tests.

The series imports 15 TFO server tests from google/packetdrill and
adds 2 more tests.

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.

Basically, we only import the non-experimental version of tests, and
for the experimental option, tcp_fastopen_server_experimental_option.pkt
is added.

The following tests are not (yet) imported:

  * icmp-baseline.pkt
  * simple1.pkt / simple2.pkt / simple3.pkt

The former is completely covered by icmp-before-accept.pkt.

The later's delta is the src/dst IP pair to generate a different
cookie, but supporting dualstack requires churn in ksft_runner.sh,
so defered to future series.  Also, sockopt-fastopen-key.pkt covers
the same function.

The following tests have the experimental version only, so converted
to the non-experimental option:

  * client-ack-dropped-then-recovery-ms-timestamps.pkt
  * sockopt-fastopen-key.pkt

For the imported tests, these common changes are applied.

  * Add SPDX header
  * Adjust path to default.sh
  * Adjust sysctl w/ set_sysctls.py
  * Use TFO_COOKIE instead of a raw hex value
  * Use SOCK_NONBLOCK for socket() not to block accept()
  * Add assertions for TCP state if commented
  * Remove unnecessary delay (e.g. +0.1 setsockopt(SO_REUSEADDR), etc)

With this series, except for simple{1,2,3}.pkt, we can remove TFO server
tests in google/packetdrill.
====================

Link: https://patch.msgid.link/20250927213022.1850048-1-kuniyu@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 4ed9db2d 9b62d53c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ sysctl -q net.ipv4.tcp_pacing_ss_ratio=200
sysctl -q net.ipv4.tcp_pacing_ca_ratio=120
sysctl -q net.ipv4.tcp_notsent_lowat=4294967295 > /dev/null 2>&1

sysctl -q net.ipv4.tcp_fastopen=0x70403
sysctl -q net.ipv4.tcp_fastopen=0x3
# Use TFO_COOKIE in ksft_runner.sh for this key.
sysctl -q net.ipv4.tcp_fastopen_key=a1a1a1a1-b2b2b2b2-c3c3c3c3-d4d4d4d4

sysctl -q net.ipv4.tcp_syncookies=1
+6 −2
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@ declare -A ip_args=(
		--gateway_ip=192.168.0.1
		--netmask_ip=255.255.0.0
		--remote_ip=192.0.2.1
		-D TFO_COOKIE=3021b9d889017eeb
		-D TFO_COOKIE_ZERO=b7c12350a90dc8f5
		-D CMSG_LEVEL_IP=SOL_IP
		-D CMSG_TYPE_RECVERR=IP_RECVERR"
	[ipv6]="--ip_version=ipv6
@@ -16,6 +18,8 @@ declare -A ip_args=(
		--local_ip=fd3d:0a0b:17d6::1
		--gateway_ip=fd3d:0a0b:17d6:8888::1
		--remote_ip=fd3d:fa7b:d17d::1
		-D TFO_COOKIE=c1d1e9742a47a9bc
		-D TFO_COOKIE_ZERO=82af1a8f9a205c34
		-D CMSG_LEVEL_IP=SOL_IPV6
		-D CMSG_TYPE_RECVERR=IPV6_RECVERR"
)
@@ -48,7 +52,7 @@ elif [[ ! "$ip_versions" =~ ^ipv[46]$ ]]; then
fi

ktap_print_header
ktap_set_plan 2
ktap_set_plan $(echo $ip_versions | wc -w)

for ip_version in $ip_versions; do
	unshare -n packetdrill ${ip_args[$ip_version]} ${optargs[@]} $script > /dev/null \
+32 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
//
// Basic TFO server test
//
// Test TFO_SERVER_COOKIE_NOT_REQD flag on receiving
// SYN with data but without Fast Open cookie option.

`./defaults.sh
 ./set_sysctls.py /proc/sys/net/ipv4/tcp_fastopen=0x202`

    0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3
   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
   +0 bind(3, ..., ...) = 0
   +0 listen(3, 1) = 0
   +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0

// Since TFO_SERVER_COOKIE_NOT_REQD, a TFO socket will be created with
// the data accepted.
   +0 < S 0:1000(1000) win 32792 <mss 1460,sackOK,nop,nop>
   +0 > S. 0:0(0) ack 1001 <mss 1460,nop,nop,sackOK>
   +0 accept(3, ..., ...) = 4
   +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) != 0, tcpi_options }%
   +0 read(4, ..., 1024) = 1000

// Data After SYN will be accepted too.
   +0 < . 1001:2001(1000) ack 1 win 5840
   +0 > . 1:1(0) ack 2001

// Should change the implementation later to set the SYN flag as well.
   +0 read(4, ..., 1024) = 1000
   +0 write(4, ..., 1000) = 1000
   +0 > P. 1:1001(1000) ack 2001
+21 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
//
// Basic TFO server test
//
// Test TFO_SERVER_WO_SOCKOPT1 without setsockopt(TCP_FASTOPEN)

`./defaults.sh
 ./set_sysctls.py /proc/sys/net/ipv4/tcp_fastopen=0x402`

    0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, 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:10(10) win 32792 <mss 1460,sackOK,nop,nop,FO TFO_COOKIE,nop,nop>
   +0 > S. 0:0(0) ack 11 <mss 1460,nop,nop,sackOK>

   +0 accept(3, ..., ...) = 4
   +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) != 0, tcpi_options }%

   +0 read(4, ..., 512) = 10
+26 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
//
// Basic TFO server test
//
// Server w/o TCP_FASTOPEN socket option

`./defaults.sh`

    0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, 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:10(10) win 32792 <mss 1460,sackOK,FO TFO_COOKIE>

// Data is ignored since TCP_FASTOPEN is not set on the listener
   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>

   +0 accept(3, ..., ...) = -1 EAGAIN (Resource temporarily unavailable)

// The above should block until ack comes in below.
   +0 < . 1:31(30) ack 1 win 5840
   +0 accept(3, ..., ...) = 4

   +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) == 0, tcpi_options }%
   +0 read(4, ..., 512) = 30
Loading