Skip to contentSkip to conversation

selftests/net: packetdrill: netns and two imports

PATCH Applied Willem de Bruijn 4 participants 9 messages Sep 12, 2024 – Sep 16, 2024

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

v2 cover selftests/net: packetdrill: netns and two imports

From: Willem de Bruijn <[email protected]>

1/3: run in nets, as discussed, and add missing CONFIGs 2/3: import tcp/zerocopy
3/3: import tcp/slow_start

Willem de Bruijn (3):
selftests/net: packetdrill: run in netns and expand config selftests/net: packetdrill: import tcp/zerocopy selftests/net: packetdrill: import tcp/slow_start

 .../selftests/net/packetdrill/Makefile        |   1 +
 .../testing/selftests/net/packetdrill/config  |   6 +
 .../selftests/net/packetdrill/ksft_runner.sh  |   4 +-
 .../selftests/net/packetdrill/set_sysctls.py  |  38 ++++++
 ...tcp_slow_start_slow-start-ack-per-1pkt.pkt |  56 +++++++++
 ...tart_slow-start-ack-per-2pkt-send-5pkt.pkt |  33 +++++
 ...tart_slow-start-ack-per-2pkt-send-6pkt.pkt |  34 +++++
 ...tcp_slow_start_slow-start-ack-per-2pkt.pkt |  42 +++++++
 ...tcp_slow_start_slow-start-ack-per-4pkt.pkt |  35 ++++++
 .../tcp_slow_start_slow-start-after-idle.pkt  |  39 ++++++
 ...slow_start_slow-start-after-win-update.pkt |  50 ++++++++
 ...t_slow-start-app-limited-9-packets-out.pkt |  38 ++++++
 .../tcp_slow_start_slow-start-app-limited.pkt |  36 ++++++
 ..._slow_start_slow-start-fq-ack-per-2pkt.pkt |  63 ++++++++++
 .../net/packetdrill/tcp_zerocopy_basic.pkt    |  55 ++++++++
 .../net/packetdrill/tcp_zerocopy_batch.pkt    |  41 ++++++
 .../net/packetdrill/tcp_zerocopy_client.pkt   |  30 +++++
 .../net/packetdrill/tcp_zerocopy_closed.pkt   |  44 +++++++
 .../packetdrill/tcp_zerocopy_epoll_edge.pkt   |  61 +++++++++
 .../tcp_zerocopy_epoll_exclusive.pkt          |  63 ++++++++++
 .../tcp_zerocopy_epoll_oneshot.pkt            |  66 ++++++++++
 .../tcp_zerocopy_fastopen-client.pkt          |  56 +++++++++
 .../tcp_zerocopy_fastopen-server.pkt          |  44 +++++++
 .../net/packetdrill/tcp_zerocopy_maxfrags.pkt | 118 ++++++++++++++++++
 .../net/packetdrill/tcp_zerocopy_small.pkt    |  57 +++++++++
 25 files changed, 1108 insertions(+), 2 deletions(-)
 create mode 100755 tools/testing/selftests/net/packetdrill/set_sysctls.py
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-1pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-2pkt-send-5pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-2pkt-send-6pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-2pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-4pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-after-idle.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-after-win-update.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-app-limited-9-packets-out.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-app-limited.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-fq-ack-per-2pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_basic.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_batch.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_client.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_closed.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_epoll_edge.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_epoll_exclusive.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_epoll_oneshot.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_fastopen-client.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_fastopen-server.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_maxfrags.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_small.pkt
Signature · 1 line
2.46.0.598.g6f2099f65c-goog
#1 lore raw

PATCH v2 1/3 selftests/net: packetdrill: run in netns and expand config

From: Willem de Bruijn <[email protected]>

Run packetdrill tests inside netns.
They may change system settings, such as sysctl.

Also expand config with a few more needed CONFIGs.

---
 tools/testing/selftests/net/packetdrill/config         | 5 +++++
 tools/testing/selftests/net/packetdrill/ksft_runner.sh | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)
