vm networking: add flag vnet_hdr#78
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for virtio-net headers in VM networking by introducing a new vnet_hdr flag. This flag enables proper handling of segmentation offload for containers running with their own network namespace and veth pairs, where unsegmented packets would otherwise be dropped by the kernel.
Key changes:
- Adds a new
vnet_hdrboolean field to control virtio-net header inclusion - Introduces network flag constants to replace magic numbers
- Updates documentation to describe the new optional field
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/shim/task/networking_unix.go | Adds vnet_hdr field and flag constant, updates parsing and flag handling logic |
| docs/vm-networking.md | Documents the new vnet_hdr optional field |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fbdd137 to
f5f3bb5
Compare
f5f3bb5 to
852e85c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When segmentation offload is enabled, and unsegmented packets are sent to a VM (i.e. when running a container in the root netns), the kernel will detect that packets are larger than expected and proceed. That's not the case for containers (i.e. when running a container with its own netns, and a veth pair). In that case, packets reach the virtio-net interface, are forwarded to the bridge, and then to the appropriate veth. Unsegmented packets with GSO fields unset are dropped by the kernel either at the bridge or at the veth level. That may be due to the current network topology where the vnet interface is attached to a bridge. In that case, we need to tell libkrun that the network backend sends / receives virtio_net_hdr structs with the packets, and the backend need to preserve GSO fields for VM-to-VM connections, or populate them for host-to-VM connections. Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
dmcgowan
left a comment
There was a problem hiding this comment.
Its optional and approved for libkrun, lets get it in so it can be apart of ourvm interface
When segmentation offload is enabled, and unsegmented packets are sent to a VM (i.e. when running a container in the root netns), the kernel will detect that packets are larger than expected and proceed.
That's not the case for containers (i.e. when running a container with its own netns, and a veth pair). In that case, packets reach the virtio-net interface, are forwarded to the bridge, and then to the appropriate veth.
Unsegmented packets with GSO fields unset are dropped by the kernel either at the bridge or at the veth level. That may be due to the current network topology where the vnet interface is attached to a bridge.
In that case, we need to tell libkrun that the network backend sends / receives virtio_net_hdr structs with the packets, and the backend need to preserve GSO fields for VM-to-VM connections, or populate them for host-to-VM connections.