summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/tcp/testing
diff options
context:
space:
mode:
authorBhasker Hariharan <bhaskerh@google.com>2019-03-29 12:04:42 -0700
committerShentubot <shentubot@google.com>2019-03-29 12:05:43 -0700
commit45c54b1f4e2bb6fcad14b8b7734d6a1847329901 (patch)
treeedcb16a05eb4799210f2a1308677f24e64517186 /pkg/tcpip/transport/tcp/testing
parentcc0e96a4bd3348ecc2a636fd90118b8e5cce672c (diff)
Fix incorrect checksums in TCP and UDP tests.
PiperOrigin-RevId: 241025361 Change-Id: I292e7aea9a4b294b11e4f736e107010d9524586b
Diffstat (limited to 'pkg/tcpip/transport/tcp/testing')
-rw-r--r--pkg/tcpip/transport/tcp/testing/context/context.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/pkg/tcpip/transport/tcp/testing/context/context.go b/pkg/tcpip/transport/tcp/testing/context/context.go
index 5cef8ee97..8ac411b1d 100644
--- a/pkg/tcpip/transport/tcp/testing/context/context.go
+++ b/pkg/tcpip/transport/tcp/testing/context/context.go
@@ -327,9 +327,7 @@ func (c *Context) BuildSegment(payload []byte, h *Headers) buffer.VectorisedView
})
// Calculate the TCP pseudo-header checksum.
- xsum := header.Checksum([]byte(TestAddr), 0)
- xsum = header.Checksum([]byte(StackAddr), xsum)
- xsum = header.Checksum([]byte{0, uint8(tcp.ProtocolNumber)}, xsum)
+ xsum := header.PseudoHeaderChecksum(tcp.ProtocolNumber, TestAddr, StackAddr, uint16(len(t)))
// Calculate the TCP checksum and set it.
xsum = header.Checksum(payload, xsum)
@@ -481,9 +479,7 @@ func (c *Context) SendV6Packet(payload []byte, h *Headers) {
})
// Calculate the TCP pseudo-header checksum.
- xsum := header.Checksum([]byte(TestV6Addr), 0)
- xsum = header.Checksum([]byte(StackV6Addr), xsum)
- xsum = header.Checksum([]byte{0, uint8(tcp.ProtocolNumber)}, xsum)
+ xsum := header.PseudoHeaderChecksum(tcp.ProtocolNumber, TestV6Addr, StackV6Addr, uint16(len(t)))
// Calculate the TCP checksum and set it.
xsum = header.Checksum(payload, xsum)