diff options
author | Arthur Sfez <asfez@google.com> | 2021-10-04 09:50:18 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-10-04 09:52:31 -0700 |
commit | 429821b0a91091db71509276855e5919d4d90a49 (patch) | |
tree | ec2db309a2d0fa2fc70887d36c6e1af58bd9d0a4 /test/packetimpact | |
parent | 3bab5e56677942c19d0777a1d6aee38a25a05bbb (diff) |
Test listener receiving an invalid ACK while the accept queue is full
Updates #6683
PiperOrigin-RevId: 400745768
Diffstat (limited to 'test/packetimpact')
-rw-r--r-- | test/packetimpact/tests/tcp_listen_backlog_test.go | 28 |
1 files changed, 24 insertions, 4 deletions
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) } }() |