diff options
author | Mithun Iyer <iyerm@google.com> | 2021-03-08 13:15:51 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-03-08 13:18:01 -0800 |
commit | 5a75a932029fb5de712b2ae4ec62be6bfe6ce6f8 (patch) | |
tree | fdde29abb8b5220fdb18100acd896dfd80d4ae30 /test | |
parent | cabbbb373a62971684bf012a0c2164106395e051 (diff) |
Avoid a race with test peer advert and DUT send
Fix a race where the DUT could send out test data before it received the
peer window advertisement. Such a race results in the DUT taking longer
time to retransmit zero window probe, thus causing the test to fail
receiving the last expected probe.
To ensure this ordering, piggyback a non-zero payload with the zero
window advertisement and let the DUT receive that, before continuing
with the test.
PiperOrigin-RevId: 361640241
Diffstat (limited to 'test')
-rw-r--r-- | test/packetimpact/tests/tcp_zero_window_probe_retransmit_test.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/test/packetimpact/tests/tcp_zero_window_probe_retransmit_test.go b/test/packetimpact/tests/tcp_zero_window_probe_retransmit_test.go index d094c10eb..413cfa236 100644 --- a/test/packetimpact/tests/tcp_zero_window_probe_retransmit_test.go +++ b/test/packetimpact/tests/tcp_zero_window_probe_retransmit_test.go @@ -15,6 +15,7 @@ package tcp_zero_window_probe_retransmit_test import ( + "bytes" "flag" "testing" "time" @@ -51,18 +52,23 @@ func TestZeroWindowProbeRetransmit(t *testing.T) { if _, err := conn.ExpectData(t, &testbench.TCP{}, samplePayload, time.Second); err != nil { t.Fatalf("expected payload was not received: %s", err) } - conn.Send(t, testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck | header.TCPFlagPsh)}, samplePayload) - if _, err := conn.ExpectData(t, &testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck)}, nil, time.Second); err != nil { - t.Fatalf("expected packet was not received: %s", err) - } // Check for the dut to keep the connection alive as long as the zero window // probes are acknowledged. Check if the zero window probes are sent at // exponentially increasing intervals. The timeout intervals are function // of the recorded first zero probe transmission duration. // - // Advertize zero receive window again. - conn.Send(t, testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck), WindowSize: testbench.Uint16(0)}) + // Advertize zero receive window along with a payload. + conn.Send(t, testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck | header.TCPFlagPsh), WindowSize: testbench.Uint16(0)}, samplePayload) + if _, err := conn.ExpectData(t, &testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck)}, nil, time.Second); err != nil { + t.Fatalf("expected packet was not received: %s", err) + } + // Wait for the payload to be received by the DUT, which is also an + // indication of receive of the peer window advertisement. + if got := dut.Recv(t, acceptFd, int32(len(sampleData)), 0); !bytes.Equal(got, sampleData) { + t.Fatalf("got dut.Recv(t, %d, %d, 0) = %s, want %s", acceptFd, len(sampleData), got, sampleData) + } + probeSeq := testbench.Uint32(uint32(*conn.RemoteSeqNum(t) - 1)) ackProbe := testbench.Uint32(uint32(*conn.RemoteSeqNum(t))) |