MCPcopy Create free account
hub / github.com/encodeous/nylon / packetIsGROCandidate

Function packetIsGROCandidate

polyamide/tun/offload_linux.go:751–775  ·  view source on GitHub ↗
(b []byte, canUDPGRO bool)

Source from the content-addressed store, hash-verified

749)
750
751func packetIsGROCandidate(b []byte, canUDPGRO bool) groCandidateType {
752 if len(b) < 28 {
753 return notGROCandidate
754 }
755 if b[0]>>4 == 4 {
756 if b[0]&0x0F != 5 {
757 // IPv4 packets w/IP options do not coalesce
758 return notGROCandidate
759 }
760 if b[9] == unix.IPPROTO_TCP && len(b) >= 40 {
761 return tcp4GROCandidate
762 }
763 if b[9] == unix.IPPROTO_UDP && canUDPGRO {
764 return udp4GROCandidate
765 }
766 } else if b[0]>>4 == 6 {
767 if b[6] == unix.IPPROTO_TCP && len(b) >= 60 {
768 return tcp6GROCandidate
769 }
770 if b[6] == unix.IPPROTO_UDP && len(b) >= 48 && canUDPGRO {
771 return udp6GROCandidate
772 }
773 }
774 return notGROCandidate
775}
776
777const (
778 udphLen = 8

Callers 2

handleGROFunction · 0.85

Calls

no outgoing calls

Tested by 1