tools/testing/selftests/net/packetdrill/config +5 -0
index 0d402830f18d8..a7877819081f5 100644
@@ -1,5 +1,10 @@
 CONFIG_IPV6=y
+CONFIG_HZ_1000=y
+CONFIG_HZ=1000
+CONFIG_NET_NS=y
 CONFIG_NET_SCH_FIFO=y
 CONFIG_PROC_SYSCTL=y
+CONFIG_SYN_COOKIES=y
+CONFIG_TCP_CONG_CUBIC=y
 CONFIG_TCP_MD5SIG=y
 CONFIG_TUN=y
tools/testing/selftests/net/packetdrill/ksft_runner.sh +2 -2
index 2f62caccbbbc5..7478c0c0c9aac 100755
@@ -33,9 +33,9 @@ fi
 ktap_print_header
 ktap_set_plan 2
 
-packetdrill ${ipv4_args[@]} $(basename $script) > /dev/null \
+unshare -n packetdrill ${ipv4_args[@]} $(basename $script) > /dev/null \
 	&& ktap_test_pass "ipv4" || ktap_test_fail "ipv4"
-packetdrill ${ipv6_args[@]} $(basename $script) > /dev/null \
+unshare -n packetdrill ${ipv6_args[@]} $(basename $script) > /dev/null \
 	&& ktap_test_pass "ipv6" || ktap_test_fail "ipv6"
 
 ktap_finished
Signature · 1 line
2.46.0.598.g6f2099f65c-goog
#2 lore raw

PATCH v2 2/3 selftests/net: packetdrill: import tcp/zerocopy

In reply to Willem de Bruijn

From: Willem de Bruijn <[email protected]>

Same as initial tests, import verbatim from
github.com/google/packetdrill, aside from:

- update source ./defaults.sh path to adjust for flat dir
- add SPDX headers
- remove author statements if any
- drop blank lines at EOF (new)

Also import set_sysctls.py, which many scripts depend on to set sysctls and then restore them later. This is no longer strictly needed for namespacified sysctl. But not all sysctls are namespacified, and doesn't hurt if they are.

---

changes v1->v2:
- add set_sysctls.py to TEST_INCLUDES
- drop blank lines at EOF

---
 .../selftests/net/packetdrill/Makefile        |   1 +
 .../selftests/net/packetdrill/set_sysctls.py  |  38 ++++++
 .../net/packetdrill/tcp_zerocopy_basic.pkt    |  55 ++++++++
 .../net/packetdrill/tcp_zerocopy_batch.pkt    |  41 ++++++
 .../net/packetdrill/tcp_zerocopy_client.pkt   |  30 +++++
 .../net/packetdrill/tcp_zerocopy_closed.pkt   |  44 +++++++
 .../packetdrill/tcp_zerocopy_epoll_edge.pkt   |  61 +++++++++
 .../tcp_zerocopy_epoll_exclusive.pkt          |  63 ++++++++++
 .../tcp_zerocopy_epoll_oneshot.pkt            |  66 ++++++++++
 .../tcp_zerocopy_fastopen-client.pkt          |  56 +++++++++
 .../tcp_zerocopy_fastopen-server.pkt          |  44 +++++++
 .../net/packetdrill/tcp_zerocopy_maxfrags.pkt | 118 ++++++++++++++++++
 .../net/packetdrill/tcp_zerocopy_small.pkt    |  57 +++++++++
 13 files changed, 674 insertions(+)
 create mode 100755 tools/testing/selftests/net/packetdrill/set_sysctls.py
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_basic.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_batch.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_client.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_closed.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_epoll_edge.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_epoll_exclusive.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_epoll_oneshot.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_fastopen-client.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_fastopen-server.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_maxfrags.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_zerocopy_small.pkt
tools/testing/selftests/net/packetdrill/Makefile +1 -0
index 870f7258dc8d7..31cfb666ba8b3 100644
@@ -2,6 +2,7 @@
 
 TEST_INCLUDES := ksft_runner.sh \
 		 defaults.sh \
