Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/net: packetdrill: add minimal client and server tests

Introduce minimal tests. These can serve as simple illustrative
examples, and as templates when writing new tests.

When adding new cases, it can be easier to extend an existing base
test rather than start from scratch. The existing tests all focus on
real, often non-trivial, features. It is not obvious which to take as
starting point, and arguably none really qualify.

Add two tests
- the client test performs the active open and initial close
- the server test implements the passive open and final close

Signed-off-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20260105172529.3514786-1-willemdebruijn.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Willem de Bruijn and committed by
Jakub Kicinski
3b7a108c 55ffb0b1

+59
+24
tools/testing/selftests/net/packetdrill/tcp_basic_client.pkt
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // 3 + // Minimal active open. 4 + // First to close connection. 5 + 6 + `./defaults.sh` 7 + 8 + 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 4 9 + 10 + // Connect to server: active open: three-way handshake 11 + +0...0 connect(4, ..., ...) = 0 12 + +0 > S 0:0(0) <mss 1460,sackOK,TS val 0 ecr 0,nop,wscale 8> 13 + +0 < S. 0:0(0) ack 1 win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 7> 14 + +0 > . 1:1(0) ack 1 15 + 16 + // Send data 17 + +0 send(4, ..., 1000, 0) = 1000 18 + +0 > P. 1:1001(1000) ack 1 19 + +0 < . 1:1(0) ack 1001 win 257 20 + 21 + +0 close(4) = 0 22 + +0 > F. 1001:1001(0) ack 1 23 + +0 < F. 1:1(0) ack 1002 win 257 24 + +0 > . 1002:1002(0) ack 2
+35
tools/testing/selftests/net/packetdrill/tcp_basic_server.pkt
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // 3 + // Minimal passive open. 4 + // Peer is first to close. 5 + 6 + `./defaults.sh` 7 + 8 + // Open listener socket 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 + // Incoming connection: passive open: three-way handshake 15 + +0 < S 0:0(0) win 65535 <mss 1000,sackOK,nop,nop,nop,wscale 8> 16 + +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8> 17 + +0 < . 1:1(0) ack 1 win 257 18 + 19 + // Open connection socket and close listener socket 20 + +0 accept(3, ..., ...) = 4 21 + +0 close(3) = 0 22 + 23 + // Peer sends data: acknowledge and receive 24 + +0 < P. 1:1001(1000) ack 1 win 257 25 + +0 > . 1:1(0) ack 1001 26 + +0 recv(4, ..., 1000, 0) = 1000 27 + 28 + // Peer initiates connection close 29 + +0 < F. 1001:1001(0) ack 1 win 257 30 + +.04 > . 1:1(0) ack 1002 31 + 32 + // Local socket also closes its side 33 + +0 close(4) = 0 34 + +0 > F. 1:1(0) ack 1002 35 + +0 < . 1002:1002(0) ack 2 win 257