From 429821b0a91091db71509276855e5919d4d90a49 Mon Sep 17 00:00:00 2001 From: Arthur Sfez Date: Mon, 4 Oct 2021 09:50:18 -0700 Subject: Test listener receiving an invalid ACK while the accept queue is full Updates #6683 PiperOrigin-RevId: 400745768 --- test/packetimpact/tests/tcp_listen_backlog_test.go | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'test/packetimpact/tests') diff --git a/test/packetimpact/tests/tcp_listen_backlog_test.go b/test/packetimpact/tests/tcp_listen_backlog_test.go index c5fd37845..4b0f2e31f 100644 --- a/test/packetimpact/tests/tcp_listen_backlog_test.go +++ b/test/packetimpact/tests/tcp_listen_backlog_test.go @@ -144,13 +144,33 @@ func TestTCPListenBacklog(t *testing.T) { } } + // While the accept queue is still full, send an unexpected ACK from a new + // socket. The listener should reply with an RST. + func() { + conn := dut.Net.NewTCPIPv4(t, testbench.TCP{DstPort: &remotePort}, testbench.TCP{}) + defer conn.Close(t) + conn.Send(t, testbench.TCP{Flags: testbench.TCPFlags(header.TCPFlagAck)}) + if !dut.Uname.IsLinux() { + // TODO(https://gvisor.dev/issues/6683): Expect a RST. + if got, err := conn.Expect(t, testbench.TCP{}, time.Second); err == nil { + t.Errorf("expected no TCP frame, got %s", got) + } + } else { + if got, err := conn.Expect(t, testbench.TCP{}, time.Second); err != nil { + t.Errorf("expected TCP frame: %s", err) + } else if got, want := *got.Flags, header.TCPFlagRst; got != want { + t.Errorf("got %s, want %s", got, want) + } + } + }() + func() { // Now initiate a new connection when the accept queue is full. - connectingConn := dut.Net.NewTCPIPv4(t, testbench.TCP{DstPort: &remotePort}, testbench.TCP{}) - defer connectingConn.Close(t) + conn := dut.Net.NewTCPIPv4(t, testbench.TCP{DstPort: &remotePort}, testbench.TCP{}) + defer conn.Close(t) // Expect dut connection to drop the SYN. - connectingConn.Send(t, testbench.TCP{Flags: testbench.TCPFlags(header.TCPFlagSyn)}) - if got, err := connectingConn.Expect(t, testbench.TCP{}, time.Second); err == nil { + conn.Send(t, testbench.TCP{Flags: testbench.TCPFlags(header.TCPFlagSyn)}) + if got, err := conn.Expect(t, testbench.TCP{}, time.Second); err == nil { t.Fatalf("expected no TCP frame, got %s", got) } }() -- cgit v1.2.3