From 380ede9b73822a7d373653f20b4f74ef1695ad24 Mon Sep 17 00:00:00 2001 From: Mithun Iyer Date: Wed, 10 Feb 2021 14:20:18 -0800 Subject: Retry RST expectation in tcp_synrcvd_reset_test Deflake this test by retransmitting the ACK and retrying RST expectation after the supposed state transition to CLOSED. This gives time for the state transition to complete. Without such a retransmit from the test, the ACK could get silently dropped by the listener when the passively connecting endpoint has not yet completely updated the state (in gVisor this would be endpoint state and decrement of synRcvdCount). PiperOrigin-RevId: 356825562 --- test/packetimpact/tests/tcp_synrcvd_reset_test.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'test/packetimpact') diff --git a/test/packetimpact/tests/tcp_synrcvd_reset_test.go b/test/packetimpact/tests/tcp_synrcvd_reset_test.go index c5bbd29ee..4ab9509ec 100644 --- a/test/packetimpact/tests/tcp_synrcvd_reset_test.go +++ b/test/packetimpact/tests/tcp_synrcvd_reset_test.go @@ -42,10 +42,22 @@ func TestTCPSynRcvdReset(t *testing.T) { t.Fatalf("expected SYN-ACK %s", err) } conn.Send(t, testbench.TCP{Flags: testbench.Uint8(header.TCPFlagRst)}) + // Expect the connection to have transitioned SYN-RCVD to CLOSED. - // TODO(gvisor.dev/issue/478): Check for TCP_INFO on the dut side. - conn.Send(t, testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck)}) - if _, err := conn.ExpectData(t, &testbench.TCP{Flags: testbench.Uint8(header.TCPFlagRst)}, nil, time.Second); err != nil { - t.Fatalf("expected a TCP RST %s", err) + // + // Retransmit the ACK a few times to give time for the DUT to + // transition to CLOSED. We cannot use TCP_INFO to lookup the state + // as this is a passive DUT connection. + i := 0 + for ; i < 5; i++ { + conn.Send(t, testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck)}) + if _, err := conn.ExpectData(t, &testbench.TCP{Flags: testbench.Uint8(header.TCPFlagRst)}, nil, time.Second); err != nil { + t.Logf("retransmit%d ACK as we did not get the expected RST, %s", i, err) + } else { + break + } + } + if i == 5 { + t.Fatalf("expected a TCP RST") } } -- cgit v1.2.3