+		 set_sysctls.py \
 		 ../../kselftest/ktap_helpers.sh
 
 TEST_PROGS := $(wildcard *.pkt)
tools/testing/selftests/net/packetdrill/set_sysctls.py new file +38 -0
new file mode 100755
index 0000000000000..5ddf456ae973a
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""Sets sysctl values and writes a file that restores them.
+
+The arguments are of the form "<proc-file>=<val>" separated by spaces.
+The program first reads the current value of the proc-file and creates
+a shell script named "/tmp/sysctl_restore_${PACKETDRILL_PID}.sh" which
+restores the values when executed. It then sets the new values.
+
+PACKETDRILL_PID is set by packetdrill to the pid of itself, so a .pkt
+file could restore sysctls by running `/tmp/sysctl_restore_${PPID}.sh`
+at the end.
+"""
+
+import os
+import subprocess
+import sys
+
+filename = '/tmp/sysctl_restore_%s.sh' % os.environ['PACKETDRILL_PID']
+
+# Open file for restoring sysctl values
+restore_file = open(filename, 'w')
+print('#!/bin/bash', file=restore_file)
+
+for a in sys.argv[1:]:
+  sysctl = a.split('=')
+  # sysctl[0] contains the proc-file name, sysctl[1] the new value
+
+  # read current value and add restore command to file
+  cur_val = subprocess.check_output(['cat', sysctl[0]], universal_newlines=True)
+  print('echo "%s" > %s' % (cur_val.strip(), sysctl[0]), file=restore_file)
+
+  # set new value
+  cmd = 'echo "%s" > %s' % (sysctl[1], sysctl[0])
+  os.system(cmd)
+
+os.system('chmod u+x %s' % filename)
tools/testing/selftests/net/packetdrill/tcp_zerocopy_basic.pkt new file +55 -0

55 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_zerocopy_batch.pkt new file +41 -0

41 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_zerocopy_client.pkt new file +30 -0
new file mode 100644
index 0000000000000..6509882932e91
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+// Minimal client-side zerocopy test
+
+`./defaults.sh`
+
+    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 4
+   +0 setsockopt(4, SOL_SOCKET, SO_ZEROCOPY, [1], 4) = 0
+   +0...0 connect(4, ..., ...) = 0
+
+   +0 > S 0:0(0) <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8>
+   +0 < S. 0:0(0) ack 1 win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+   +0 > . 1:1(0) ack 1
+
+   +0 send(4, ..., 4000, MSG_ZEROCOPY) = 4000
+   +0 > P. 1:4001(4000) ack 1
+   +0 < . 1:1(0) ack 4001 win 257
+
+   +0 recvmsg(4, {msg_name(...)=...,
+                  msg_iov(1)=[{...,0}],
+                  msg_flags=MSG_ERRQUEUE,
+                  msg_control=[
+                        {cmsg_level=CMSG_LEVEL_IP,
+                         cmsg_type=CMSG_TYPE_RECVERR,
+                         cmsg_data={ee_errno=0,
+                                    ee_origin=SO_EE_ORIGIN_ZEROCOPY,
+                                    ee_type=0,
+                                    ee_code=SO_EE_CODE_ZEROCOPY_COPIED,
+                                    ee_info=0,
+                                    ee_data=0}}
+                   ]}, MSG_ERRQUEUE) = 0
tools/testing/selftests/net/packetdrill/tcp_zerocopy_closed.pkt new file +44 -0

44 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_zerocopy_epoll_edge.pkt new file +61 -0

61 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_zerocopy_epoll_exclusive.pkt new file +63 -0

63 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_zerocopy_epoll_oneshot.pkt new file +66 -0

66 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_zerocopy_fastopen-client.pkt new file +56 -0

56 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_zerocopy_fastopen-server.pkt new file +44 -0

44 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_zerocopy_maxfrags.pkt new file +118 -0

118 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_zerocopy_small.pkt new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
2.46.0.598.g6f2099f65c-goog
#3 lore raw

PATCH v2 3/3 selftests/net: packetdrill: import tcp/slow_start

In reply to Willem de Bruijn

From: Willem de Bruijn <[email protected]>

Same import process as previous tests.

Also add CONFIG_NET_SCH_FQ to config, as one test uses that.

Same test process as previous tests. Both with and without debug mode. Recording the steps once:

make mrproper

vng --build \
        --config tools/testing/selftests/net/packetdrill/config \
        --config kernel/configs/debug.config

vng -v --run . --user root --cpus 4 -- \
make -C tools/testing/selftests TARGETS=net/packetdrill run_tests

---
 .../testing/selftests/net/packetdrill/config  |  1 +
 ...tcp_slow_start_slow-start-ack-per-1pkt.pkt | 56 +++++++++++++++++
 ...tart_slow-start-ack-per-2pkt-send-5pkt.pkt | 33 ++++++++++
 ...tart_slow-start-ack-per-2pkt-send-6pkt.pkt | 34 ++++++++++
 ...tcp_slow_start_slow-start-ack-per-2pkt.pkt | 42 +++++++++++++
 ...tcp_slow_start_slow-start-ack-per-4pkt.pkt | 35 +++++++++++
 .../tcp_slow_start_slow-start-after-idle.pkt  | 39 ++++++++++++
 ...slow_start_slow-start-after-win-update.pkt | 50 +++++++++++++++
 ...t_slow-start-app-limited-9-packets-out.pkt | 38 +++++++++++
 .../tcp_slow_start_slow-start-app-limited.pkt | 36 +++++++++++
 ..._slow_start_slow-start-fq-ack-per-2pkt.pkt | 63 +++++++++++++++++++
 11 files changed, 427 insertions(+)
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-1pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-2pkt-send-5pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-2pkt-send-6pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-2pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-4pkt.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-after-idle.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-after-win-update.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-app-limited-9-packets-out.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-app-limited.pkt
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-fq-ack-per-2pkt.pkt
tools/testing/selftests/net/packetdrill/config +1 -0
index a7877819081f5..0237ed98f3c0d 100644
@@ -3,6 +3,7 @@ CONFIG_HZ_1000=y
 CONFIG_HZ=1000
 CONFIG_NET_NS=y
 CONFIG_NET_SCH_FIFO=y
+CONFIG_NET_SCH_FQ=y
 CONFIG_PROC_SYSCTL=y
 CONFIG_SYN_COOKIES=y
 CONFIG_TCP_CONG_CUBIC=y
tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-1pkt.pkt new file +56 -0

56 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-2pkt-send-5pkt.pkt new file +33 -0
new file mode 100644
index 0000000000000..9212ae1fd0f2f
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test of slow start when an outstanding flight of packets is
+// less than the current cwnd, and not big enough to bump up cwnd.
+//
+// In this variant, the receiver ACKs every other packet,
+// approximating standard delayed ACKs.
+
+// Set up config.
+`./defaults.sh`
+
+    0 socket(..., SOCK_STREAM, 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:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+   +0 < . 1:1(0) ack 1 win 257
+   +0 accept(3, ..., ...) = 4
+
+// Only send 5 packets.
+   +0 write(4, ..., 5000) = 5000
+   +0 > P. 1:5001(5000) ack 1
+   +0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
+
+   +0 < . 1:1(0) ack 2001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 10, 'cwnd=%d' % tcpi_snd_cwnd }%
+
+   +0 < . 1:1(0) ack 4001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 10, 'cwnd=%d' % tcpi_snd_cwnd }%
+
+   +0 < . 1:1(0) ack 5001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 10, 'cwnd=%d' % tcpi_snd_cwnd }%
tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-2pkt-send-6pkt.pkt new file +34 -0
new file mode 100644
index 0000000000000..416c901ddf518
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test of slow start when an outstanding flight of packets is
+// less than the current cwnd, but still big enough that in slow
+// start we want to increase our cwnd a little.
+//
+// In this variant, the receiver ACKs every other packet,
+// approximating standard delayed ACKs.
+
+// Set up config.
+`./defaults.sh`
+
+    0 socket(..., SOCK_STREAM, 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:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+   +0 < . 1:1(0) ack 1 win 257
+   +0 accept(3, ..., ...) = 4
+
+// Only send 6 packets.
+   +0 write(4, ..., 6000) = 6000
+   +0 > P. 1:6001(6000) ack 1
+   +0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
+
+   +0 < . 1:1(0) ack 2001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 12, 'cwnd=%d' % tcpi_snd_cwnd }%
+
+   +0 < . 1:1(0) ack 4001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 12, 'cwnd=%d' % tcpi_snd_cwnd }%
+
+   +0 < . 1:1(0) ack 6001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 12, 'cwnd=%d' % tcpi_snd_cwnd }%
tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-2pkt.pkt new file +42 -0

42 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-ack-per-4pkt.pkt new file +35 -0
new file mode 100644
index 0000000000000..065fae9e9abd7
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test of slow start when not application-limited, so that
+// the cwnd continues to grow.
+// In this variant, the receiver sends one ACK per 4 packets.
+
+// Set up config. To keep things simple, disable the
+// mechanism that defers sending in order to send bigger TSO packets.
+`./defaults.sh
+sysctl -q net.ipv4.tcp_tso_win_divisor=100`
+
+    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+   +0 bind(3, ..., ...) = 0
+   +0 listen(3, 1) = 0
+
+  +.1 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+  +.1 < . 1:1(0) ack 1 win 257
+   +0 accept(3, ..., ...) = 4
+   +0 setsockopt(4, SOL_SOCKET, SO_SNDBUF, [200000], 4) = 0
+
+   +0 write(4, ..., 30000) = 30000
+   +0 > P. 1:10001(10000) ack 1
+   +0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
+
+ +.11 < . 1:1(0) ack 4001 win 257
+   +0 > P. 10001:18001(8000) ack 1
+
+ +.01 < . 1:1(0) ack 8001 win 257
+   +0 > P. 18001:26001(8000) ack 1
+
++.005 < . 1:1(0) ack 10001 win 257
+   +0 > P. 26001:30001(4000) ack 1
+
+   +0 %{ assert tcpi_snd_cwnd == 20, tcpi_snd_cwnd }%
tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-after-idle.pkt new file +39 -0
new file mode 100644
index 0000000000000..11b213be11384
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test of slow start after idle
+// This test expects tso size to be at least initial cwnd * mss
+
+`./defaults.sh
+./set_sysctls.py /proc/sys/net/ipv4/tcp_slow_start_after_idle=1 \
+		 /proc/sys/net/ipv4/tcp_min_tso_segs=10`
+
+    0 socket(..., SOCK_STREAM, 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:0(0) win 65535 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+  +.1 < . 1:1(0) ack 1 win 511
+   +0 accept(3, ..., ...) = 4
+   +0 setsockopt(4, SOL_SOCKET, SO_SNDBUF, [200000], 4) = 0
+
+   +0 write(4, ..., 26000) = 26000
+   +0 > P. 1:5001(5000) ack 1
+   +0 > P. 5001:10001(5000) ack 1
+   +0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
+
+  +.1 < . 1:1(0) ack 10001 win 511
+   +0 %{ assert tcpi_snd_cwnd == 20, tcpi_snd_cwnd }%
+   +0 > P. 10001:20001(10000) ack 1
+   +0 > P. 20001:26001(6000) ack 1
+
+  +.1 < . 1:1(0) ack 26001 win 511
+   +0 %{ assert tcpi_snd_cwnd == 36, tcpi_snd_cwnd }%
+
+   +2 write(4, ..., 20000) = 20000
+// If slow start after idle works properly, we should send 5 MSS here (cwnd/2)
+   +0 > P. 26001:31001(5000) ack 1
+   +0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
+
+// Reset sysctls
+`/tmp/sysctl_restore_${PPID}.sh`
tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-after-win-update.pkt new file +50 -0

50 lines not on this page · raw message

tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-app-limited-9-packets-out.pkt new file +38 -0
new file mode 100644
index 0000000000000..869f32c35a2ab
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test of slow start when application-limited: in this case,
+// with IW10, if we don't fully use our cwnd but instead
+// send just 9 packets, then cwnd should grow to twice that
+// value, or 18 packets.
+
+// Set up config.
+`./defaults.sh`
+
+    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+   +0 bind(3, ..., ...) = 0
+   +0 listen(3, 1) = 0
+
+  +.1 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+  +.1 < . 1:1(0) ack 1 win 257
+   +0 accept(3, ..., ...) = 4
+   +0 setsockopt(4, SOL_SOCKET, SO_SNDBUF, [200000], 4) = 0
+
+   +0 write(4, ..., 9000) = 9000
+   +0 > P. 1:9001(9000) ack 1
+   +0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
+
++.105 < . 1:1(0) ack 2001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 12, tcpi_snd_cwnd }%
+
++.005 < . 1:1(0) ack 4001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 14, tcpi_snd_cwnd }%
+
++.005 < . 1:1(0) ack 6001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 16, tcpi_snd_cwnd }%
+
++.005 < . 1:1(0) ack 8001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 18, tcpi_snd_cwnd }%
+
++.005 < . 1:1(0) ack 9001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 18, tcpi_snd_cwnd }%
tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-app-limited.pkt new file +36 -0
new file mode 100644
index 0000000000000..0f77b7955db6e
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test of slow start when application-limited: in this case,
+// with IW10, if we send exactly 10 packets then cwnd should grow to 20.
+
+// Set up config.
+`./defaults.sh`
+
+    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+   +0 bind(3, ..., ...) = 0
+   +0 listen(3, 1) = 0
+
+  +.1 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+  +.1 < . 1:1(0) ack 1 win 257
+   +0 accept(3, ..., ...) = 4
+   +0 setsockopt(4, SOL_SOCKET, SO_SNDBUF, [200000], 4) = 0
+
+   +0 write(4, ..., 10000) = 10000
+   +0 > P. 1:10001(10000) ack 1
+   +0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
+
++.105 < . 1:1(0) ack 2001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 12, tcpi_snd_cwnd }%
+
++.005 < . 1:1(0) ack 4001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 14, tcpi_snd_cwnd }%
+
++.005 < . 1:1(0) ack 6001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 16, tcpi_snd_cwnd }%
+
++.005 < . 1:1(0) ack 8001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 18, tcpi_snd_cwnd }%
+
++.005 < . 1:1(0) ack 10001 win 257
+   +0 %{ assert tcpi_snd_cwnd == 20, tcpi_snd_cwnd }%
tools/testing/selftests/net/packetdrill/tcp_slow_start_slow-start-fq-ack-per-2pkt.pkt new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
2.46.0.598.g6f2099f65c-goog
Acked-by on the v2 series
#4 lore raw
In reply to Willem de Bruijn

Hi Willem,

Quoted 5 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

1/3: run in nets, as discussed, and add missing CONFIGs 2/3: import tcp/zerocopy
3/3: import tcp/slow_start

Thank you for the v2. This new version looks good to me:

I didn't pay too much attention to the new tests, because they look good, heavily tested I suppose, and I guess the goal is not to diverge from the original ones for the moment. Still, please note that the CI reported some timing issues with tcp_zerocopy_closed.pkt when using a debug kernel config, e.g.

Quoted 1 line

tcp_zerocopy_closed.pkt:22: timing error: expected system call return at 0.100596 sec but happened at 0.109564 sec; tolerance 0.004000 sec

https://netdev.bots.linux.dev/contest.html?executor=vmksft-packetdrill-dbg&test=tcp-zerocopy-closed-pkt

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#5 lore raw
Quoted 20 lines · Matthieu Baerts

Hi Willem,

Quoted 5 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

1/3: run in nets, as discussed, and add missing CONFIGs 2/3: import tcp/zerocopy
3/3: import tcp/slow_start

Thank you for the v2. This new version looks good to me:

I didn't pay too much attention to the new tests, because they look good, heavily tested I suppose, and I guess the goal is not to diverge from the original ones for the moment. Still, please note that the CI reported some timing issues with tcp_zerocopy_closed.pkt when using a debug kernel config, e.g.

Quoted 3 lines
Quoted 1 line

tcp_zerocopy_closed.pkt:22: timing error: expected system call return at 0.100596 sec but happened at 0.109564 sec; tolerance 0.004000 sec

https://netdev.bots.linux.dev/contest.html?executor=vmksft-packetdrill-dbg&test=tcp-zerocopy-closed-pkt

Thanks Matthieu. I did not run the dbg variant often enough to observe that. Note to self to run more times before I submit.

It seems to fail 2/10 times on the dbg spinner. I don't have an explanation for the failure yet. The line itself has no expected delay

# script packet:  0.113203 S 0:0(0) <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8>
# actual packet:  0.107191 S 0:0(0) win 65535 <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8>

+0.1 recvmsg(4, {msg_name(...)=...,

                    msg_iov(1)=[{...,0}],
                    msg_flags=MSG_ERRQUEUE,
                    msg_control=[]}, MSG_ERRQUEUE) = -1 EAGAIN (Resource temporarily unavailable)

+0...0 connect(4, ..., ...) = 0

+0 > S 0:0(0) <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8>

I guess the expectation includes the +0.1 delay before calling recvmsg, and that timer fired a bit early.

I previously shared a draft patch to adjust --tolerance_usecs in dbg runs. May have to send that after all.

https://lore.kernel.org/netdev/[email protected]/

#6 lore raw
Quoted 43 lines · Willem de Bruijn
Quoted 20 lines · Matthieu Baerts

Hi Willem,

Quoted 5 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

1/3: run in nets, as discussed, and add missing CONFIGs 2/3: import tcp/zerocopy
3/3: import tcp/slow_start

Thank you for the v2. This new version looks good to me:

I didn't pay too much attention to the new tests, because they look good, heavily tested I suppose, and I guess the goal is not to diverge from the original ones for the moment. Still, please note that the CI reported some timing issues with tcp_zerocopy_closed.pkt when using a debug kernel config, e.g.

Quoted 3 lines
Quoted 1 line

tcp_zerocopy_closed.pkt:22: timing error: expected system call return at 0.100596 sec but happened at 0.109564 sec; tolerance 0.004000 sec

https://netdev.bots.linux.dev/contest.html?executor=vmksft-packetdrill-dbg&test=tcp-zerocopy-closed-pkt

Thanks Matthieu. I did not run the dbg variant often enough to observe that. Note to self to run more times before I submit.

It seems to fail 2/10 times on the dbg spinner. I don't have an explanation for the failure yet. The line itself has no expected delay

# script packet:  0.113203 S 0:0(0) <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8>
# actual packet:  0.107191 S 0:0(0) win 65535 <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8>
   +0.1 recvmsg(4, {msg_name(...)=...,
                    msg_iov(1)=[{...,0}],
                    msg_flags=MSG_ERRQUEUE,
                    msg_control=[]}, MSG_ERRQUEUE) = -1 EAGAIN (Resource temporarily unavailable)

   +0...0 connect(4, ..., ...) = 0

   +0 > S 0:0(0) <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8>
Quoted 7 lines

I guess the expectation includes the +0.1 delay before calling recvmsg, and that timer fired a bit early.

I previously shared a draft patch to adjust --tolerance_usecs in dbg runs. May have to send that after all.

https://lore.kernel.org/netdev/[email protected]/

Not sure you've seen, but tcp_slow_start_slow-start-after-win-update.pkt also just popped up on the dashboard for dbg:

# tcp_slow_start_slow-start-after-win-update.pkt:39: error handling packet: timing error: expected outbound packet in relative time range +0.600000~+0.620000

https://netdev-3.bots.linux.dev/vmksft-packetdrill-dbg/results/774981/1-tcp-slow-start-slow-start-after-win-update-pkt/stdout

Do we want to follow up with that '--tolerance_usecs=10000' you've mentioned above?

#7 lore raw
Quoted 55 lines · Stanislav Fomichev
Quoted 43 lines · Willem de Bruijn
Quoted 20 lines · Matthieu Baerts

Hi Willem,

Quoted 5 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

1/3: run in nets, as discussed, and add missing CONFIGs 2/3: import tcp/zerocopy
3/3: import tcp/slow_start

Thank you for the v2. This new version looks good to me:

I didn't pay too much attention to the new tests, because they look good, heavily tested I suppose, and I guess the goal is not to diverge from the original ones for the moment. Still, please note that the CI reported some timing issues with tcp_zerocopy_closed.pkt when using a debug kernel config, e.g.

Quoted 3 lines
Quoted 1 line

tcp_zerocopy_closed.pkt:22: timing error: expected system call return at 0.100596 sec but happened at 0.109564 sec; tolerance 0.004000 sec

https://netdev.bots.linux.dev/contest.html?executor=vmksft-packetdrill-dbg&test=tcp-zerocopy-closed-pkt

Thanks Matthieu. I did not run the dbg variant often enough to observe that. Note to self to run more times before I submit.

It seems to fail 2/10 times on the dbg spinner. I don't have an explanation for the failure yet. The line itself has no expected delay

# script packet:  0.113203 S 0:0(0) <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8>
# actual packet:  0.107191 S 0:0(0) win 65535 <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8>
   +0.1 recvmsg(4, {msg_name(...)=...,
                    msg_iov(1)=[{...,0}],
                    msg_flags=MSG_ERRQUEUE,
                    msg_control=[]}, MSG_ERRQUEUE) = -1 EAGAIN (Resource temporarily unavailable)

   +0...0 connect(4, ..., ...) = 0

   +0 > S 0:0(0) <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8>
Quoted 7 lines

I guess the expectation includes the +0.1 delay before calling recvmsg, and that timer fired a bit early.

I previously shared a draft patch to adjust --tolerance_usecs in dbg runs. May have to send that after all.

https://lore.kernel.org/netdev/[email protected]/

Not sure you've seen, but tcp_slow_start_slow-start-after-win-update.pkt also just popped up on the dashboard for dbg:

Quoted 6 lines

# tcp_slow_start_slow-start-after-win-update.pkt:39: error handling packet: timing error: expected outbound packet in relative time range +0.600000~+0.620000

https://netdev-3.bots.linux.dev/vmksft-packetdrill-dbg/results/774981/1-tcp-slow-start-slow-start-after-win-update-pkt/stdout

Do we want to follow up with that '--tolerance_usecs=10000' you've mentioned above?

And more tests coming. Looks like it. I'll finish it up. Thanks for the pointer.

#8 lore raw
In reply to Willem de Bruijn
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 6 lines · On Wed, 11 Sep 2024 20:52:39 -0400 you wrote:

From: Willem de Bruijn <[email protected]>

1/3: run in nets, as discussed, and add missing CONFIGs 2/3: import tcp/zerocopy
3/3: import tcp/slow_start

Quoted 6 lines

Willem de Bruijn (3):
selftests/net: packetdrill: run in netns and expand config selftests/net: packetdrill: import tcp/zerocopy selftests/net: packetdrill: import tcp/slow_start

[...]

Here is the summary with links:
- [net-next,v2,1/3] selftests/net: packetdrill: run in netns and expand config

    https://git.kernel.org/netdev/net-next/c/cded7e0479c9
  - [net-next,v2,2/3] selftests/net: packetdrill: import tcp/zerocopy
    https://git.kernel.org/netdev/net-next/c/1e42f73fd3c2
  - [net-next,v2,3/3] selftests/net: packetdrill: import tcp/slow_start
    https://git.kernel.org/netdev/net-next/c/e874be276ee4

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html