-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests/net: packetdrill: import tcp/ecn, tcp/close, tcp/sack, tcp/…
…tcp_info 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 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 Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Soham Chakradeo <sohamch@google.com> Link: https://patch.msgid.link/20241217185203.297935-2-sohamch.kernel@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
Soham Chakradeo
authored and
Jakub Kicinski
committed
Dec 18, 2024
1 parent
c1bad69
commit 88395c0
Showing
11 changed files
with
442 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
tools/testing/selftests/net/packetdrill/tcp_close_close-local-close-then-remote-fin.pkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Test basic connection teardown where local process closes first: | ||
// the local process calls close() first, so we send a FIN, and receive an ACK. | ||
// Then we receive a FIN and ACK it. | ||
|
||
`./defaults.sh` | ||
|
||
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 | ||
+.01...0.011 connect(3, ..., ...) = 0 | ||
+0 > S 0:0(0) <...> | ||
+0 < S. 0:0(0) ack 1 win 32768 <mss 1000,nop,wscale 6,nop,nop,sackOK> | ||
+0 > . 1:1(0) ack 1 | ||
|
||
+0 write(3, ..., 1000) = 1000 | ||
+0 > P. 1:1001(1000) ack 1 | ||
+0 < . 1:1(0) ack 1001 win 257 | ||
|
||
+0 close(3) = 0 | ||
+0 > F. 1001:1001(0) ack 1 | ||
+0 < . 1:1(0) ack 1002 win 257 | ||
|
||
+0 < F. 1:1(0) ack 1002 win 257 | ||
+0 > . 1002:1002(0) ack 2 |
21 changes: 21 additions & 0 deletions
21
tools/testing/selftests/net/packetdrill/tcp_close_close-on-syn-sent.pkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Test to make sure no RST is being sent when close() | ||
// is called on a socket with SYN_SENT state. | ||
|
||
`./defaults.sh` | ||
|
||
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 | ||
+0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 | ||
|
||
+0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress) | ||
+0 > S 0:0(0) <...> | ||
|
||
// Application decideds to close the socket in SYN_SENT state | ||
// Make sure no RST is sent after close(). | ||
+0 close(3) = 0 | ||
|
||
// Receive syn-ack to trigger the send side packet examination: | ||
// If a RESET were sent right after close(), it would have failed with | ||
// a mismatched timestamp. | ||
+.1 < S. 0:0(0) ack 1 win 32000 <mss 1460,nop,wscale 7> | ||
+0 > R 1:1(0) |
36 changes: 36 additions & 0 deletions
36
tools/testing/selftests/net/packetdrill/tcp_close_close-remote-fin-then-close.pkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Verify behavior for the sequence: remote side sends FIN, then we close(). | ||
// Since the remote side (client) closes first, we test our LAST_ACK code path. | ||
|
||
`./defaults.sh` | ||
|
||
// Initialize a server socket. | ||
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 | ||
|
||
// Client closes first. | ||
+.01 < F. 1:1(0) ack 1 win 257 | ||
+0 > . 1:1(0) ack 2 | ||
|
||
// App notices that client closed. | ||
+0 read(4, ..., 1000) = 0 | ||
|
||
// Then we close. | ||
+.01 close(4) = 0 | ||
+0 > F. 1:1(0) ack 2 | ||
|
||
// Client ACKs our FIN. | ||
+.01 < . 2:2(0) ack 2 win 257 | ||
|
||
// Verify that we send RST in response to any incoming segments | ||
// (because the kernel no longer has any record of this socket). | ||
+.01 < . 2:2(0) ack 2 win 257 | ||
+0 > R 2:2(0) |
21 changes: 21 additions & 0 deletions
21
tools/testing/selftests/net/packetdrill/tcp_ecn_ecn-uses-ect0.pkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Test ECN: verify that Linux TCP ECN sending code uses ECT0 (not ECT1). | ||
// | ||
`./defaults.sh | ||
sysctl -q net.ipv4.tcp_ecn=1 # fully enabled | ||
` | ||
|
||
// Initialize connection | ||
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 4 | ||
|
||
// ECN handshake: send EW flags in SYN packet, E flag in SYN-ACK response | ||
+.002 ... 0.004 connect(4, ..., ...) = 0 | ||
|
||
+0 > SEW 0:0(0) <mss 1460,sackOK,TS val 100 ecr 0,nop,wscale 8> | ||
+.002 < SE. 0:0(0) ack 1 win 32767 <mss 1000,nop,wscale 6,nop,nop,sackOK> | ||
+0 > . 1:1(0) ack 1 | ||
|
||
// Write 1 MSS. | ||
+.002 write(4, ..., 1000) = 1000 | ||
// Send 1 MSS with ect0. | ||
+0 > [ect0] P. 1:1001(1000) ack 1 |
37 changes: 37 additions & 0 deletions
37
tools/testing/selftests/net/packetdrill/tcp_sack_sack-route-refresh-ip-tos.pkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Verify that setsockopt calls that force a route refresh do not | ||
// cause problems matching SACKs with packets in the write queue. | ||
// This variant tests IP_TOS. | ||
|
||
`./defaults.sh` | ||
|
||
// Establish a connection. | ||
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 | ||
+0 setsockopt(3, SOL_IP, IP_MTU_DISCOVER, [IP_PMTUDISC_DONT], 1) = 0 | ||
+0...0.010 connect(3, ..., ...) = 0 | ||
|
||
+0 > S 0:0(0) <mss 1460,sackOK,TS val 100 ecr 0,nop,wscale 8> | ||
+.01 < S. 0:0(0) ack 1 win 65535 <mss 1460,nop,wscale 2,nop,nop,sackOK> | ||
+0 > . 1:1(0) ack 1 | ||
|
||
+.01 write(3, ..., 5840) = 5840 | ||
+0 > P. 1:5841(5840) ack 1 | ||
+.01 < . 1:1(0) ack 5841 win 65535 | ||
|
||
+.01 write(3, ..., 5840) = 5840 | ||
+0 > P. 5841:11681(5840) ack 1 | ||
+.01 < . 1:1(0) ack 11681 win 65535 | ||
|
||
+.01 write(3, ..., 14600) = 14600 | ||
+0 > P. 11681:26281(14600) ack 1 | ||
|
||
// Try the socket option that we know can force a route refresh. | ||
+0 setsockopt(3, SOL_IP, IP_TOS, [4], 1) = 0 | ||
// Then revert to avoid routing/mangling/etc implications of that setting. | ||
+0 setsockopt(3, SOL_IP, IP_TOS, [0], 1) = 0 | ||
|
||
// Verify that we do not retransmit the SACKed segments. | ||
+.01 < . 1:1(0) ack 13141 win 65535 <sack 16061:17521 20441:26281,nop,nop> | ||
+0 > . 13141:16061(2920) ack 1 | ||
+0 > P. 17521:20441(2920) ack 1 | ||
+.01 < . 1:1(0) ack 26281 win 65535 |
64 changes: 64 additions & 0 deletions
64
tools/testing/selftests/net/packetdrill/tcp_sack_sack-shift-sacked-2-6-8-3-9-nofack.pkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Test shifting of newly-SACKed ranges onto the previous already-SACKed skb. | ||
// This variant tests non-FACK SACK with SACKs coming in the order | ||
// 2 6 8 3 9, to test what happens when we get a new SACKed range | ||
// (for packet 3) that is on the right of an existing SACKed range | ||
// (for packet 2). | ||
|
||
`./defaults.sh` | ||
|
||
// Establish a connection and send 10 MSS. | ||
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> | ||
+.1 < . 1:1(0) ack 1 win 1024 | ||
+0 accept(3, ..., ...) = 4 | ||
|
||
+0 write(4, ..., 10000) = 10000 | ||
+0 > P. 1:10001(10000) ack 1 | ||
|
||
+.1 < . 1:1(0) ack 1 win 257 <sack 2001:3001,nop,nop> | ||
+.001 < . 1:1(0) ack 1 win 257 <sack 2001:3001 6001:7001,nop,nop> | ||
+.001 < . 1:1(0) ack 1 win 257 <sack 2001:3001 6001:7001 8001:9001,nop,nop> | ||
|
||
// 3 SACKed packets, so we enter Fast Recovery. | ||
+0 > . 1:1001(1000) ack 1 | ||
+0 %{ assert tcpi_ca_state == TCP_CA_Recovery, tcpi_ca_state }% | ||
+0 %{ assert tcpi_lost == 6, tcpi_lost }% | ||
|
||
// SACK for 3001:4001. | ||
// This SACK for an adjacent range causes the sender to | ||
// shift the newly-SACKed range onto the previous skb. | ||
+.007 < . 1:1(0) ack 1 win 257 <sack 2001:4001 6001:7001 8001:9001,nop,nop> | ||
+0 > . 1001:2001(1000) ack 1 | ||
+0 %{ assert tcpi_lost == 5, tcpi_lost }% | ||
+0 %{ assert tcpi_reordering == 6, tcpi_reordering }% // 8001:9001 -> 3001:4001 is 6 | ||
|
||
// SACK for 9001:10001. | ||
+.01 < . 1:1(0) ack 1 win 257 <sack 2001:4001 6001:7001 8001:10001,nop,nop> | ||
+0 %{ assert tcpi_lost == 5, tcpi_lost }% | ||
|
||
// ACK for 1:1001 as packets from t=0.303 arrive. | ||
+.083 < . 1:1(0) ack 1001 win 257 <sack 2001:4001 6001:7001 8001:10001,nop,nop> | ||
+0 %{ assert tcpi_lost == 4,tcpi_lost }% | ||
|
||
// ACK for 1:4001 as packets from t=0.310 arrive. | ||
+.017 < . 1:1(0) ack 4001 win 257 <sack 6001:7001 8001:10001,nop,nop> | ||
+0 %{ assert tcpi_lost == 3,tcpi_lost }% | ||
|
||
// ACK for 1:7001 as packets from t=0.320 arrive. | ||
+.01 < . 1:1(0) ack 7001 win 257 <sack 8001:10001,nop,nop> | ||
|
||
// ACK for all data as packets from t=0.403 arrive. | ||
+.1 < . 1:1(0) ack 10001 win 257 | ||
+0 %{ | ||
assert tcpi_ca_state == TCP_CA_Open, tcpi_ca_state | ||
assert tcpi_unacked == 0, tcpi_unacked | ||
assert tcpi_sacked == 0, tcpi_sacked | ||
assert tcpi_lost == 0, tcpi_lost | ||
assert tcpi_retrans == 0, tcpi_retrans | ||
}% |
66 changes: 66 additions & 0 deletions
66
tools/testing/selftests/net/packetdrill/tcp_sack_sack-shift-sacked-7-3-4-8-9-fack.pkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Test shifting of newly-SACKed ranges onto the previous already-SACKed skb. | ||
// This variant tests the case where we mark packets 0-4 lost, then | ||
// get a SACK for 3, and then a SACK for 4. | ||
|
||
`./defaults.sh` | ||
|
||
// Establish a connection and send 10 MSS. | ||
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> | ||
+.1 < . 1:1(0) ack 1 win 1024 | ||
+0 accept(3, ..., ...) = 4 | ||
|
||
+0 write(4, ..., 10000) = 10000 | ||
+0 > P. 1:10001(10000) ack 1 | ||
|
||
// SACK for 7001:8001. Using RACK we delay the fast retransmit. | ||
+.1 < . 1:1(0) ack 1 win 257 <sack 7001:8001,nop,nop> | ||
// RACK reordering timer | ||
+.027 > . 1:1001(1000) ack 1 | ||
+0 %{ | ||
assert tcpi_ca_state == TCP_CA_Recovery, tcpi_ca_state | ||
assert tcpi_lost == 7, tcpi_lost # RACK thinks 1:7001 are lost | ||
assert tcpi_reordering == 3, tcpi_reordering | ||
}% | ||
|
||
// SACK for 3001:4001. | ||
+.002 < . 1:1(0) ack 1 win 257 <sack 3001:4001 7001:8001,nop,nop> | ||
+0 > . 1001:2001(1000) ack 1 | ||
+0 %{ | ||
assert tcpi_lost == 6, tcpi_lost # since 3001:4001 is no longer lost | ||
assert tcpi_reordering == 5, tcpi_reordering # 7001:8001 -> 3001:4001 | ||
}% | ||
|
||
// SACK for 4001:5001. | ||
// This SACK for an adjacent range causes the sender to | ||
// shift the newly-SACKed range onto the previous skb. | ||
// It uses the RFC3517 algorithm to mark 1:3001 lost | ||
// because >=3 higher-sequence packets are SACKed. | ||
+.002 < . 1:1(0) ack 1 win 257 <sack 3001:5001 7001:8001,nop,nop> | ||
+0 > . 2001:3001(1000) ack 1 | ||
+0 %{ | ||
assert tcpi_lost == 5,tcpi_lost # SACK/RFC3517 thinks 1:3001 are lost | ||
}% | ||
|
||
// SACK for 8001:9001. | ||
+.002 < . 1:1(0) ack 1 win 257 <sack 3001:5001 7001:9001,nop,nop> | ||
|
||
// SACK for 9001:10001. | ||
+.002 < . 1:1(0) ack 1 win 257 <sack 3001:5001 7001:10001,nop,nop> | ||
+0 > . 5001:6001(1000) ack 1 | ||
|
||
// To simplify clean-up, say we get an ACK for all data. | ||
+.1 < . 1:1(0) ack 10001 win 257 | ||
+0 %{ | ||
assert tcpi_ca_state == TCP_CA_Open, tcpi_ca_state | ||
assert tcpi_unacked == 0, tcpi_unacked | ||
assert tcpi_sacked == 0, tcpi_sacked | ||
assert tcpi_lost == 0, tcpi_lost | ||
assert tcpi_retrans == 0, tcpi_retrans | ||
}% |
62 changes: 62 additions & 0 deletions
62
tools/testing/selftests/net/packetdrill/tcp_sack_sack-shift-sacked-7-5-6-8-9-fack.pkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Test shifting of newly-SACKed ranges onto the previous already-SACKed skb. | ||
// This variant tests the case where we mark packets 0-4 lost, then | ||
// get a SACK for 5, and then a SACK for 6. | ||
|
||
`./defaults.sh` | ||
|
||
// Establish a connection and send 10 MSS. | ||
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> | ||
+.1 < . 1:1(0) ack 1 win 1024 | ||
+0 accept(3, ..., ...) = 4 | ||
|
||
+0 write(4, ..., 10000) = 10000 | ||
+0 > P. 1:10001(10000) ack 1 | ||
|
||
// SACK for 7001:8001. Using RACK we delay a fast retransmit. | ||
+.1 < . 1:1(0) ack 1 win 257 <sack 7001:8001,nop,nop> | ||
+.027 > . 1:1001(1000) ack 1 | ||
+0 %{ | ||
assert tcpi_ca_state == TCP_CA_Recovery, tcpi_ca_state | ||
assert tcpi_lost == 7,tcpi_lost # RACK thinks 1:7001 are lost | ||
assert tcpi_reordering == 3, tcpi_reordering | ||
}% | ||
|
||
// SACK for 5001:6001. | ||
+0 < . 1:1(0) ack 1 win 257 <sack 5001:6001 7001:8001,nop,nop> | ||
+0 > . 1001:2001(1000) ack 1 | ||
+0 %{ | ||
assert tcpi_lost == 6, tcpi_lost | ||
assert tcpi_reordering == 3, tcpi_reordering # 7001:8001 -> 5001:6001 is 3 | ||
}% | ||
|
||
// SACK for 6001:7001. | ||
// This SACK for an adjacent range causes the sender to | ||
// shift the newly-SACKed range onto the previous skb. | ||
+0 < . 1:1(0) ack 1 win 257 <sack 5001:8001,nop,nop> | ||
+0 > . 2001:3001(1000) ack 1 | ||
+0 %{ assert tcpi_lost == 5, tcpi_lost }% | ||
|
||
// SACK for 8001:9001. | ||
+0 < . 1:1(0) ack 1 win 257 <sack 5001:9001,nop,nop> | ||
+0 > . 3001:4001(1000) ack 1 | ||
|
||
// SACK for 9001:10001. | ||
+0 < . 1:1(0) ack 1 win 257 <sack 5001:10001,nop,nop> | ||
+0 > . 4001:5001(1000) ack 1 | ||
|
||
// To simplify clean-up, say we get an ACK for all data. | ||
+.1 < . 1:1(0) ack 10001 win 257 | ||
+0 %{ | ||
assert tcpi_ca_state == TCP_CA_Open, tcpi_ca_state | ||
assert tcpi_unacked == 0, tcpi_unacked | ||
assert tcpi_sacked == 0, tcpi_sacked | ||
assert tcpi_lost == 0, tcpi_lost | ||
assert tcpi_retrans == 0, tcpi_retrans | ||
}% |
20 changes: 20 additions & 0 deletions
20
tools/testing/selftests/net/packetdrill/tcp_tcp_info_tcp-info-last_data_recv.pkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Test tcpi_last_data_recv for active session | ||
`./defaults.sh` | ||
|
||
// Create a socket and set it to non-blocking. | ||
+0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 | ||
+0 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR) | ||
+0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 | ||
|
||
+0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress) | ||
+0 > S 0:0(0) <mss 1460,sackOK,TS val 100 ecr 0,nop,wscale 8> | ||
+.030 < S. 0:0(0) ack 1 win 10000 <mss 1000,sackOK,nop,nop,nop,wscale 8> | ||
+0 > . 1:1(0) ack 1 | ||
|
||
+1 %{ assert 990 <= tcpi_last_data_recv <= 1010, tcpi_last_data_recv }% | ||
|
||
+0 < . 1:1001(1000) ack 1 win 300 | ||
+0 > . 1:1(0) ack 1001 | ||
|
||
+0 %{ assert tcpi_last_data_recv <= 10, tcpi_last_data_recv }% |
Oops, something went wrong.