diff options
Diffstat (limited to '')
| -rw-r--r-- | tun/offload_linux.go | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/tun/offload_linux.go b/tun/offload_linux.go index 5f0db06..7cd3206 100644 --- a/tun/offload_linux.go +++ b/tun/offload_linux.go @@ -608,6 +608,10 @@ func tcpGRO(bufs [][]byte, offset int, pktI int, table *tcpGROTable, isV6 bool) case coalesceItemInvalidCSum: // delete the item with an invalid csum table.deleteAt(item.key, i) + // The deleted item will not be re-visited in applyTCPCoalesceAccounting, + // so we must zero the virtioNetHdr. clear() is the equivalent of + // encoding a zero value virtioNetHdr. + clear(bufs[item.bufsIndex][offset-virtioNetHdrLen : offset]) case coalescePktInvalidCSum: // no point in inserting an item that we can't coalesce return groResultNoop @@ -667,11 +671,7 @@ func applyTCPCoalesceAccounting(bufs [][]byte, offset int, table *tcpGROTable) e psum := pseudoHeaderChecksumNoFold(unix.IPPROTO_TCP, srcAddr, dstAddr, uint16(len(pkt)-int(item.iphLen))) binary.BigEndian.PutUint16(pkt[hdr.csumStart+hdr.csumOffset:], checksum([]byte{}, psum)) } else { - hdr := virtioNetHdr{} - err := hdr.encode(bufs[item.bufsIndex][offset-virtioNetHdrLen:]) - if err != nil { - return err - } + clear(bufs[item.bufsIndex][offset-virtioNetHdrLen : offset]) } } } @@ -727,11 +727,7 @@ func applyUDPCoalesceAccounting(bufs [][]byte, offset int, table *udpGROTable) e psum := pseudoHeaderChecksumNoFold(unix.IPPROTO_UDP, srcAddr, dstAddr, uint16(len(pkt)-int(item.iphLen))) binary.BigEndian.PutUint16(pkt[hdr.csumStart+hdr.csumOffset:], checksum([]byte{}, psum)) } else { - hdr := virtioNetHdr{} - err := hdr.encode(bufs[item.bufsIndex][offset-virtioNetHdrLen:]) - if err != nil { - return err - } + clear(bufs[item.bufsIndex][offset-virtioNetHdrLen : offset]) } } } @@ -880,11 +876,7 @@ func handleGRO(bufs [][]byte, offset int, tcpTable *tcpGROTable, udpTable *udpGR } switch result { case groResultNoop: - hdr := virtioNetHdr{} - err := hdr.encode(bufs[i][offset-virtioNetHdrLen:]) - if err != nil { - return err - } + clear(bufs[i][offset-virtioNetHdrLen : offset]) fallthrough case groResultTableInsert: *toWrite = append(*toWrite, i) |
