Repository navigation
feat(gateway): Share edge uplinks with NAT without restart outages - #745
Conversation
The gateway attaches edge_lb and edge_return to its uplinks itself, unpinned, so a restart detaches them, bounces every uplink, and cuts egress for a shard chained behind it through the gateway's own xdp_chain map (#710). #742 and #743 put the egress shard on the node's shared dispatcher; this moves the gateway onto it too and retires chain mode, so the two share an uplink and either can restart without touching the other's traffic. - edgedsr.c includes the dispatcher's header and passes every packet it does not claim to the later slots with dispatch_next, in place of xdp_chain and its tail call. Attached directly, the programs hold their own empty copies of the dispatcher maps, so an unclaimed packet passes to the kernel as before. - edgeattach.Load takes the dispatcher's maps as MapReplacements and never pins, recreates or unpins them. - GALACTIC_GATEWAY_XDP_ATTACH defaults to dispatch: the gateway fills slots 0 and 1, renews both leases, and keeps the dispatcher on the public targets with the public role and on the internal targets with the return role, through xdpattach.DispatchSet. direct attaches the programs as before, after releasing an idle dispatcher, and refuses to start while another datapath's slot is live there. - An internal interface that resolves to a public one is refused at startup and dropped from the return set on a later re-resolve, since edge_return forwards anything sourced from a VIP. - GALACTIC_GATEWAY_DATAPATH_ENABLED=false loads nothing, empties the gateway's slots, and makes NetworkGatewayReconciler withdraw this node's VIP advertisements and report DatapathDisabled without driving the engine. The public interface and SRv6 address are not required while it is off. - Chain mode is gone: natattach's chain code, galactic-nat's waitForChain/keepChain, the chained overlay and its placement test. GALACTIC_NAT_XDP_ATTACH=chain is read as dispatch with a warning. Nothing in infra uses the overlay. - xdpattach.ReleaseIdleDispatcher and ClearDispatcherSlots replace the NAT-only helpers, so both binaries release and empty slots the same way. - A disabled gateway withdraws its VIPs on every reconcile, so it matches its own advertisements exactly by their rule label, "<rule>-<node>-v4/-v6", and never claims another node's whose name shares the suffix ("edge1" against "pop-edge1"), which would turn the old suffix match into a delete/recreate loop. Unlabelled legacy advertisements keep the suffix match. - edgeattach.Load removes the retired /sys/fs/bpf/galactic-edge/xdp_chain pin, so it no longer keeps an old shard program loaded or lets a shard not yet upgraded install itself into a map no datapath runs. - A setup step that fails after the gateway joined the dispatcher stops its leases and empties its slots before the process exits. - The gateway architecture and configuration docs, the NAT and node-label docs, the overview docs, AGENTS.md, the lab NAT README and the manifest comments describe the dispatcher in place of xdp_chain, and the NAT doc says a node that ran chain mode upgrades the gateway and the shard together. Root tests run the gateway and the shard on one veth uplink and show a gateway restart leaves the root program and the shard's coverage in place, and that a direct-mode gateway refuses an uplink the shard runs on. edgedsr's tests show an unclaimed packet reaches the shard's slot and a claimed one never does. The containerlab lab ran both on dfw-worker2 in dispatch mode: egress passed with the gateway in front, a gateway restart under traffic kept the root program and lost no requests, a NAT restart kept the gateway ready, and turning the gateway off emptied only its slots. Fixes #717 Fixes #710 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Lab run on the containerlab lab, dfw-worker2, with images built from this branch's code (3376c25 differs only by the advertisement-label match, the retired-pin removal and the setup cleanup, which have their own tests). The gateway ran in dispatch mode with bond0 public and bond1 internal, next to the egress shard in dispatch mode.
Direct-mode refusal of an uplink the shard uses is covered by TestAttachDirect_RefusesAnUplinkTheShardRunsOn, which runs as root against real veth pairs. The root-gated tests for every touched package pass under -race locally, and the Unit Tests (root) job runs them in CI. |
|
Code-reviewer: merge. No blocking findings; four non-blocking items fixed before push (exact advertisement match by rule label, retired xdp_chain pin removal, cleanup on setup failure, docs). RAN: review of changes and diff. Adversary: hold, could not run root-only eBPF tests (skip without root) and CI was pending. One warning: removing the xdp_chain pin needs an upgrade-order note; the NAT doc already says chain-mode nodes upgrade both binaries together, and the PR body now documents this. RAN: go build/vet, go test of touched packages (BPF tests skipped as non-root), kustomize builds, stale-reference greps. Conventions-reviewer: hold on rollout reach (the gateway default flip and chain removal) and merge order with #597. The author confirmed the gateway is deployed on no production node and no production shard uses chain mode, and earlier decided stale drafts (#597, #580, #613) rebase onto this work. RAN: gh pr view, diff stat, open-PR collision check, kustomize builds of both bases. No findings were applied (nothing to apply). CI green: Build, E2E Tests, Lint, Unit Tests, Unit Tests (root), license/cla, and all image publish jobs passed. All checks passed successfully on 3376c25. Merge method: merge. Auto-merge enabled and will complete once a code owner approves. The base branch ruleset requires one code-owner approval of the last push, so the PR will merge after approval. |
Summary
A gateway restart detaches its XDP programs from the uplinks, which cuts egress for an egress shard on the same node and bounces every link.
The gateway now runs from the node's shared XDP dispatcher by default, as the shard already can, so the two share each uplink and either can restart or be turned off without touching the other's traffic.
The old chained mode is removed. No production node runs the gateway or a chained shard, so nothing changes there, and a node that did must upgrade both binaries together.
Test plan
Fixes #717
Fixes #710
🤖 Generated with Claude Code