Skip to content

afpacket: add vnet_hdr_size option that can be passed to NewTPacket#136

Merged
mosajjal merged 2 commits intogopacket:masterfrom
MarcusWichelmann:afpacket-vnethdr
Oct 28, 2025
Merged

afpacket: add vnet_hdr_size option that can be passed to NewTPacket#136
mosajjal merged 2 commits intogopacket:masterfrom
MarcusWichelmann:afpacket-vnethdr

Conversation

@MarcusWichelmann
Copy link
Copy Markdown
Contributor

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/

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/
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 OptVNetHdrSize option 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.

@mosajjal mosajjal merged commit 34a6022 into gopacket:master Oct 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants