selftest: packetdrill: Import TFO server tests.
Subsystems (3)
v2 cover 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.
Changes:
v2:
* Add patch 1 for icmp-before-accept.pkt.
* Patch 2:
* Keep TFO_CLIENT_ENABLE for tcp_syscall_bad_arg_fastopen-invalid-buf-ptr.pkt.
v1: https://lore.kernel.org/netdev/[email protected]/
Kuniyuki Iwashima (13):
selftest: packetdrill: Set ktap_set_plan properly for single protocol
test.
selftest: packetdrill: Require explicit setsockopt(TCP_FASTOPEN).
selftest: packetdrill: Define common TCP Fast Open cookie.
selftest: packetdrill: Import TFO server basic tests.
selftest: packetdrill: Add test for TFO_SERVER_WO_SOCKOPT1.
selftest: packetdrill: Add test for experimental option.
selftest: packetdrill: Import opt34/fin-close-socket.pkt.
selftest: packetdrill: Import opt34/icmp-before-accept.pkt.
selftest: packetdrill: Import opt34/reset-* tests.
selftest: packetdrill: Import opt34/*-trigger-rst.pkt.
selftest: packetdrill: Refine
tcp_fastopen_server_reset-after-disconnect.pkt.
selftest: packetdrill: Import sockopt-fastopen-key.pkt
selftest: packetdrill: Import
client-ack-dropped-then-recovery-ms-timestamps.pkt
.../selftests/net/packetdrill/defaults.sh | 3 +-
.../selftests/net/packetdrill/ksft_runner.sh | 8 +-
..._fastopen_server_basic-cookie-not-reqd.pkt | 32 ++++++++
...cp_fastopen_server_basic-no-setsockopt.pkt | 21 ++++++
...fastopen_server_basic-non-tfo-listener.pkt | 26 +++++++
...cp_fastopen_server_basic-pure-syn-data.pkt | 50 +++++++++++++
.../tcp_fastopen_server_basic-rw.pkt | 23 ++++++
...tcp_fastopen_server_basic-zero-payload.pkt | 26 +++++++
...ck-dropped-then-recovery-ms-timestamps.pkt | 46 ++++++++++++
...cp_fastopen_server_experimental_option.pkt | 37 ++++++++++
.../tcp_fastopen_server_fin-close-socket.pkt | 30 ++++++++
...tcp_fastopen_server_icmp-before-accept.pkt | 49 ++++++++++++
...tcp_fastopen_server_reset-after-accept.pkt | 37 ++++++++++
...cp_fastopen_server_reset-before-accept.pkt | 32 ++++++++
...en_server_reset-close-with-unread-data.pkt | 32 ++++++++
...p_fastopen_server_reset-non-tfo-socket.pkt | 37 ++++++++++
...p_fastopen_server_sockopt-fastopen-key.pkt | 74 +++++++++++++++++++
...pen_server_trigger-rst-listener-closed.pkt | 21 ++++++
...fastopen_server_trigger-rst-reconnect.pkt} | 10 ++-
..._server_trigger-rst-unread-data-closed.pkt | 23 ++++++
20 files changed, 611 insertions(+), 6 deletions(-)
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-cookie-not-reqd.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-no-setsockopt.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-non-tfo-listener.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-pure-syn-data.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-rw.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-zero-payload.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_client-ack-dropped-then-recovery-ms-timestamps.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_experimental_option.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_fin-close-socket.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_icmp-before-accept.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-after-accept.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-before-accept.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-close-with-unread-data.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-non-tfo-socket.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_sockopt-fastopen-key.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_trigger-rst-listener-closed.pkt
rename tools/testing/selftests/net/packetdrill/{tcp_fastopen_server_reset-after-disconnect.pkt => tcp_fastopen_server_trigger-rst-reconnect.pkt} (66%)
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_trigger-rst-unread-data-closed.pktSignature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 1/13 selftest: packetdrill: Set ktap_set_plan properly for single protocol test.
The cited commit forgot to update the ktap_set_plan call.
ktap_set_plan sets the number of tests (KSFT_NUM_TESTS), which must match the number of executed tests (KTAP_CNT_PASS + KTAP_CNT_SKIP + KTAP_CNT_XFAIL) in ktap_finished.
Otherwise, the selftest exit()s with 1.
Let's adjust KSFT_NUM_TESTS based on supported protocols.
While at it, misalignment is fixed up.
--- tools/testing/selftests/net/packetdrill/ksft_runner.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/packetdrill/ksft_runner.sh +2 -2
@@ -48,11 +48,11 @@ 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 \ - && ktap_test_pass $ip_version || $failfunc $ip_version + && ktap_test_pass $ip_version || $failfunc $ip_version done ktap_finished
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 2/13 selftest: packetdrill: Require explicit setsockopt(TCP_FASTOPEN).
In reply to Kuniyuki IwashimaTo enable TCP Fast Open on a server, net.ipv4.tcp_fastopen must have 0x2 (TFO_SERVER_ENABLE), and we need to do either
1. Call setsockopt(TCP_FASTOPEN) for the socket
2. Set 0x400 (TFO_SERVER_WO_SOCKOPT1) additionally to net.ipv4.tcp_fastopen
The default.sh sets 0x70403 so that each test does not need setsockopt(). (0x1 is TFO_CLIENT_ENABLE, and 0x70000 is ...???)
However, some tests overwrite net.ipv4.tcp_fastopen without TFO_SERVER_WO_SOCKOPT1 and forgot setsockopt(TCP_FASTOPEN).
For example, pure-syn-data.pkt [0] tests non-TFO servers unintentionally, except in the first scenario.
To prevent such an accident, let's require explicit setsockopt().
TFO_CLIENT_ENABLE is necessary for
tcp_syscall_bad_arg_fastopen-invalid-buf-ptr.pkt.
--- tools/testing/selftests/net/packetdrill/defaults.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/packetdrill/defaults.sh +1 -1
@@ -51,7 +51,7 @@ 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 sysctl -q net.ipv4.tcp_fastopen_key=a1a1a1a1-b2b2b2b2-c3c3c3c3-d4d4d4d4 sysctl -q net.ipv4.tcp_syncookies=1
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 3/13 selftest: packetdrill: Define common TCP Fast Open cookie.
In reply to Kuniyuki IwashimaTCP Fast Open cookie is generated in __tcp_fastopen_cookie_gen_cipher().
The cookie value is generated from src/dst IPs and a key configured by setsockopt(TCP_FASTOPEN_KEY) or net.ipv4.tcp_fastopen_key.
The default.sh sets net.ipv4.tcp_fastopen_key, and the original packetdrill defines the corresponding cookie as TFO_COOKIE in run_all.py. [0]
Then, each test does not need to care about the value, and we can easily update TFO_COOKIE in case __tcp_fastopen_cookie_gen_cipher() changes the algorithm.
However, some tests use the bare hex value for specific IPv4 addresses and do not support IPv6.
Let's define the same TFO_COOKIE in ksft_runner.sh.
We will replace such bare hex values with TFO_COOKIE except for a single test for setsockopt(TCP_FASTOPEN_KEY).
--- tools/testing/selftests/net/packetdrill/defaults.sh | 1 + tools/testing/selftests/net/packetdrill/ksft_runner.sh | 2 ++ 2 files changed, 3 insertions(+)
tools/testing/selftests/net/packetdrill/defaults.sh +1 -0
@@ -52,6 +52,7 @@ 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=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
tools/testing/selftests/net/packetdrill/ksft_runner.sh +2 -0
@@ -9,6 +9,7 @@ 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 CMSG_LEVEL_IP=SOL_IP -D CMSG_TYPE_RECVERR=IP_RECVERR" [ipv6]="--ip_version=ipv6
@@ -16,6 +17,7 @@ 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 CMSG_LEVEL_IP=SOL_IPV6 -D CMSG_TYPE_RECVERR=IPV6_RECVERR" )
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
Re: [PATCH v2 net-next 03/13] selftest: packetdrill: Define common TCP Fast Open cookie.
Quoted 7 lines · Kuniyuki Iwashima
TCP Fast Open cookie is generated in
__tcp_fastopen_cookie_gen_cipher().The cookie value is generated from src/dst IPs and a key configured by
setsockopt(TCP_FASTOPEN_KEY)or net.ipv4.tcp_fastopen_key.The
default.shsets net.ipv4.tcp_fastopen_key, and the original packetdrill defines the corresponding cookie asTFO_COOKIEinrun_all.py. [0]
tiny, not reason for respin: no link [0].
Quoted 13 lines
Then, each test does not need to care about the value, and we can easily update
TFO_COOKIEin case__tcp_fastopen_cookie_gen_cipher()changes the algorithm.However, some tests use the bare hex value for specific IPv4 addresses and do not support IPv6.
Let's define the same
TFO_COOKIEinksft_runner.sh.We will replace such bare hex values with
TFO_COOKIEexcept for a single test forsetsockopt(TCP_FASTOPEN_KEY).Signed-off-by Kuniyuki Iwashima <[email protected]>
Re: [PATCH v2 net-next 03/13] selftest: packetdrill: Define common TCP Fast Open cookie.
Quoted 11 lines · Willem de Bruijn
Quoted 7 lines · Kuniyuki Iwashima
TCP Fast Open cookie is generated in
__tcp_fastopen_cookie_gen_cipher().The cookie value is generated from src/dst IPs and a key configured by
setsockopt(TCP_FASTOPEN_KEY)or net.ipv4.tcp_fastopen_key.The
default.shsets net.ipv4.tcp_fastopen_key, and the original packetdrill defines the corresponding cookie asTFO_COOKIEinrun_all.py. [0]tiny, not reason for respin: no link [0].
Oops, the link was
#[0]
Thanks!
Quoted 14 lines
Quoted 14 lines
Then, each test does not need to care about the value, and we can easily update
TFO_COOKIEin case__tcp_fastopen_cookie_gen_cipher()changes the algorithm.However, some tests use the bare hex value for specific IPv4 addresses and do not support IPv6.
Let's define the same
TFO_COOKIEinksft_runner.sh.We will replace such bare hex values with
TFO_COOKIEexcept for a single test forsetsockopt(TCP_FASTOPEN_KEY).Signed-off-by Kuniyuki Iwashima <[email protected]>
PATCH v2 4/13 selftest: packetdrill: Import TFO server basic tests.
In reply to Kuniyuki IwashimaThis 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.
--- ..._fastopen_server_basic-cookie-not-reqd.pkt | 32 ++++++++++++ ...fastopen_server_basic-non-tfo-listener.pkt | 26 ++++++++++ ...cp_fastopen_server_basic-pure-syn-data.pkt | 50 +++++++++++++++++++ .../tcp_fastopen_server_basic-rw.pkt | 23 +++++++++ ...tcp_fastopen_server_basic-zero-payload.pkt | 26 ++++++++++ 5 files changed, 157 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-cookie-not-reqd.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-non-tfo-listener.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-pure-syn-data.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-rw.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-zero-payload.pkt
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-cookie-not-reqd.pkt new file +32 -0
@@ -0,0 +1,32 @@ +// 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
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-non-tfo-listener.pkt new file +26 -0
@@ -0,0 +1,26 @@ +// 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
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-pure-syn-data.pkt new file +50 -0
50 lines not on this page · raw message
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-rw.pkt new file +23 -0
@@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Basic TFO server test +// +// Test TFO server with SYN that has TFO cookie and data. + +`./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 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 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 + +0 write(4, ..., 100) = 100 + +0 > P. 1:101(100) ack 11
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-zero-payload.pkt new file +26 -0
@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Basic TFO server test +// +// Test zero-payload packet w/ valid TFO cookie - a TFO socket will +// still be created and accepted but read() will not return until a +// later pkt with 10 byte. + +`./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 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0 + + +0 < S 0:0(0) win 32792 <mss 1460,sackOK,nop,nop,FO TFO_COOKIE,nop,nop> + +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK> + +0 accept(3, ..., ...) = 4 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) == 0, tcpi_options }% + +// A TFO socket is created and is writable. + +0 write(4, ..., 100) = 100 + +0 > P. 1:101(100) ack 1 + +0...0.300 read(4, ..., 512) = 10 + +.3 < P. 1:11(10) ack 1 win 5840
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 5/13 selftest: packetdrill: Add test for TFO_SERVER_WO_SOCKOPT1.
In reply to Kuniyuki IwashimaTFO_SERVER_WO_SOCKOPT1 is no longer enabled by default, and each server test requires setsockopt(TCP_FASTOPEN).
Let's add a basic test for TFO_SERVER_WO_SOCKOPT1.
--- ...cp_fastopen_server_basic-no-setsockopt.pkt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-no-setsockopt.pkt
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-no-setsockopt.pkt new file +21 -0
@@ -0,0 +1,21 @@ +// 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
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 6/13 selftest: packetdrill: Add test for experimental option.
In reply to Kuniyuki IwashimaThe only difference between non-experimental vs experimental TFO option handling is SYN+ACK generation.
When tcp_parse_fastopen_option() parses a TFO option, it sets tcp_fastopen_cookie.exp to false if the option number is 34, and true if 255.
The value is carried to tcp_options_write() to generate a TFO option with the same option number.
Other than that, all the TFO handling is the same and the kernel must generate the same cookie regardless of the option number.
Let's add a test for the handling so that we can consolidate fastopen/server/ tests and fastopen/server/opt34 tests.
--- ...cp_fastopen_server_experimental_option.pkt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_experimental_option.pkt
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_experimental_option.pkt new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Test the Experimental Option +// +// SYN w/ FOEXP w/o cookie must generates SYN+ACK w/ FOEXP +// w/ a valid cookie, and the cookie must be the same one +// with one generated by IANA FO + +`./defaults.sh` + +// Request a TFO cookie by Experimental Option +// This must generate the same TFO_COOKIE + 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 + + +0 < S 0:10(10) win 32792 <mss 1460,sackOK,nop,nop,FOEXP> + +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,FOEXP TFO_COOKIE> + + +0 close(3) = 0 + +// Test if FOEXP with a valid cookie creates a TFO socket + 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 + + +0 < S 0:10(10) win 32792 <mss 1460,sackOK,nop,nop,FOEXP TFO_COOKIE> + +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
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 7/13 selftest: packetdrill: Import opt34/fin-close-socket.pkt.
In reply to Kuniyuki IwashimaThis imports the non-experimental version of fin-close-socket.pkt.
This file tests the scenario where a TFO child socket's state transitions from SYN_RECV to CLOSE_WAIT before accept()ed.
--- .../tcp_fastopen_server_fin-close-socket.pkt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_fin-close-socket.pkt
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_fin-close-socket.pkt new file +30 -0
@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Send a FIN pkt with the ACK bit to a TFO socket. +// The socket will go to TCP_CLOSE_WAIT state and data can be +// read until the socket is closed, at which time a FIN will be sent. + +`./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 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 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> + +// FIN is acked and the socket goes to TCP_CLOSE_WAIT state +// in tcp_fin() called from tcp_data_queue(). + +0 < F. 11:11(0) ack 1 win 32792 + +0 > . 1:1(0) ack 12 + + +0 accept(3, ..., ...) = 4 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) != 0, tcpi_options }% + +0 %{ assert tcpi_state == TCP_CLOSE_WAIT, tcpi_state }% + + +0 read(4, ..., 512) = 10 + +0 close(4) = 0 + +0 > F. 1:1(0) ack 12 + * > F. 1:1(0) ack 12
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 8/13 selftest: packetdrill: Import opt34/icmp-before-accept.pkt.
In reply to Kuniyuki IwashimaThis imports the non-experimental version of icmp-before-accept.pkt.
This file tests the scenario where an ICMP unreachable packet for a not-yet-accept()ed socket changes its state to TCP_CLOSE, but the SYN data must be read without error, and the following read() returns EHOSTUNREACH.
Note that this test support only IPv4 as icmp is used.
--- ...tcp_fastopen_server_icmp-before-accept.pkt | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_icmp-before-accept.pkt
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_icmp-before-accept.pkt new file +49 -0
@@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Send an ICMP host_unreachable pkt to a pending SYN_RECV req. +// +// If it's a TFO req, the ICMP error will cause it to switch +// to TCP_CLOSE state but remains in the acceptor queue. + +--ip_version=ipv4 + +`./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 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 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> + +// Out-of-window icmp is ignored but accounted. + +0 `nstat > /dev/null` + +0 < icmp unreachable [5000:6000(1000)] + +0 `nstat | grep TcpExtOutOfWindowIcmps > /dev/null` + +// Valid ICMP unreach. + +0 < icmp unreachable host_unreachable [0:10(10)] + +// Unlike the non-TFO case, the req is still there to be accepted. + +0 accept(3, ..., ...) = 4 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) != 0, tcpi_options }% + +// tcp_done_with_error() in tcp_v4_err() sets sk->sk_state +// to TCP_CLOSE + +0 %{ assert tcpi_state == TCP_CLOSE, tcpi_state }% + +// The 1st read will succeed and return the data in SYN + +0 read(4, ..., 512) = 10 + +// The 2nd read will fail. + +0 read(4, ..., 512) = -1 EHOSTUNREACH (No route to host) + +// But is no longer writable because it's in TCP_CLOSE state. + +0 write(4, ..., 100) = -1 EPIPE (Broken Pipe) + +// inbound pkt will trigger RST because the socket has been moved +// off the TCP hash tables. + +0 < . 1:1(0) ack 1 win 32792 + +0 > R 1:1(0)
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 9/13 selftest: packetdrill: Import opt34/reset-* tests.
In reply to Kuniyuki IwashimaThis imports the non-experimental version of opt34/reset-*.pkt.
| Child | RST | sk_err |
---------------------------------+---------+-------------------------------+---------+
reset-after-accept.pkt | TFO | after accept(), SYN_RECV | read() | reset-close-with-unread-data.pkt | TFO | after accept(), SYN_RECV | write() | reset-before-accept.pkt | TFO | before accept(), SYN_RECV | read() | reset-non-tfo-socket.pkt | non-TFO | before accept(), ESTABLISHED | write() |
The first 3 files test scenarios where a SYN_RECV socket receives RST before/after accept() and data in SYN must be read() without error, but the following read() or fist write() will return ECONNRESET.
The last test is similar but with non-TFO socket.
--- ...tcp_fastopen_server_reset-after-accept.pkt | 37 +++++++++++++++++++ ...cp_fastopen_server_reset-before-accept.pkt | 32 ++++++++++++++++ ...en_server_reset-close-with-unread-data.pkt | 32 ++++++++++++++++ ...p_fastopen_server_reset-non-tfo-socket.pkt | 37 +++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-after-accept.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-before-accept.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-close-with-unread-data.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-non-tfo-socket.pkt
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-after-accept.pkt new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Send a RST to a TFO socket after it has been accepted. +// +// First read() will return all the data and this is consistent +// with the non-TFO case. Second read will return -1 + +`./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 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 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 %{ assert tcpi_state == TCP_SYN_RECV, tcpi_state }% + +// 1st read will return the data from SYN. +// tcp_reset() sets sk->sk_err to ECONNRESET for SYN_RECV. + +0 < R. 11:11(0) win 32792 + +0 %{ assert tcpi_state == TCP_CLOSE, tcpi_state }% + +// This one w/o ACK bit will cause the same effect. +// +0 < R 11:11(0) win 32792 +// See Step 2 in tcp_validate_incoming(). + +// found_ok_skb in tcp_recvmsg_locked() + +0 read(4, ..., 512) = 10 + +// !copied && sk->sk_err -> sock_error(sk) + +0 read(4, ..., 512) = -1 ECONNRESET (Connection reset by peer) + +0 close(4) = 0
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-before-accept.pkt new file +32 -0
@@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Send a RST to a TFO socket before it is accepted. +// +// The socket won't go away and after it's accepted the data +// in the SYN pkt can still be read. But that's about all that +// the acceptor can do with the socket. + +`./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 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0 + + +0 < S 0:10(10) win 32792 <mss 1460,sackOK,nop,nop,nop,wscale 7,FO TFO_COOKIE,nop,nop> + +0 > S. 0:0(0) ack 11 <mss 1460,nop,nop,sackOK,nop,wscale 8> + +// 1st read will return the data from SYN. + +0 < R. 11:11(0) win 257 + +// This one w/o ACK bit will cause the same effect. +// +0 < R 11:11(0) win 257 + + +0 accept(3, ..., ...) = 4 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) != 0, tcpi_options }% + +0 %{ assert tcpi_state == TCP_CLOSE, tcpi_state }% + + +0 read(4, ..., 512) = 10 + +0 read(4, ..., 512) = -1 ECONNRESET (Connection reset by peer) + +0 close(4) = 0
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-close-with-unread-data.pkt new file +32 -0
@@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Send a RST to a TFO socket after it is accepted. +// +// The socket will change to TCP_CLOSE state with pending data so +// write() will fail. Pending data can be still be read and close() +// won't trigger RST if data is not read +// +// 565b7b2d2e63 ("tcp: do not send reset to already closed sockets") +// https://lore.kernel.org/netdev/[email protected]/ + +`./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 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 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 %{ assert tcpi_state == TCP_SYN_RECV, tcpi_state }% + +// tcp_done() sets sk->sk_state to TCP_CLOSE and clears tp->fastopen_rsk + +0 < R. 11:11(0) win 32792 + +0 %{ assert tcpi_state == TCP_CLOSE, tcpi_state }% + + +0 write(4, ..., 100) = -1 ECONNRESET(Connection reset by peer) + +0 close(4) = 0
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-non-tfo-socket.pkt new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Send a RST to a fully established socket with pending data before +// it is accepted. +// +// The socket with pending data won't go away and can still be accepted +// with data read. But it will be in TCP_CLOSE state. + +`./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 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0 + +// Invalid cookie, so accept() fails. + +0 < S 0:10(10) win 32792 <mss 1460,sackOK,nop,nop,FO aaaaaaaaaaaaaaaa,nop,nop> + +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK, FO TFO_COOKIE,nop,nop> + + +0 accept(3, ..., ...) = -1 EAGAIN (Resource temporarily unavailable) + +// Complete 3WHS and send data and RST + +0 < . 1:1(0) ack 1 win 32792 + +0 < . 1:11(10) ack 1 win 32792 + +0 < R. 11:11(0) win 32792 + +// A valid reset won't make the fully-established socket go away. +// It's just that the acceptor will get a dead, unusable socket +// in TCP_CLOSE state. + +0 accept(3, ..., ...) = 4 + +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) == 0, tcpi_options }% + +0 %{ assert tcpi_state == TCP_CLOSE, tcpi_state }% + + +0 write(4, ..., 100) = -1 ECONNRESET(Connection reset by peer) + +0 read(4, ..., 512) = 10 + +0 read(4, ..., 512) = 0
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 10/13 selftest: packetdrill: Import opt34/*-trigger-rst.pkt.
In reply to Kuniyuki IwashimaThis imports the non-experimental version of opt34/*-trigger-rst.pkt.
| accept() | SYN data |
-----------------------------------+----------+----------+
listener-closed-trigger-rst.pkt | no | unread | unread-data-closed-trigger-rst.pkt | yes | unread |
Both files test that close()ing a SYN_RECV socket with unread SYN data triggers RST.
The files are renamed to have the common prefix, trigger-rst.
--- ...pen_server_trigger-rst-listener-closed.pkt | 21 +++++++++++++++++ ..._server_trigger-rst-unread-data-closed.pkt | 23 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_trigger-rst-listener-closed.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_trigger-rst-unread-data-closed.pkt
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_trigger-rst-listener-closed.pkt new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Close a listener socket with pending TFO child. +// This will trigger RST pkt to go out. + +`./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 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 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> + +// RST pkt is generated for each not-yet-accepted TFO child. +// inet_csk_listen_stop() -> inet_child_forget() -> tcp_disconnect() +// -> tcp_need_reset() is true for SYN_RECV + +0 close(3) = 0 + +0 > R. 1:1(0) ack 11
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_trigger-rst-unread-data-closed.pkt new file +23 -0
@@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Close a TFO socket with unread data. +// This will trigger a RST pkt. + +`./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 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 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 %{ assert tcpi_state == TCP_SYN_RECV, tcpi_state }% + +// data_was_unread == true in __tcp_close() + +0 close(4) = 0 + +0 > R. 1:1(0) ack 11
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 11/13 selftest: packetdrill: Refine tcp_fastopen_server_reset-after-disconnect.pkt.
In reply to Kuniyuki IwashimaThese changes are applied to follow the imported packetdrill tests.
* Call setsockopt(TCP_FASTOPEN)
* Remove unnecessary accept() delay
* Add assertion for TCP states
* Rename to tcp_fastopen_server_trigger-rst-reconnect.pkt.
---
...t => tcp_fastopen_server_trigger-rst-reconnect.pkt} | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
rename tools/testing/selftests/net/packetdrill/{tcp_fastopen_server_reset-after-disconnect.pkt => tcp_fastopen_server_trigger-rst-reconnect.pkt} (66%)tools/testing/selftests/net/packetdrill/tcp_fastopen_server_trigger-rst-reconnect.pkt renamed from tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-after-disconnect.pkt +7 -3
@@ -1,26 +1,30 @@ // SPDX-License-Identifier: GPL-2.0 `./defaults.sh - ./set_sysctls.py /proc/sys/net/ipv4/tcp_fastopen=0x602 /proc/sys/net/ipv4/tcp_timestamps=0` + ./set_sysctls.py /proc/sys/net/ipv4/tcp_timestamps=0` 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 - +0 < S 0:10(10) win 32792 <mss 1460,nop,nop,sackOK> + +0 < S 0:10(10) win 32792 <mss 1460,nop,nop,sackOK,nop,nop,FO TFO_COOKIE> +0 > S. 0:0(0) ack 11 win 65535 <mss 1460,nop,nop,sackOK> // sk->sk_state is TCP_SYN_RECV - +.1 accept(3, ..., ...) = 4 + +0 accept(3, ..., ...) = 4 + +0 %{ assert tcpi_state == TCP_SYN_RECV, tcpi_state }% // tcp_disconnect() sets sk->sk_state to TCP_CLOSE +0 connect(4, AF_UNSPEC, ...) = 0 +0 > R. 1:1(0) ack 11 win 65535 + +0 %{ assert tcpi_state == TCP_CLOSE, tcpi_state }% // connect() sets sk->sk_state to TCP_SYN_SENT +0 fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0 +0 connect(4, ..., ...) = -1 EINPROGRESS (Operation is now in progress) +0 > S 0:0(0) win 65535 <mss 1460,nop,nop,sackOK,nop,wscale 8> + +0 %{ assert tcpi_state == TCP_SYN_SENT, tcpi_state }% // tp->fastopen_rsk must be NULL +1 > S 0:0(0) win 65535 <mss 1460,nop,nop,sackOK,nop,wscale 8>
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 12/13 selftest: packetdrill: Import sockopt-fastopen-key.pkt
In reply to Kuniyuki Iwashimasockopt-fastopen-key.pkt does not have the non-experimental version, so the Experimental version is converted, FOEXP -> FO.
The test sets net.ipv4.tcp_fastopen_key=0-0-0-0 and instead sets another key via setsockopt(TCP_FASTOPEN_KEY).
The first listener generates a valid cookie in response to TFO option without cookie, and the second listner creates a TFO socket using the valid cookie.
TCP_FASTOPEN_KEY is adjusted to use the common key in default.sh so that we can use TFO_COOKIE and support dualstack. Similarly, TFO_COOKIE_ZERO for the 0-0-0-0 key is defined.
--- .../selftests/net/packetdrill/ksft_runner.sh | 2 + ...p_fastopen_server_sockopt-fastopen-key.pkt | 74 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_sockopt-fastopen-key.pkt
tools/testing/selftests/net/packetdrill/ksft_runner.sh +2 -0
@@ -10,6 +10,7 @@ declare -A ip_args=( --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
@@ -18,6 +19,7 @@ declare -A ip_args=( --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" )
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_sockopt-fastopen-key.pkt new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
PATCH v2 13/13 selftest: packetdrill: Import client-ack-dropped-then-recovery-ms-timestamps.pkt
In reply to Kuniyuki IwashimaThis also does not have the non-experimental version, so converted to FO.
The comment in .pkt explains the detailed scenario.
--- ...ck-dropped-then-recovery-ms-timestamps.pkt | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_client-ack-dropped-then-recovery-ms-timestamps.pkt
tools/testing/selftests/net/packetdrill/tcp_fastopen_server_client-ack-dropped-then-recovery-ms-timestamps.pkt new file +46 -0
@@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// A reproducer case for a TFO SYNACK RTO undo bug in: +// 794200d66273 ("tcp: undo cwnd on Fast Open spurious SYNACK retransmit") +// This sequence that tickles this bug is: +// - Fast Open server receives TFO SYN with data, sends SYNACK +// - (client receives SYNACK and sends ACK, but ACK is lost) +// - server app sends some data packets +// - (N of the first data packets are lost) +// - server receives client ACK that has a TS ECR matching first SYNACK, +// and also SACKs suggesting the first N data packets were lost +// - server performs undo of SYNACK RTO, then immediately enters recovery +// - buggy behavior in 794200d66273 then performed an undo that caused +// the connection to be in a bad state, in CA_Open with retrans_out != 0 + +// Check that outbound TS Val ticks are as we would expect with 1000 usec per +// timestamp tick: +--tcp_ts_tick_usecs=1000 + +`./defaults.sh` + +// Initialize connection + 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 + +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 + +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0 + +0 bind(3, ..., ...) = 0 + +0 listen(3, 1) = 0 + + +0 < S 0:1000(1000) win 65535 <mss 1012,sackOK,TS val 1000 ecr 0,wscale 7,nop,nop,nop,FO TFO_COOKIE> + +0 > S. 0:0(0) ack 1001 <mss 1460,sackOK,TS val 2000 ecr 1000,nop,wscale 8> + +0 accept(3, ..., ...) = 4 + +// Application writes more data + +.010 write(4, ..., 10000) = 10000 + +0 > P. 1:5001(5000) ack 1001 <nop,nop,TS val 2010 ecr 1000> + +0 > P. 5001:10001(5000) ack 1001 <nop,nop,TS val 2010 ecr 1000> + +0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }% + + +0 < . 1001:1001(0) ack 1 win 257 <TS val 1010 ecr 2000,sack 2001:5001> + +0 > P. 1:2001(2000) ack 1001 <nop,nop,TS val 2010 ecr 1010> + +0 %{ assert tcpi_ca_state == TCP_CA_Recovery, tcpi_ca_state }% + +0 %{ assert tcpi_snd_cwnd == 7, tcpi_snd_cwnd }% + + +0 < . 1001:1001(0) ack 1 win 257 <TS val 1011 ecr 2000,sack 2001:6001> + +0 %{ assert tcpi_ca_state == TCP_CA_Recovery, tcpi_ca_state }% + +0 %{ assert tcpi_snd_cwnd == 7, tcpi_snd_cwnd }%
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
Quoted 106 lines · Kuniyuki Iwashima
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.pktThe 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.pktFor the imported tests, these common changes are applied.
* Add SPDX header
* Adjust path todefault.sh
* Adjust sysctl w/set_sysctls.py
* UseTFO_COOKIEinstead of a raw hex value
* UseSOCK_NONBLOCKforsocket()not to blockaccept()
* Add assertions for TCP state if commented
* Remove unnecessary delay (e.g. +0.1setsockopt(SO_REUSEADDR), etc)With this series, except for simple{1,2,3}.pkt, we can remove TFO server tests in google/packetdrill.
Changes:
v2:
* Add patch 1 for icmp-before-accept.pkt.
* Patch 2:
* KeepTFO_CLIENT_ENABLEfor tcp_syscall_bad_arg_fastopen-invalid-buf-ptr.pkt.v1: https://lore.kernel.org/netdev/[email protected]/
Kuniyuki Iwashima (13):
selftest: packetdrill: Setktap_set_planproperly for single protocol
test.
selftest: packetdrill: Require explicitsetsockopt(TCP_FASTOPEN).
selftest: packetdrill: Define common TCP Fast Open cookie.
selftest: packetdrill: Import TFO server basic tests.
selftest: packetdrill: Add test forTFO_SERVER_WO_SOCKOPT1.
selftest: packetdrill: Add test for experimental option.
selftest: packetdrill: Import opt34/fin-close-socket.pkt.
selftest: packetdrill: Import opt34/icmp-before-accept.pkt.
selftest: packetdrill: Import opt34/reset-* tests.
selftest: packetdrill: Import opt34/*-trigger-rst.pkt.
selftest: packetdrill: Refine
tcp_fastopen_server_reset-after-disconnect.pkt.
selftest: packetdrill: Import sockopt-fastopen-key.pkt
selftest: packetdrill: Import
client-ack-dropped-then-recovery-ms-timestamps.pkt.../selftests/net/packetdrill/defaults.sh | 3 +- .../selftests/net/packetdrill/ksft_runner.sh | 8 +- ..._fastopen_server_basic-cookie-not-reqd.pkt | 32 ++++++++ ...cp_fastopen_server_basic-no-setsockopt.pkt | 21 ++++++ ...fastopen_server_basic-non-tfo-listener.pkt | 26 +++++++ ...cp_fastopen_server_basic-pure-syn-data.pkt | 50 +++++++++++++ .../tcp_fastopen_server_basic-rw.pkt | 23 ++++++ ...tcp_fastopen_server_basic-zero-payload.pkt | 26 +++++++ ...ck-dropped-then-recovery-ms-timestamps.pkt | 46 ++++++++++++ ...cp_fastopen_server_experimental_option.pkt | 37 ++++++++++ .../tcp_fastopen_server_fin-close-socket.pkt | 30 ++++++++ ...tcp_fastopen_server_icmp-before-accept.pkt | 49 ++++++++++++ ...tcp_fastopen_server_reset-after-accept.pkt | 37 ++++++++++ ...cp_fastopen_server_reset-before-accept.pkt | 32 ++++++++ ...en_server_reset-close-with-unread-data.pkt | 32 ++++++++ ...p_fastopen_server_reset-non-tfo-socket.pkt | 37 ++++++++++ ...p_fastopen_server_sockopt-fastopen-key.pkt | 74 +++++++++++++++++++ ...pen_server_trigger-rst-listener-closed.pkt | 21 ++++++ ...fastopen_server_trigger-rst-reconnect.pkt} | 10 ++- ..._server_trigger-rst-unread-data-closed.pkt | 23 ++++++ 20 files changed, 611 insertions(+), 6 deletions(-) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-cookie-not-reqd.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-no-setsockopt.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-non-tfo-listener.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-pure-syn-data.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-rw.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_basic-zero-payload.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_client-ack-dropped-then-recovery-ms-timestamps.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_experimental_option.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_fin-close-socket.pkt create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_icmp-before-accept.pkt
Quoted 8 lines
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-after-accept.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-before-accept.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-close-with-unread-data.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-non-tfo-socket.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_sockopt-fastopen-key.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_trigger-rst-listener-closed.pkt
rename tools/testing/selftests/net/packetdrill/{tcp_fastopen_server_reset-after-disconnect.pkt => tcp_fastopen_server_trigger-rst-reconnect.pkt} (66%)
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_fastopen_server_trigger-rst-unread-data-closed.pktThis was not just a trivial import from github.com/google/packetdrill.
Thanks for cleaning up the tests and converting the experimental-only variants to the standard FO mode, Kuniyuki.
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Sat, 27 Sep 2025 21:29:38 +0000 you wrote:
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.[...]
Here is the summary with links:
- [v2,net-next,01/13] selftest: packetdrill: Set ktap_set_plan properly for single protocol test.
https://git.kernel.org/netdev/net-next/c/70dd4775db7f - [v2,net-next,02/13] selftest: packetdrill: Require explicit setsockopt(TCP_FASTOPEN). https://git.kernel.org/netdev/net-next/c/261cb8b12376 - [v2,net-next,03/13] selftest: packetdrill: Define common TCP Fast Open cookie. https://git.kernel.org/netdev/net-next/c/97b3b8306f78 - [v2,net-next,04/13] selftest: packetdrill: Import TFO server basic tests. https://git.kernel.org/netdev/net-next/c/0b8f164eb264 - [v2,net-next,05/13] selftest: packetdrill: Add test for TFO_SERVER_WO_SOCKOPT1. https://git.kernel.org/netdev/net-next/c/399e0a7ed930 - [v2,net-next,06/13] selftest: packetdrill: Add test for experimental option. https://git.kernel.org/netdev/net-next/c/e57b3933abce - [v2,net-next,07/13] selftest: packetdrill: Import opt34/fin-close-socket.pkt. https://git.kernel.org/netdev/net-next/c/5ed080f85a33 - [v2,net-next,08/13] selftest: packetdrill: Import opt34/icmp-before-accept.pkt. https://git.kernel.org/netdev/net-next/c/a8b1750e68f5 - [v2,net-next,09/13] selftest: packetdrill: Import opt34/reset-* tests. https://git.kernel.org/netdev/net-next/c/5920f154e144 - [v2,net-next,10/13] selftest: packetdrill: Import opt34/*-trigger-rst.pkt. https://git.kernel.org/netdev/net-next/c/21f7fb31aef8 - [v2,net-next,11/13] selftest: packetdrill: Refine tcp_fastopen_server_reset-after-disconnect.pkt. https://git.kernel.org/netdev/net-next/c/be90c7b3d5c8 - [v2,net-next,12/13] selftest: packetdrill: Import sockopt-fastopen-key.pkt https://git.kernel.org/netdev/net-next/c/05b9f505fbe7 - [v2,net-next,13/13] selftest: packetdrill: Import client-ack-dropped-then-recovery-ms-timestamps.pkt https://git.kernel.org/netdev/net-next/c/9b62d53cc8b4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html