summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-01-23 00:23:34 +0000
committergVisor bot <gvisor-bot@google.com>2021-01-23 00:23:34 +0000
commit21c64a9aad986590172ef814f2bd0335a2b88399 (patch)
tree4b6a92af8753865c1049f17cb3e44f55373c7ef7 /pkg/tcpip
parent9e2762d9c5704a608a008b4b9da5264834303286 (diff)
parent76da673a0ddaf33e410d48501a9b089979411d4d (diff)
Merge release-20210112.0-77-g76da673a0 (automated)
Diffstat (limited to 'pkg/tcpip')
-rw-r--r--pkg/tcpip/network/ipv4/igmp.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/pkg/tcpip/network/ipv4/igmp.go b/pkg/tcpip/network/ipv4/igmp.go
index 9515fde45..4550aacd6 100644
--- a/pkg/tcpip/network/ipv4/igmp.go
+++ b/pkg/tcpip/network/ipv4/igmp.go
@@ -157,14 +157,13 @@ func (igmp *igmpState) handleIGMP(pkt *stack.PacketBuffer) {
}
h := header.IGMP(headerView)
- // Temporarily reset the checksum field to 0 in order to calculate the proper
- // checksum.
- wantChecksum := h.Checksum()
- h.SetChecksum(0)
- gotChecksum := ^header.ChecksumVV(pkt.Data, 0 /* initial */)
- h.SetChecksum(wantChecksum)
-
- if gotChecksum != wantChecksum {
+ // As per RFC 1071 section 1.3,
+ //
+ // To check a checksum, the 1's complement sum is computed over the
+ // same set of octets, including the checksum field. If the result
+ // is all 1 bits (-0 in 1's complement arithmetic), the check
+ // succeeds.
+ if header.ChecksumVV(pkt.Data, 0 /* initial */) != 0xFFFF {
received.checksumErrors.Increment()
return
}