summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/packetimpact/testbench/layers.go10
-rw-r--r--test/packetimpact/tests/ipv4_fragment_reassembly_test.go6
-rw-r--r--test/packetimpact/tests/ipv6_fragment_icmp_error_test.go14
-rw-r--r--test/packetimpact/tests/ipv6_fragment_reassembly_test.go14
4 files changed, 23 insertions, 21 deletions
diff --git a/test/packetimpact/testbench/layers.go b/test/packetimpact/testbench/layers.go
index 19e6b8d7d..64a7a171a 100644
--- a/test/packetimpact/testbench/layers.go
+++ b/test/packetimpact/testbench/layers.go
@@ -852,7 +852,13 @@ func (l *ICMPv6) ToBytes() ([]byte, error) {
if err != nil {
return nil, err
}
- h.SetChecksum(header.ICMPv6Checksum(h, *ipv6.SrcAddr, *ipv6.DstAddr, payload))
+ h.SetChecksum(header.ICMPv6Checksum(header.ICMPv6ChecksumParams{
+ Header: h,
+ Src: *ipv6.SrcAddr,
+ Dst: *ipv6.DstAddr,
+ PayloadCsum: header.ChecksumVV(payload, 0 /* initial */),
+ PayloadLen: payload.Size(),
+ }))
break
}
}
@@ -974,7 +980,7 @@ func (l *ICMPv4) ToBytes() ([]byte, error) {
var vv buffer.VectorisedView
vv.AppendView(buffer.View(l.Payload))
vv.Append(payload)
- h.SetChecksum(header.ICMPv4Checksum(h, vv))
+ h.SetChecksum(header.ICMPv4Checksum(h, header.ChecksumVV(vv, 0 /* initial */)))
}
return h, nil
diff --git a/test/packetimpact/tests/ipv4_fragment_reassembly_test.go b/test/packetimpact/tests/ipv4_fragment_reassembly_test.go
index ee050e2c6..707f0f1f5 100644
--- a/test/packetimpact/tests/ipv4_fragment_reassembly_test.go
+++ b/test/packetimpact/tests/ipv4_fragment_reassembly_test.go
@@ -21,7 +21,6 @@ import (
"time"
"github.com/google/go-cmp/cmp"
- "gvisor.dev/gvisor/pkg/tcpip/buffer"
"gvisor.dev/gvisor/pkg/tcpip/header"
"gvisor.dev/gvisor/test/packetimpact/testbench"
)
@@ -118,10 +117,7 @@ func TestIPv4FragmentReassembly(t *testing.T) {
if _, err := rand.Read(originalPayload); err != nil {
t.Fatalf("rand.Read: %s", err)
}
- cksum := header.ICMPv4Checksum(
- icmp,
- buffer.NewVectorisedView(len(originalPayload), []buffer.View{originalPayload}),
- )
+ cksum := header.ICMPv4Checksum(icmp, header.Checksum(originalPayload, 0 /* initial */))
icmp.SetChecksum(cksum)
for _, fragment := range test.fragments {
diff --git a/test/packetimpact/tests/ipv6_fragment_icmp_error_test.go b/test/packetimpact/tests/ipv6_fragment_icmp_error_test.go
index e0b2a2178..4034a128e 100644
--- a/test/packetimpact/tests/ipv6_fragment_icmp_error_test.go
+++ b/test/packetimpact/tests/ipv6_fragment_icmp_error_test.go
@@ -21,7 +21,6 @@ import (
"github.com/google/go-cmp/cmp"
"gvisor.dev/gvisor/pkg/tcpip"
- "gvisor.dev/gvisor/pkg/tcpip/buffer"
"gvisor.dev/gvisor/pkg/tcpip/header"
"gvisor.dev/gvisor/pkg/tcpip/network/ipv6"
"gvisor.dev/gvisor/test/packetimpact/testbench"
@@ -45,12 +44,13 @@ func fragmentedICMPEchoRequest(t *testing.T, n *testbench.DUTTestNet, conn *test
icmpv6Header.SetCode(header.ICMPv6UnusedCode)
icmpv6Header.SetIdent(0)
icmpv6Header.SetSequence(0)
- cksum := header.ICMPv6Checksum(
- icmpv6Header,
- tcpip.Address(n.LocalIPv6),
- tcpip.Address(n.RemoteIPv6),
- buffer.NewVectorisedView(len(payload), []buffer.View{payload}),
- )
+ cksum := header.ICMPv6Checksum(header.ICMPv6ChecksumParams{
+ Header: icmpv6Header,
+ Src: tcpip.Address(n.LocalIPv6),
+ Dst: tcpip.Address(n.RemoteIPv6),
+ PayloadCsum: header.Checksum(payload, 0 /* initial */),
+ PayloadLen: len(payload),
+ })
icmpv6Header.SetChecksum(cksum)
icmpv6Bytes := append([]byte(icmpv6Header), payload...)
diff --git a/test/packetimpact/tests/ipv6_fragment_reassembly_test.go b/test/packetimpact/tests/ipv6_fragment_reassembly_test.go
index dd98ee7a1..db6195dc9 100644
--- a/test/packetimpact/tests/ipv6_fragment_reassembly_test.go
+++ b/test/packetimpact/tests/ipv6_fragment_reassembly_test.go
@@ -22,7 +22,6 @@ import (
"github.com/google/go-cmp/cmp"
"gvisor.dev/gvisor/pkg/tcpip"
- "gvisor.dev/gvisor/pkg/tcpip/buffer"
"gvisor.dev/gvisor/pkg/tcpip/header"
"gvisor.dev/gvisor/test/packetimpact/testbench"
)
@@ -121,12 +120,13 @@ func TestIPv6FragmentReassembly(t *testing.T) {
t.Fatalf("rand.Read: %s", err)
}
- cksum := header.ICMPv6Checksum(
- icmp,
- lIP,
- rIP,
- buffer.NewVectorisedView(len(originalPayload), []buffer.View{originalPayload}),
- )
+ cksum := header.ICMPv6Checksum(header.ICMPv6ChecksumParams{
+ Header: icmp,
+ Src: lIP,
+ Dst: rIP,
+ PayloadCsum: header.Checksum(originalPayload, 0 /* initial */),
+ PayloadLen: len(originalPayload),
+ })
icmp.SetChecksum(cksum)
for _, fragment := range test.fragments {