Skip to content

Commit f1bcd48

Browse files
committed
Merge branch 'selftests-net-packetdrill-netns-and-two-imports'
Willem de Bruijn says: ==================== 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 ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents eda5891 + e874be2 commit f1bcd48

25 files changed

+1108
-2
lines changed

tools/testing/selftests/net/packetdrill/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
TEST_INCLUDES := ksft_runner.sh \
44
defaults.sh \
5+
set_sysctls.py \
56
../../kselftest/ktap_helpers.sh
67

78
TEST_PROGS := $(wildcard *.pkt)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
CONFIG_IPV6=y
2+
CONFIG_HZ_1000=y
3+
CONFIG_HZ=1000
4+
CONFIG_NET_NS=y
25
CONFIG_NET_SCH_FIFO=y
6+
CONFIG_NET_SCH_FQ=y
37
CONFIG_PROC_SYSCTL=y
8+
CONFIG_SYN_COOKIES=y
9+
CONFIG_TCP_CONG_CUBIC=y
410
CONFIG_TCP_MD5SIG=y
511
CONFIG_TUN=y

tools/testing/selftests/net/packetdrill/ksft_runner.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ fi
3333
ktap_print_header
3434
ktap_set_plan 2
3535

36-
packetdrill ${ipv4_args[@]} $(basename $script) > /dev/null \
36+
unshare -n packetdrill ${ipv4_args[@]} $(basename $script) > /dev/null \
3737
&& ktap_test_pass "ipv4" || ktap_test_fail "ipv4"
38-
packetdrill ${ipv6_args[@]} $(basename $script) > /dev/null \
38+
unshare -n packetdrill ${ipv6_args[@]} $(basename $script) > /dev/null \
3939
&& ktap_test_pass "ipv6" || ktap_test_fail "ipv6"
4040

