gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/test/packetdrill/tcp_defer_accept.pkt (about) 1 // Test that a bare ACK does not complete a connection when TCP_DEFER_ACCEPT 2 // timeout is not hit but an ACK w/ data does complete and deliver the 3 // connection to the accept queue. 4 5 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 6 +0 setsockopt(3, SOL_TCP, TCP_DEFER_ACCEPT, [5], 4) = 0 7 +0.000 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 8 +0 bind(3, ..., ...) = 0 9 10 // Set backlog to 1 so that we can easily test. 11 +0 listen(3, 1) = 0 12 13 // Establish a connection without timestamps. 14 +0.0 < S 0:0(0) win 32792 <mss 1460,sackOK,nop,nop,nop,wscale 7> 15 +0.0 > S. 0:0(0) ack 1 <...> 16 17 // Send a bare ACK this should not complete the connection as we 18 // set the TCP_DEFER_ACCEPT above. 19 +0.0 < . 1:1(0) ack 1 win 257 20 21 // The bare ACK should be dropped and no connection should be delivered 22 // to the accept queue. 23 +0.100 accept(3, ..., ...) = -1 EWOULDBLOCK (operation would block) 24 25 // Send another bare ACK and it should still fail we set TCP_DEFER_ACCEPT 26 // to 5 seconds above. 27 +2.5 < . 1:1(0) ack 1 win 257 28 +0.100 accept(3, ..., ...) = -1 EWOULDBLOCK (operation would block) 29 30 // set accept socket back to blocking. 31 +0.000 fcntl(3, F_SETFL, O_RDWR) = 0 32 33 // Now send an ACK w/ data. This should complete the connection 34 // and deliver the socket to the accept queue. 35 +0.1 < . 1:5(4) ack 1 win 257 36 +0.0 > . 1:1(0) ack 5 <...> 37 38 // This should cause connection to transition to connected state. 39 +0.000 accept(3, ..., ...) = 4 40 +0.000 fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0 41 42 // Now read the data and we should get 4 bytes. 43 +0.000 read(4,..., 4) = 4 44 +0.000 close(4) = 0 45 46 +0.0 > F. 1:1(0) ack 5 <...> 47 +0.0 < F. 5:5(0) ack 2 win 257 48 +0.01 > . 2:2(0) ack 6 <...>