Repository navigation
feat(ebpf): Forward gateway and NAT traffic on tagged transport sides - #1540
Conversation
A VLAN netdevice has no native XDP. Generic XDP on it runs after the kernel has matched the frame's VLAN ID and removed the tag, whatever the parent's receive VLAN offload. A tagged transport side's hooks therefore run there, isolated per VLAN, without parsing a tag. xdpmode.ForLink gives a VLAN netdevice generic mode and every other interface the host's mode. xdpattach attaches and checks each interface in that mode, and skips the native support check for a VLAN netdevice. The dispatcher's ModeFor applies the same rule to its links, migrations and coverage. The host-wide mode claim is unchanged.
bpf_fib_lookup names the VLAN netdevice for a route through a tagged side, and a native XDP redirect to a VLAN netdevice transmits nothing. edgedsr.c and nat.c now look the egress interface up in a vlan_egress map. For a tagged side's VLAN netdevice they push exactly that side's 802.1Q tag and leave through its lower device, with XDP_TX when the lower device is the ingress interface. The vlanegress package fills the map from netlink, for the configured sides only: the gateway's public and internal interfaces, and the NAT shard's resolved uplinks. Both sync it at startup and on every netlink change. Its Lowers interface matches the shared transport resolution's VLANLower, which can replace FromNetlink. Root tests cover the gateway ingress and DSR return in all four public/fabric combinations, on a NIC and a bond fabric parent, attached directly and through the dispatcher, in native and generic host modes. Further root tests cover: - isolation of a second VLAN and untagged traffic on the public parent; - the XDP_TX push; - the neighbour fallback staying in the VLAN context; - the NAT66 forward push.
The contract now states that a tagged side's gateway and NAT hooks run on its VLAN netdevice in generic mode. It also describes the vlan_egress transmit tagging, the generic-mode cost on native hosts that #1405 and #1406 measure, Q1 and Q3 as resolved, and Q8 as not supported. The XDP attach mode guide states the per-interface rule. The gateway and NAT configuration guides explain how to name a tagged side.
DesignBefore this change,
This PR does three things:
The device-bound VLAN metadata kfunc was rejected: the kernel keeps device-bound programs out of program arrays, which the dispatcher and the NAT tail calls need, and the kfunc does not work in generic mode. Requiring VLAN receive offload off was also rejected: on veth the sender decides where the tag goes, so the receiver can't enforce it. ValidationReal-kernel root tests, run as root in a privileged container on kernel 7.3.3. Each runs in both host modes (
Negative control: with Unit tests:
The 8 local Lab rows are deferred to the #1405 end-of-epic pass, under #1399's decision. NAT forwarding is covered by program test runs, not by live attachment in each host mode. No hardware qualification is claimed. Compatibility and rollback
|
The NAT root test now runs NAT66 and NAT64, outbound and return, between a tagged public uplink and a tagged fabric uplink on one parent. Each translated packet must leave through the parent with exactly the egress side's tag. A gateway root test covers same-node delivery on a tagged public side. edge_lb hands the encapsulated packet to the kernel, and the packet must continue in the public VLAN netdevice's receive path with no tag. The gateway's startup log now names each tagged side by its configured interface. It no longer infers the side from the position of the interface's ifindex.
|
Tests added at a032ee5, run as root in a privileged container on kernel 7.3.3:
The startup log nit from review is fixed: each tagged side is now named by its configured interface. |
|
Review at a032ee5. Two reviewers ran: the adversarial re-review voted merge, with every earlier finding confirmed fixed. The conventions review held on two landing-order decisions, for #597 and for #1537 to #1539. The epic coordinator settled both: whichever PR lands second rebases. I fixed its remaining body finding. CI is green, including |
feat(ebpf): Forward gateway and NAT traffic on tagged transport sides
Fixes #1403
Summary
The gateway and NAT can now forward traffic when either transport side uses an 802.1Q tag. Before this change, a tagged side could not attach in native XDP mode, and packets routed into a tagged side were dropped. A tagged side's hooks now always run in generic mode on its VLAN device, and packets leaving through a tagged side carry exactly that side's tag. Nodes without VLANs behave as before.
Test plan
The claim of a same-node delivery on the public VLAN is checked in #1539. Open PR #597 edits the same NAT files, and #1537, #1538 and #1539 overlap the transport contract and interface resolution. By the epic coordinator's decision, whichever PR lands second rebases. A follow-up comment has the details.
Rollback
Revert the PR and restart the gateway and NAT pods. An older release refuses a native attach to a tagged side, as it did before.