Commit 88395c07 authored by Soham Chakradeo's avatar Soham Chakradeo Committed by Jakub Kicinski
Browse files

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: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarSoham Chakradeo <sohamch@google.com>
Link: https://patch.msgid.link/20241217185203.297935-2-sohamch.kernel@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c1bad69f
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
// 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 −0
Original line number Diff line number Diff line
// 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 −0
Original line number Diff line number Diff line
// 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 −0
Original line number Diff line number Diff line
// 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 −0
Original line number Diff line number Diff line
// 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
Loading