xref: /linux/tools/testing/selftests/net/packetdrill/tcp_close_close-remote-fin-then-close.pkt (revision 0ad9617c78acbc71373fb341a6f75d4012b01d69)
1*88395c07SSoham Chakradeo// SPDX-License-Identifier: GPL-2.0
2*88395c07SSoham Chakradeo// Verify behavior for the sequence: remote side sends FIN, then we close().
3*88395c07SSoham Chakradeo// Since the remote side (client) closes first, we test our LAST_ACK code path.
4*88395c07SSoham Chakradeo
5*88395c07SSoham Chakradeo`./defaults.sh`
6*88395c07SSoham Chakradeo
7*88395c07SSoham Chakradeo// Initialize a server socket.
8*88395c07SSoham Chakradeo    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
9*88395c07SSoham Chakradeo   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
10*88395c07SSoham Chakradeo   +0 bind(3, ..., ...) = 0
11*88395c07SSoham Chakradeo   +0 listen(3, 1) = 0
12*88395c07SSoham Chakradeo
13*88395c07SSoham Chakradeo   +0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
14*88395c07SSoham Chakradeo   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
15*88395c07SSoham Chakradeo   +0 < . 1:1(0) ack 1 win 257
16*88395c07SSoham Chakradeo
17*88395c07SSoham Chakradeo   +0 accept(3, ..., ...) = 4
18*88395c07SSoham Chakradeo
19*88395c07SSoham Chakradeo// Client closes first.
20*88395c07SSoham Chakradeo +.01 < F. 1:1(0) ack 1 win 257
21*88395c07SSoham Chakradeo   +0 > . 1:1(0) ack 2
22*88395c07SSoham Chakradeo
23*88395c07SSoham Chakradeo// App notices that client closed.
24*88395c07SSoham Chakradeo   +0 read(4, ..., 1000) = 0
25*88395c07SSoham Chakradeo
26*88395c07SSoham Chakradeo// Then we close.
27*88395c07SSoham Chakradeo +.01 close(4) = 0
28*88395c07SSoham Chakradeo   +0 > F. 1:1(0) ack 2
29*88395c07SSoham Chakradeo
30*88395c07SSoham Chakradeo// Client ACKs our FIN.
31*88395c07SSoham Chakradeo +.01 < . 2:2(0) ack 2 win 257
32*88395c07SSoham Chakradeo
33*88395c07SSoham Chakradeo// Verify that we send RST in response to any incoming segments
34*88395c07SSoham Chakradeo// (because the kernel no longer has any record of this socket).
35*88395c07SSoham Chakradeo +.01 < . 2:2(0) ack 2 win 257
36*88395c07SSoham Chakradeo   +0 > R 2:2(0)
37