diff options
author | Kevin Krakauer <krakauer@google.com> | 2020-05-01 16:08:26 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-05-01 16:09:53 -0700 |
commit | 5e1e61fbcbe8fa3cc8b104fadb8cdef3ad29c31f (patch) | |
tree | dff4d88c41b32c8b2973ba0006d22c172c83e278 /pkg/tcpip/stack/stack_test.go | |
parent | e7b8a71156b53f835c8d5ea01bdb1859e740649d (diff) |
Automated rollback of changelist 308674219
PiperOrigin-RevId: 309491861
Diffstat (limited to 'pkg/tcpip/stack/stack_test.go')
-rw-r--r-- | pkg/tcpip/stack/stack_test.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pkg/tcpip/stack/stack_test.go b/pkg/tcpip/stack/stack_test.go index 3f4e08434..1a2cf007c 100644 --- a/pkg/tcpip/stack/stack_test.go +++ b/pkg/tcpip/stack/stack_test.go @@ -95,16 +95,18 @@ func (f *fakeNetworkEndpoint) HandlePacket(r *stack.Route, pkt stack.PacketBuffe f.proto.packetCount[int(f.id.LocalAddress[0])%len(f.proto.packetCount)]++ // Consume the network header. - b := pkt.Data.First() + b, ok := pkt.Data.PullUp(fakeNetHeaderLen) + if !ok { + return + } pkt.Data.TrimFront(fakeNetHeaderLen) // Handle control packets. if b[2] == uint8(fakeControlProtocol) { - nb := pkt.Data.First() - if len(nb) < fakeNetHeaderLen { + nb, ok := pkt.Data.PullUp(fakeNetHeaderLen) + if !ok { return } - pkt.Data.TrimFront(fakeNetHeaderLen) f.dispatcher.DeliverTransportControlPacket(tcpip.Address(nb[1:2]), tcpip.Address(nb[0:1]), fakeNetNumber, tcpip.TransportProtocolNumber(nb[2]), stack.ControlPortUnreachable, 0, pkt) return |