Skip to content

fix(xdp): Retire gateway and NAT hooks from unselected interfaces - #1553

Merged
privateip merged 3 commits into
epic/1399-vlan-transportfrom
fix/issue-1552
Dec 1, 2026
Merged

privateip merged 3 commits into
epic/1399-vlan-transportfrom
fix/issue-1552

Conversation

@privateip

@privateip privateip commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1552

When a restart changes which interfaces the gateway or the NAT shard selects, the new process now removes the XDP hooks it left on the interfaces it dropped. It does this only after every newly selected interface is covered. Other datapaths' hooks stay as they are, and bond members are detached one at a time. Lab confirmation is still to come, in a later #1405 run; the test output is in a comment below.

The XDP dispatcher's links are pinned, so they outlive the process that
attached them, and DispatchSet only ever added roles and links. After a
restart that moved a side from its bond members to a VLAN netdevice,
the members kept xdp_dispatch with the gateway's and the shard's role
bits. The programs kept claiming untagged and wrong-VLAN frames on the
parent. An interface an earlier auto-detection had picked kept its hook
the same way.

Add RetireRole in xdpattach. Under the dispatch lock it removes one
datapath's role from every interface outside the kept set, then
releases the root from each such interface that no Galactic role uses
any more. A bond member goes through the attach guards: one that is the
only member of its bond carrying traffic stays attached until a sibling
carries traffic, and each released member must rejoin its bond before
the next is touched. Other datapaths' role bits and slots stay as they
are. DispatchSet.Retire and Set.Retire expose this for dispatch and
direct mode, and ReleaseDispatcherRoles covers a component that starts
in direct mode after running in dispatch mode. xdpdispatch gains
read-only PinnedLinks and RoleRows.

galactic-gateway retires on startup and after every re-resolution, and
takes a role it no longer runs off every interface. galactic-nat
retires on startup, and after a re-resolution only with an explicit
uplink override: an auto-detected set follows routes, and a route flap
would bounce an uplink twice.

Root tests in edgeattach move the public side from tagged on a VLAN of
a bond, to untagged on the bond, and back, with a restart for each move
in both host modes. They check that XDP runs on the selected interfaces
only and that untagged and wrong-VLAN frames are not claimed while the
side is tagged. They also check that an interface dropped from the
selection loses its role and its pinned link after a restart. Both
tests fail without the fix, and the first one reproduces the
wrong-VLAN claims.

Fixes #1552
@privateip privateip self-assigned this Dec 1, 2026
@privateip

Copy link
Copy Markdown
Contributor Author

Test evidence for 3a29399. The root tests ran as root in a privileged container with a private bpffs.

internal/plumbing/ebpf/edgeattach/reconfigure_root_test.go, with the fix (native mode; generic mode gives the same result, with generic on pubm):

move 0: public side pub.101, targets [pub.101]; XDP map[pub:- pub.101:generic prog 196789 pub.202:- pubm:-]
move 1: public side pub, targets [pubm]; XDP map[pub:- pub.101:- pub.202:- pubm:native prog 196789]
move 2: public side pub.101, targets [pub.101]; XDP map[pub:- pub.101:generic prog 196789 pub.202:- pubm:-]
--- PASS: TestVLANTransport_ReconfigureLeavesNoStaleHook (4.55s)
after the restart: XDP map[auto0:- pub.101:generic prog 196797 pubm:native prog 196797]
--- PASS: TestVLANTransport_RestartDropsAnUnselectedInterface (0.59s)

With xdpattach.retire stubbed out, both tests fail the way the lab did:

move 2 to pub.101: pubm holds XDP "native prog 194155", want attached=false
move 2: tagged public side claimed a VIP frame sent on rtr.202
move 2: tagged public side claimed a VIP frame sent on rtr
auto0, no longer selected, still holds XDP "native prog 194163"
auto0 kept a role row: 100
auto0 kept its pinned dispatcher link

Checks:

  • task lint: passed.
  • task build: passed.
  • task test:unit: passed.
  • Root tests for every test in edgeattach, xdpattach, xdpdispatch, cmd/galactic-gateway and cmd/galactic-nat: passed.
  • Lab rows XM, V11 and V13 in C4: not run. The shared lab is reserved, so they wait for a later Automate configurable tagged and untagged transport acceptance #1405 pass.

The gateway and the NAT shard retired on every pass, even one that left
a newly selected interface uncovered, so an old hook could come off
before its replacement was on. Retire a side only on a pass whose
targets are all covered.

The NAT shard's startup retirement now waits for the same condition. It
runs on the first pass that covers every uplink, and later passes
retire again only with an explicit uplink override.
Wrap the over-long line in the XDP mode guide, make the nil-retirer
test fail on a panic instead of asserting dead code, and drop an issue
number from a production comment.
@privateip
privateip marked this pull request as ready for review December 1, 2026 06:44
@privateip
privateip requested a review from a team as a code owner December 1, 2026 06:44
@privateip
privateip merged commit fd773e0 into epic/1399-vlan-transport Dec 1, 2026
28 checks passed
@privateip
privateip deleted the fix/issue-1552 branch December 1, 2026 06:44
@privateip

Copy link
Copy Markdown
Contributor Author

Review record for head 82197ef, the last commit of three on this branch.

First pass at 3a29399: pr-adversary VERDICT merge, with a nit that retire ran before full coverage and a warning about lock hold when the gateway retires a departed bond member. The warning was answered: a departed member is no longer a bond slave, so the wait returns immediately. It could not run the root tests. pr-conventions-reviewer VERDICT hold, for a body over the summary limit, no checkbox test plan, a contract.md overlap with draft #1549, the lab soak, and no test run.

Fixes in 9f209b5: retire is gated on full coverage in the gateway (retireCovered) and in NAT (uplinkRetirer.afterCoverage), and the body was rewritten with a checkbox test plan.

Second pass at 9f209b5: pr-rereviewer VERDICT merge, both fixes confirmed, with nits on a doc line wrap and a dead-code test assertion. pr-conventions-reviewer VERDICT merge, with a decision on the overlap with #597 and #1549. The overlap is resolved: #1549 merges cleanly with this head by git merge-tree, and #597 is a stale draft against main, outside this base's scope. The lab soak is deferred to a later #1405 run per the epic coordinator's brief.

Commit 82197ef applies only the two nits (doc wrap, nil-retirer test), so there was no third review.

Tests: the author ran the root tests in a privileged container, and edgeattach, xdpattach, xdpdispatch, galactic-gateway and galactic-nat all pass. CI on 82197ef is green, including Unit Tests (root).

Auto-merge is enabled with the merge method, as the epic requires. The base branch has no pull-request rule, so auto-merge can complete without a human approval here.

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.

1 participant