afpacket: add vnet_hdr_size option that can be passed to NewTPacket#136
Merged
mosajjal merged 2 commits intogopacket:masterfrom Oct 28, 2025
Merged
afpacket: add vnet_hdr_size option that can be passed to NewTPacket#136mosajjal merged 2 commits intogopacket:masterfrom
mosajjal merged 2 commits intogopacket:masterfrom
Conversation
This new option allows to optionally prepend packets with a virtio_net_hdr of the given size. This is useful to use offloads over the packet socket. More information: https://lwn.net/Articles/373209/
6983388 to
45e45d6
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for prepending packets with a virtio_net_hdr structure in the AF_PACKET socket implementation, enabling the use of hardware offloads over packet sockets.
- Introduces
OptVNetHdrSizeoption to specify the virtio_net_hdr size (10 or 12 bytes) - Implements
setVNetHdrSize()method to configure the socket option - Integrates the new option into the TPacket initialization flow
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| afpacket/options.go | Adds OptVNetHdrSize type, vnetHdrSize field to options struct, and parsing logic for the new option |
| afpacket/afpacket.go | Implements setVNetHdrSize() method and calls it during TPacket initialization when the option is set |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This new option allows to optionally prepend packets with a
virtio_net_hdrof the given size. This is useful to use offloads over the packet socket.More information: https://lwn.net/Articles/373209/