mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
netstack: don't verify IPv4 checksum when offload is enabled
There's no reason to check it. PiperOrigin-RevId: 487012436
This commit is contained in:
committed by
gVisor bot
parent
7b169a1640
commit
aaf5129c05
@@ -835,7 +835,7 @@ func (e *endpoint) handleLocalPacket(pkt stack.PacketBufferPtr, canSkipRXChecksu
|
||||
|
||||
pkt = pkt.CloneToInbound()
|
||||
defer pkt.DecRef()
|
||||
pkt.RXTransportChecksumValidated = canSkipRXChecksum
|
||||
pkt.RXChecksumValidated = canSkipRXChecksum
|
||||
|
||||
h, ok := e.protocol.parseAndValidate(pkt)
|
||||
if !ok {
|
||||
@@ -1705,7 +1705,7 @@ func (p *protocol) parseAndValidate(pkt stack.PacketBufferPtr) (header.IPv4, boo
|
||||
return nil, false
|
||||
}
|
||||
|
||||
if !h.IsChecksumValid() {
|
||||
if !pkt.RXChecksumValidated && !h.IsChecksumValid() {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
|
||||
@@ -1101,7 +1101,7 @@ func (e *endpoint) handleLocalPacket(pkt stack.PacketBufferPtr, canSkipRXChecksu
|
||||
|
||||
pkt = pkt.CloneToInbound()
|
||||
defer pkt.DecRef()
|
||||
pkt.RXTransportChecksumValidated = canSkipRXChecksum
|
||||
pkt.RXChecksumValidated = canSkipRXChecksum
|
||||
|
||||
hView, ok := e.protocol.parseAndValidate(pkt)
|
||||
if !ok {
|
||||
|
||||
@@ -530,7 +530,7 @@ func (ct *ConnTrack) getConnAndUpdate(pkt PacketBufferPtr, skipChecksumValidatio
|
||||
uint16(pkt.Data().Size()),
|
||||
tid.srcAddr,
|
||||
tid.dstAddr,
|
||||
pkt.RXTransportChecksumValidated || skipChecksumValidation)
|
||||
pkt.RXChecksumValidated || skipChecksumValidation)
|
||||
if !csumValid || !ok {
|
||||
return nil
|
||||
}
|
||||
@@ -542,7 +542,7 @@ func (ct *ConnTrack) getConnAndUpdate(pkt PacketBufferPtr, skipChecksumValidatio
|
||||
pkt.NetworkProtocolNumber,
|
||||
tid.srcAddr,
|
||||
tid.dstAddr,
|
||||
pkt.RXTransportChecksumValidated || skipChecksumValidation)
|
||||
pkt.RXChecksumValidated || skipChecksumValidation)
|
||||
if !lengthValid || !csumValid {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ func (n *nic) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pkt Pac
|
||||
return
|
||||
}
|
||||
|
||||
pkt.RXTransportChecksumValidated = n.NetworkLinkEndpoint.Capabilities()&CapabilityRXChecksumOffload != 0
|
||||
pkt.RXChecksumValidated = n.NetworkLinkEndpoint.Capabilities()&CapabilityRXChecksumOffload != 0
|
||||
|
||||
networkEndpoint.HandlePacket(pkt)
|
||||
}
|
||||
|
||||
@@ -162,9 +162,9 @@ type packetBuffer struct {
|
||||
// NICID is the ID of the last interface the network packet was handled at.
|
||||
NICID tcpip.NICID
|
||||
|
||||
// RXTransportChecksumValidated indicates that transport checksum verification
|
||||
// may be safely skipped.
|
||||
RXTransportChecksumValidated bool
|
||||
// RXChecksumValidated indicates that checksum verification may be
|
||||
// safely skipped.
|
||||
RXChecksumValidated bool
|
||||
|
||||
// NetworkPacketInfo holds an incoming packet's network-layer information.
|
||||
NetworkPacketInfo NetworkPacketInfo
|
||||
@@ -390,7 +390,7 @@ func (pk PacketBufferPtr) Clone() PacketBufferPtr {
|
||||
newPk.TransportProtocolNumber = pk.TransportProtocolNumber
|
||||
newPk.PktType = pk.PktType
|
||||
newPk.NICID = pk.NICID
|
||||
newPk.RXTransportChecksumValidated = pk.RXTransportChecksumValidated
|
||||
newPk.RXChecksumValidated = pk.RXChecksumValidated
|
||||
newPk.NetworkPacketInfo = pk.NetworkPacketInfo
|
||||
newPk.tuple = pk.tuple
|
||||
newPk.InitRefs()
|
||||
|
||||
@@ -101,7 +101,7 @@ func newIncomingSegment(id stack.TransportEndpointID, clock tcpip.Clock, pkt sta
|
||||
uint16(pkt.Data().Size()),
|
||||
netHdr.SourceAddress(),
|
||||
netHdr.DestinationAddress(),
|
||||
pkt.RXTransportChecksumValidated)
|
||||
pkt.RXChecksumValidated)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("header data offset does not respect size constraints: %d < offset < %d, got offset=%d", header.TCPMinimumSize, len(hdr), hdr.DataOffset())
|
||||
}
|
||||
@@ -119,7 +119,7 @@ func newIncomingSegment(id stack.TransportEndpointID, clock tcpip.Clock, pkt sta
|
||||
s.pkt = pkt.IncRef()
|
||||
s.csumValid = csumValid
|
||||
|
||||
if !s.pkt.RXTransportChecksumValidated {
|
||||
if !s.pkt.RXChecksumValidated {
|
||||
s.csum = csum
|
||||
}
|
||||
return s, nil
|
||||
|
||||
@@ -913,7 +913,7 @@ func (e *endpoint) HandlePacket(id stack.TransportEndpointID, pkt stack.PacketBu
|
||||
pkt.NetworkProtocolNumber,
|
||||
netHdr.SourceAddress(),
|
||||
netHdr.DestinationAddress(),
|
||||
pkt.RXTransportChecksumValidated)
|
||||
pkt.RXChecksumValidated)
|
||||
if !lengthValid {
|
||||
// Malformed packet.
|
||||
e.stack.Stats().UDP.MalformedPacketsReceived.Increment()
|
||||
|
||||
@@ -87,7 +87,7 @@ func (p *protocol) HandleUnknownDestinationPacket(id stack.TransportEndpointID,
|
||||
pkt.NetworkProtocolNumber,
|
||||
netHdr.SourceAddress(),
|
||||
netHdr.DestinationAddress(),
|
||||
pkt.RXTransportChecksumValidated)
|
||||
pkt.RXChecksumValidated)
|
||||
if !lengthValid {
|
||||
p.stack.Stats().UDP.MalformedPacketsReceived.Increment()
|
||||
return stack.UnknownDestinationPacketMalformed
|
||||
|
||||
Reference in New Issue
Block a user