xref: /linux/tools/testing/selftests/net/packetdrill/tcp_fastopen_server_reset-non-tfo-socket.pkt (revision 55a42f78ffd386e01a5404419f8c5ded7db70a21)
1// SPDX-License-Identifier: GPL-2.0
2//
3// Send a RST to a fully established socket with pending data before
4// it is accepted.
5//
6// The socket with pending data won't go away and can still be accepted
7// with data read. But it will be in TCP_CLOSE state.
8
9`./defaults.sh`
10
11    0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, 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   +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0
16
17// Invalid cookie, so accept() fails.
18   +0 < S 0:10(10) win 32792 <mss 1460,sackOK,nop,nop,FO aaaaaaaaaaaaaaaa,nop,nop>
19   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK, FO TFO_COOKIE,nop,nop>
20
21   +0 accept(3, ..., ...) = -1 EAGAIN (Resource temporarily unavailable)
22
23// Complete 3WHS and send data and RST
24   +0 < . 1:1(0) ack 1 win 32792
25   +0 < . 1:11(10) ack 1 win 32792
26   +0 < R. 11:11(0) win 32792
27
28// A valid reset won't make the fully-established socket go away.
29// It's just that the acceptor will get a dead, unusable socket
30// in TCP_CLOSE state.
31   +0 accept(3, ..., ...) = 4
32   +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) == 0, tcpi_options }%
33   +0 %{ assert tcpi_state == TCP_CLOSE, tcpi_state }%
34
35   +0 write(4, ..., 100) = -1 ECONNRESET(Connection reset by peer)
36   +0 read(4, ..., 512) = 10
37   +0 read(4, ..., 512) = 0
38