4141
ktap_finished
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
"""Sets sysctl values and writes a file that restores them.
5+
6+
The arguments are of the form "<proc-file>=<val>" separated by spaces.
7+
The program first reads the current value of the proc-file and creates
8+
a shell script named "/tmp/sysctl_restore_${PACKETDRILL_PID}.sh" which
9+
restores the values when executed. It then sets the new values.
10+
11+
PACKETDRILL_PID is set by packetdrill to the pid of itself, so a .pkt
12+
file could restore sysctls by running `/tmp/sysctl_restore_${PPID}.sh`
13+
at the end.
14+
"""
15+
16+
import os
17+
import subprocess
18+
import sys
19+
20+
filename = '/tmp/sysctl_restore_%s.sh' % os.environ['PACKETDRILL_PID']
21+
22+
# Open file for restoring sysctl values
23+
restore_file = open(filename, 'w')
24+
print('#!/bin/bash', file=restore_file)
25+
26+
for a in sys.argv[1:]:
27+
sysctl = a.split('=')
28+
# sysctl[0] contains the proc-file name, sysctl[1] the new value
29+
30+
# read current value and add restore command to file
31+
cur_val = subprocess.check_output(['cat', sysctl[0]], universal_newlines=True)
32+
print('echo "%s" > %s' % (cur_val.strip(), sysctl[0]), file=restore_file)
33+
34+
# set new value
35+
cmd = 'echo "%s" > %s' % (sysctl[1], sysctl[0])
36+
os.system(cmd)
37+
38+
os.system('chmod u+x %s' % filename)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Test of slow start when not application-limited, so that
3+
// the cwnd continues to grow.
4+
// In this variant, the receiver ACKs every packet.
5+
6+
// Set up config. To keep things simple, disable the
7+
// mechanism that defers sending in order to send bigger TSO packets.
8+
`./defaults.sh
9+
sysctl -q net.ipv4.tcp_tso_win_divisor=100`
10+
11+
0 socket(..., SOCK_STREAM, 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+
16+
+.1 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
17+
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
18+
+.1 < . 1:1(0) ack 1 win 257
19+
+0 accept(3, ..., ...) = 4
20+
+0 setsockopt(4, SOL_SOCKET, SO_SNDBUF, [200000], 4) = 0
21+
22+
+0 write(4, ..., 30000) = 30000
23+
+0 > P. 1:10001(10000) ack 1
24+
+0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
25+
26+
+.105 < . 1:1(0) ack 1001 win 257
27+
+0 > P. 10001:12001(2000) ack 1
28+
29+
+0 < . 1:1(0) ack 2001 win 257
30+
+0 > P. 12001:14001(2000) ack 1
31+
32+
+.005 < . 1:1(0) ack 3001 win 257
33+
+0 > P. 14001:16001(2000) ack 1
34+
35+
+0 < . 1:1(0) ack 4001 win 257
36+
+0 > P. 16001:18001(2000) ack 1
37+
38+
+.005 < . 1:1(0) ack 5001 win 257
39+
+0 > P. 18001:20001(2000) ack 1
40+
41+
+0 < . 1:1(0) ack 6001 win 257
42+
+0 > P. 20001:22001(2000) ack 1
43+
44+
+.005 < . 1:1(0) ack 7001 win 257
45+
+0 > P. 22001:24001(2000) ack 1
46+
47+
+0 < . 1:1(0) ack 8001 win 257
48+
+0 > P. 24001:26001(2000) ack 1
49+
50+
+.005 < . 1:1(0) ack 9001 win 257
51+
+0 > P. 26001:28001(2000) ack 1
52+
53+
+0 < . 1:1(0) ack 10001 win 257
54+
+0 > P. 28001:30001(2000) ack 1
55+
56+
+0 %{ assert tcpi_snd_cwnd == 20, tcpi_snd_cwnd }%
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Test of slow start when an outstanding flight of packets is
3+
// less than the current cwnd, and not big enough to bump up cwnd.
4+
//
5+
// In this variant, the receiver ACKs every other packet,
6+
// approximating standard delayed ACKs.
7+
8+
// Set up config.
9+
`./defaults.sh`
10+
11+
0 socket(..., SOCK_STREAM, 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+
16+
+0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
17+
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
18+
+0 < . 1:1(0) ack 1 win 257
19+
+0 accept(3, ..., ...) = 4
20+
21+
// Only send 5 packets.
22+
+0 write(4, ..., 5000) = 5000
23+
+0 > P. 1:5001(5000) ack 1
24+
+0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
25+
26+
+0 < . 1:1(0) ack 2001 win 257
27+
+0 %{ assert tcpi_snd_cwnd == 10, 'cwnd=%d' % tcpi_snd_cwnd }%
28+
29+
+0 < . 1:1(0) ack 4001 win 257
30+
+0 %{ assert tcpi_snd_cwnd == 10, 'cwnd=%d' % tcpi_snd_cwnd }%
31+
32+
+0 < . 1:1(0) ack 5001 win 257
33+
+0 %{ assert tcpi_snd_cwnd == 10, 'cwnd=%d' % tcpi_snd_cwnd }%
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Test of slow start when an outstanding flight of packets is
3+
// less than the current cwnd, but still big enough that in slow
4+
// start we want to increase our cwnd a little.
5+
//
6+
// In this variant, the receiver ACKs every other packet,
7+
// approximating standard delayed ACKs.
8+
9+
// Set up config.
10+
`./defaults.sh`
11+
12+
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
13+
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
14+
+0 bind(3, ..., ...) = 0
15+
+0 listen(3, 1) = 0
16+
17+
+0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
18+
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
19+
+0 < . 1:1(0) ack 1 win 257
20+
+0 accept(3, ..., ...) = 4
21+
22+
// Only send 6 packets.
23+
+0 write(4, ..., 6000) = 6000
24+
+0 > P. 1:6001(6000) ack 1
25+
+0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
26+
27+
+0 < . 1:1(0) ack 2001 win 257
28+
+0 %{ assert tcpi_snd_cwnd == 12, 'cwnd=%d' % tcpi_snd_cwnd }%
29+
30+
+0 < . 1:1(0) ack 4001 win 257
31+
+0 %{ assert tcpi_snd_cwnd == 12, 'cwnd=%d' % tcpi_snd_cwnd }%
32+
33+
+0 < . 1:1(0) ack 6001 win 257
34+
+0 %{ assert tcpi_snd_cwnd == 12, 'cwnd=%d' % tcpi_snd_cwnd }%
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Test of slow start when not application-limited, so that
3+
// the cwnd continues to grow.
4+
// In this variant, the receiver ACKs every other packet,
5+
// approximating standard delayed ACKs.
6+
7+
// Set up config. To keep things simple, disable the
8+
// mechanism that defers sending in order to send bigger TSO packets.
9+
`./defaults.sh
10+
sysctl -q net.ipv4.tcp_tso_win_divisor=100`
11+
12+
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
13+
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
14+
+0 bind(3, ..., ...) = 0
15+
+0 listen(3, 1) = 0
16+
17+
+.1 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
18+
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
19+
+.1 < . 1:1(0) ack 1 win 257
20+
+0 accept(3, ..., ...) = 4
21+
+0 setsockopt(4, SOL_SOCKET, SO_SNDBUF, [200000], 4) = 0
22+
23+
+0 write(4, ..., 30000) = 30000
24+
+0 > P. 1:10001(10000) ack 1
25+
+0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
26+
27+
+.105 < . 1:1(0) ack 2001 win 257
28+
+0 > P. 10001:14001(4000) ack 1
29+
30+
+.005 < . 1:1(0) ack 4001 win 257
31+
+0 > P. 14001:18001(4000) ack 1
32+
33+
+.005 < . 1:1(0) ack 6001 win 257
34+
+0 > P. 18001:22001(4000) ack 1
35+
36+
+.005 < . 1:1(0) ack 8001 win 257
37+
+0 > P. 22001:26001(4000) ack 1
38+
39+
+.005 < . 1:1(0) ack 10001 win 257
40+
+0 > P. 26001:30001(4000) ack 1
41+
42+
+0 %{ assert tcpi_snd_cwnd == 20, tcpi_snd_cwnd }%
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Test of slow start when not application-limited, so that
3+
// the cwnd continues to grow.
4+
// In this variant, the receiver sends one ACK per 4 packets.
5+
6+
// Set up config. To keep things simple, disable the
7+
// mechanism that defers sending in order to send bigger TSO packets.
8+
`./defaults.sh
9+
sysctl -q net.ipv4.tcp_tso_win_divisor=100`
10+
11+
0 socket(..., SOCK_STREAM, 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+
16+
+.1 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
17+
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
18+
+.1 < . 1:1(0) ack 1 win 257
19+
+0 accept(3, ..., ...) = 4
20+
+0 setsockopt(4, SOL_SOCKET, SO_SNDBUF, [200000], 4) = 0
21+
22+
+0 write(4, ..., 30000) = 30000
23+
+0 > P. 1:10001(10000) ack 1
24+
+0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
25+
26+
+.11 < . 1:1(0) ack 4001 win 257
27+
+0 > P. 10001:18001(8000) ack 1
28+
29+
+.01 < . 1:1(0) ack 8001 win 257
30+
+0 > P. 18001:26001(8000) ack 1
31+
32+
+.005 < . 1:1(0) ack 10001 win 257
33+
+0 > P. 26001:30001(4000) ack 1
34+
35+
+0 %{ assert tcpi_snd_cwnd == 20, tcpi_snd_cwnd }%
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Test of slow start after idle
3+
// This test expects tso size to be at least initial cwnd * mss
4+
5+
`./defaults.sh
6+
./set_sysctls.py /proc/sys/net/ipv4/tcp_slow_start_after_idle=1 \
7+
/proc/sys/net/ipv4/tcp_min_tso_segs=10`
8+
9+
0 socket(..., SOCK_STREAM, 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:0(0) win 65535 <mss 1000,sackOK,nop,nop,nop,wscale 7>
15+
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
16+
+.1 < . 1:1(0) ack 1 win 511
17+
+0 accept(3, ..., ...) = 4
18+
+0 setsockopt(4, SOL_SOCKET, SO_SNDBUF, [200000], 4) = 0
19+
20+
+0 write(4, ..., 26000) = 26000
21+
+0 > P. 1:5001(5000) ack 1
22+
+0 > P. 5001:10001(5000) ack 1
23+
+0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
24+
25+
+.1 < . 1:1(0) ack 10001 win 511
26+
+0 %{ assert tcpi_snd_cwnd == 20, tcpi_snd_cwnd }%
27+
+0 > P. 10001:20001(10000) ack 1
28+
+0 > P. 20001:26001(6000) ack 1
29+
30+
+.1 < . 1:1(0) ack 26001 win 511
31+
+0 %{ assert tcpi_snd_cwnd == 36, tcpi_snd_cwnd }%
32+
33+
+2 write(4, ..., 20000) = 20000
34+
// If slow start after idle works properly, we should send 5 MSS here (cwnd/2)
35+
+0 > P. 26001:31001(5000) ack 1
36+
+0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
37+
38+
// Reset sysctls
39+
`/tmp/sysctl_restore_${PPID}.sh`

0 commit comments

Comments
 (0)