(b []byte, canUDPGRO bool)
| 749 | ) |
| 750 | |
| 751 | func 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 | |
| 777 | const ( |
| 778 | udphLen = 8 |
no outgoing calls