Replace bridge with TC redirect for VM networking#2
Merged
Conversation
This was referenced May 20, 2026
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.
Summary
Replace the per-NIC Linux bridge (
eth0 → br0 → tap0) with TC ingress mirred redirect (eth0 ↔ tap0), following the industry-standard pattern used by awslabs/tc-redirect-tap and Kata Containers.What changed
Network data plane: bridge → TC redirect
Before: Each NIC created 3 kernel objects (eth0, br0, tap0) with a MAC learning disable hack to prevent ARP reply misrouting.
After: Each NIC creates 2 kernel objects (eth0, tap0) wired by TC ingress qdisc + U32 catch-all filter + mirred
EGRESS_REDIRaction withTC_ACT_STOLEN. Bidirectional: eth0 ingress → tap0 egress, tap0 ingress → eth0 egress.MAC address alignment
Replaced
utils.GenerateMAC()(random MAC) with capturingeth0's actual HardwareAddr from CNI and passing it to Cloud Hypervisor's--net mac=parameter. This ensures the guest virtio-net MAC matches the CNI veth MAC — required for anti-spoofing CNI plugins (Cilium eBPF, Calico eBPF, AWS VPC ENI CNIs).TAP device hardening
IFF_VNET_HDR: Allows kernel to parse virtio_net headers for checksum offload and GSO/GRO.IFF_ONE_QUEUE: Prevents packet drops on older kernels when the send buffer is full.Console interface fix
Changed
Hypervisor.Console()return type fromio.ReadClosertoio.ReadWriteCloserto match actual usage (net.Connand*os.Fileare both ReadWriteCloser).Files changed
network/cni/config_linux.gobridgeTapInNS→tcRedirectInNS+addTCRedirecthelpernetwork/cni/config.gobrName, use MAC fromsetupTCRedirectinstead ofGenerateMACnetwork/cni/config_darwin.gohypervisor/hypervisor.goConsole→io.ReadWriteCloserhypervisor/cloudhypervisor/console.goVerification
All verified on Ubuntu 24.04 host with Cloud Hypervisor v51.1.
🤖 Generated with Claude Code