aboutsummaryrefslogtreecommitdiff
path: root/tun/tcp_offload_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'tun/tcp_offload_linux.go')
-rw-r--r--tun/tcp_offload_linux.go35
1 files changed, 25 insertions, 10 deletions
diff --git a/tun/tcp_offload_linux.go b/tun/tcp_offload_linux.go
index 4912efd..39a7180 100644
--- a/tun/tcp_offload_linux.go
+++ b/tun/tcp_offload_linux.go
@@ -189,14 +189,29 @@ func tcpPacketsCanCoalesce(pkt []byte, iphLen, tcphLen uint8, seq uint32, pshSet
return coalesceUnavailable
}
}
- if pkt[1] != pktTarget[1] {
- // cannot coalesce with unequal ToS values
- return coalesceUnavailable
- }
- if pkt[6]>>5 != pktTarget[6]>>5 {
- // cannot coalesce with unequal DF or reserved bits. MF is checked
- // further up the stack.
- return coalesceUnavailable
+ if pkt[0]>>4 == 6 {
+ if pkt[0] != pktTarget[0] || pkt[1]>>4 != pktTarget[1]>>4 {
+ // cannot coalesce with unequal Traffic class values
+ return coalesceUnavailable
+ }
+ if pkt[7] != pktTarget[7] {
+ // cannot coalesce with unequal Hop limit values
+ return coalesceUnavailable
+ }
+ } else {
+ if pkt[1] != pktTarget[1] {
+ // cannot coalesce with unequal ToS values
+ return coalesceUnavailable
+ }
+ if pkt[6]>>5 != pktTarget[6]>>5 {
+ // cannot coalesce with unequal DF or reserved bits. MF is checked
+ // further up the stack.
+ return coalesceUnavailable
+ }
+ if pkt[8] != pktTarget[8] {
+ // cannot coalesce with unequal TTL values
+ return coalesceUnavailable
+ }
}
// seq adjacency
lhsLen := item.gsoSize
@@ -366,7 +381,7 @@ func coalesceTCPPackets(mode canCoalesce, pkt []byte, pktBuffsIndex int, gsoSize
}
const (
- ipv4FlagMoreFragments = 0x80
+ ipv4FlagMoreFragments uint8 = 0x20
)
const (
@@ -409,7 +424,7 @@ func tcpGRO(bufs [][]byte, offset int, pktI int, table *tcpGROTable, isV6 bool)
return false
}
if !isV6 {
- if pkt[6]&ipv4FlagMoreFragments != 0 || (pkt[6]<<3 != 0 || pkt[7] != 0) {
+ if pkt[6]&ipv4FlagMoreFragments != 0 || pkt[6]<<3 != 0 || pkt[7] != 0 {
// no GRO support for fragmented segments for now
return false
}