summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/stack/forwarder_test.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-04-20 14:31:12 -0700
committergVisor bot <gvisor-bot@google.com>2020-04-20 14:31:12 -0700
commit07b1b4cc98552a7d45d673ce1e4d1222bbffca7d (patch)
tree0c09a287bf7c712e315e2dd2a49b8785054de986 /pkg/tcpip/stack/forwarder_test.go
parent470633d7e916e7956f4ebd75559f92cf12067cbf (diff)
parenta551add5d8a5bf631cd9859c761e579fdb33ec82 (diff)
Merge pull request #2313 from kevinGC:firstn
PiperOrigin-RevId: 307477185
Diffstat (limited to 'pkg/tcpip/stack/forwarder_test.go')
-rw-r--r--pkg/tcpip/stack/forwarder_test.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/pkg/tcpip/stack/forwarder_test.go b/pkg/tcpip/stack/forwarder_test.go
index e9c652042..c7c663498 100644
--- a/pkg/tcpip/stack/forwarder_test.go
+++ b/pkg/tcpip/stack/forwarder_test.go
@@ -70,7 +70,10 @@ func (f *fwdTestNetworkEndpoint) ID() *NetworkEndpointID {
func (f *fwdTestNetworkEndpoint) HandlePacket(r *Route, pkt PacketBuffer) {
// Consume the network header.
- b := pkt.Data.First()
+ b, ok := pkt.Data.PullUp(fwdTestNetHeaderLen)
+ if !ok {
+ return
+ }
pkt.Data.TrimFront(fwdTestNetHeaderLen)
// Dispatch the packet to the transport protocol.
@@ -473,7 +476,7 @@ func TestForwardingWithFakeResolverPartialTimeout(t *testing.T) {
t.Fatal("packet not forwarded")
}
- b := p.Pkt.Header.View()
+ b := p.Pkt.Data.ToView()
if b[0] != 3 {
t.Fatalf("got b[0] = %d, want = 3", b[0])
}
@@ -517,7 +520,7 @@ func TestForwardingWithFakeResolverTwoPackets(t *testing.T) {
t.Fatal("packet not forwarded")
}
- b := p.Pkt.Header.View()
+ b := p.Pkt.Data.ToView()
if b[0] != 3 {
t.Fatalf("got b[0] = %d, want = 3", b[0])
}
@@ -564,7 +567,7 @@ func TestForwardingWithFakeResolverManyPackets(t *testing.T) {
t.Fatal("packet not forwarded")
}
- b := p.Pkt.Header.View()
+ b := p.Pkt.Data.ToView()
if b[0] != 3 {
t.Fatalf("got b[0] = %d, want = 3", b[0])
}
@@ -619,7 +622,7 @@ func TestForwardingWithFakeResolverManyResolutions(t *testing.T) {
// The first 5 packets (address 3 to 7) should not be forwarded
// because their address resolutions are interrupted.
- b := p.Pkt.Header.View()
+ b := p.Pkt.Data.ToView()
if b[0] < 8 {
t.Fatalf("got b[0] = %d, want b[0] >= 8", b[0])
}