xref: /linux/tools/testing/selftests/net/packetdrill/tcp_rcv_neg_window.pkt (revision 91a4855d6c03e770e42f17c798a36a3c46e63de2)
1// SPDX-License-Identifier: GPL-2.0
2// Test maximum advertised window limit when rcv_nxt advances past
3// rcv_mwnd_seq. The "usable window" must be properly clamped to zero
4// rather than becoming negative.
5
6--mss=1000
7
8`./defaults.sh`
9
10// Establish a connection.
11   +0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
12   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
13   +0 setsockopt(3, SOL_SOCKET, SO_RCVBUF, [20000], 4) = 0
14   +0 bind(3, ..., ...) = 0
15   +0 listen(3, 1) = 0
16
17   +0 < S 0:0(0) win 32792 <mss 1000,nop,wscale 7>
18   +0 > S. 0:0(0) ack 1 win 18980 <mss 1460,nop,wscale 0>
19  +.1 < . 1:1(0) ack 1 win 257
20
21   +0 accept(3, ..., ...) = 4
22
23// A too big packet is accepted if the receive queue is empty. It
24// does not trigger an immediate ACK.
25   +0 < P. 1:20001(20000) ack 1 win 257
26   +0 %{ assert tcpi_bytes_received == 20000, tcpi_bytes_received; }%
27
28// Send a RST immediately so that there is no rcv_wup/rcv_mwnd_seq update yet
29   +0 < R. 20001:20001(0) ack 1 win 257
30
31// Verify that the RST was accepted. Indirectly this also verifies that no
32// immediate ACK was sent for the data packet above.
33   +0 < . 20001:20001(0) ack 1 win 257
34   +0 > R 1:1(0)
35