Skip to content

feat: Let operators force the host-wide XDP attach mode - #1535

Merged
privateip merged 1 commit into
epic/1399-vlan-transportfrom
feat/issue-1534
Nov 30, 2026
Merged

privateip merged 1 commit into
epic/1399-vlan-transportfrom
feat/issue-1534

Conversation

@privateip

Copy link
Copy Markdown
Contributor

Summary

Operators had no way to run Galactic's XDP programs in generic mode on a host without bnxt_en NICs, so the lab never exercised the generic-mode paths the tagged-transport work needs.

A new host-wide setting, read by both the edge gateway and the egress shard, forces native or generic mode, and left unset it keeps today's driver-based choice and logs which one decided.

Each process now claims the host's mode before it attaches and fails at startup beside a live peer in the other mode, whatever either decision came from, where before the later process left the earlier one's interfaces in the old mode until that pod restarted.

Deferred to the end-of-epic lab pass (#1405)

  • The mode check on every edge node in both modes
  • The lab baseline in generic mode
  • The negative mixed-mode case

Test plan

  • Unit tests cover the unset setting with and without bnxt_en, forced generic and native, an invalid value, the mixed-mode refusal, stale claims, and a peer from a release without claims
  • On a real bpffs, a claim beside an existing dispatcher succeeds, a conflicting one fails, and the old host mode record never blocks it
  • The lab tooling passes shellcheck and task dry runs

Fixes #1534

Add GALACTIC_XDP_MODE (--xdp-mode), one name that galactic-gateway and
galactic-nat both read: auto (the default) keeps the driver-based choice,
native or generic forces that mode for every Galactic XDP attachment on the
host. Any other value fails validation. Each process logs the decision's
source, forced or driver, next to its mode and reason, and warns when native
is forced over bnxt_en NICs (#673).

Before attaching, each process claims the host's mode under
/sys/fs/bpf/galactic-xdp/modes/<component>/ and holds a flock on the claim
for its lifetime. A live claim from the other component in a different mode
fails startup with ErrHostModeConflict, whatever either decision came from,
so a host never attaches in mixed modes. A stale claim, and a peer from a
release that writes none, block nothing.

The containerlab lab gains XDP_MODE for deploy, lab:xdp-mode to switch a
running lab, and verify:xdp-mode to check every Galactic attachment's mode.

Fixes #1534
@privateip privateip self-assigned this Nov 30, 2026
@privateip

Copy link
Copy Markdown
Contributor Author

Evidence for 9180e0f. Lab checks are deferred to the end-of-epic lab pass in #1405, as the PR body says.

Unit tests (go test -race -v, unprivileged):

--- PASS: TestSelect                              (unset: driver result unchanged, bnxt_en included; Source=driver)
--- PASS: TestSelect_Forced                       (generic without bnxt_en, generic with it, native without it, native over bnxt_en with the #673 NIC list)
--- PASS: TestSelect_ForcedStillChecksTargets
--- PASS: TestSelect_RejectsAnUnknownSetting
--- PASS: TestParseSetting
--- PASS: TestParseSetting_RejectsAnInvalidValue
--- PASS: TestClaim_SameModeCoexists
--- PASS: TestClaim_RejectsMixedModes             (forced vs driver both ways, forced vs forced, driver vs driver as after a bnxt_en hot-add)
--- PASS: TestClaim_StaleClaimIsReplaced
--- PASS: TestClaim_PeerWithoutClaimIsNotSeen      (an older-release peer writes no claim; the dispatcher's host_mode pin is never read as one)
--- PASS: TestClaim_WaitsForTheSameComponent
--- PASS: TestClaim_ReadsAnUnreadableLiveRecordAsAnError
--- PASS: TestClaim_RejectsAnInvalidComponent
--- PASS: TestHostClaim_ReleaseTwice
ok  	go.datum.net/galactic/internal/plumbing/ebpf/xdpmode
--- PASS: TestXDPMode                             (both components: unset, auto, generic, native, flag over env, invalid env, invalid flag)
--- PASS: TestXDPModeIgnoresPrefixedNames
ok  	go.datum.net/galactic/internal/config

Root test on a real bpffs (a privileged throwaway container with its own bpffs mount; task test:unit-root itself was not run because this session has no sudo):

--- PASS: TestClaim_OnBpffsBesideTheDispatcher
--- PASS: TestOpenForSlots_LeavesTheHostModeAlone

This test caught a real bug that tmpfs could not: bpffs refuses any name containing a dot, so the first record format (generic.forced) failed on a real kernel. Records are now <mode>_<source>, and component names may not contain a dot.

Upgrade safety. A pod from a release without claims writes none, so a new pod beside it starts. The dispatcher's existing host_mode record is left alone by Claim, and the new pod's dispatcher overwrites it on open, as before. TestClaim_OnBpffsBesideTheDispatcher opens a native dispatcher, claims generic beside it, then reopens in generic and reads host_mode as generic.

Mixed-mode hole, before and after. Before, the later process migrated the dispatcher links it covers, and the earlier one went not-ready, so interfaces only the earlier one covered, such as the gateway's internal interfaces, stayed in the old mode until it restarted. After, the later process fails at startup with ErrHostModeConflict naming both components, modes and sources. This applies whatever either decision came from, which includes a bnxt_en NIC hot-added while one pod runs.

Other checks.

  • task ci passed locally (lint, build, unit, e2e) on the commit before the bpffs record-name fix. The re-run on 9180e0f got through lint and was stopped during build, so this PR's GitHub CI is the full run for the final commit.
  • golangci-lint and the race unit tests for the changed packages pass on 9180e0f.
  • Shellcheck on the changed lab scripts is clean. Its one finding, SC2034 on PORT_PICKED, is in existing lib.sh code outside this change.
  • task --dry shows XDP_MODE reaching deploy, deploy:galactic-nat, deploy:galactic-gateway and lab:xdp-mode. verify:xdp-mode refuses to run without EXPECT, and an invalid XDP_MODE is refused.

Lab, partial and not acceptance evidence. A native-mode lab deploy of an earlier revision confirmed that every Kind node has its own bpffs mount, distinct from the host's and from every other node's. Each edge node's claim directory held only its own gateway and shard, recorded native_driver.

@privateip
privateip marked this pull request as ready for review November 30, 2026 18:35
@privateip
privateip requested a review from a team as a code owner November 30, 2026 18:35
@privateip
privateip merged commit dd624af into epic/1399-vlan-transport Nov 30, 2026
28 checks passed
@privateip
privateip deleted the feat/issue-1534 branch November 30, 2026 18:35
@privateip

Copy link
Copy Markdown
Contributor Author

Verdicts from the first review pass, both merge:

VERDICT: merge. I found no correctness defects. Claim runs once per process on exclusive code paths, the config resolves GALACTIC_XDP_MODE and --xdp-mode correctly, and the build, vet and tests pass locally. The remaining condition is green CI.

VERDICT: merge. No reach or convention problems. The lab checks are deferred to the end-of-epic pass (#1405), as the PR body states. The PR has no Flux, Kustomize or patch-target changes. A merge-tree against #1532 (same containerlab README, Taskfile and lib.sh) is clean.

No findings were applied, so this run made no commits. The adversary's only item, the wait for green CI, was handled here.

CI on head 9180e0f: every check passed (Build, Lint, Unit Tests, Unit Tests (root), ci / Build and test, E2E Tests, Manifests, Documentation, Alerts, Service API bundle, bundle-is-current, platforms, publish-kustomize-bundles, and the image publish jobs), with the debug and service-api publish jobs skipped by design. The PR was marked ready after CI passed.

Auto-merge was enabled with the merge method (--merge) that the base ruleset allows. The base branch ruleset carries no review requirement, so auto-merge completed on CI alone and the PR merged before any human approval. No human reviewer was requested beyond the code owners, since the repository sets none.

privateip added a commit that referenced this pull request Dec 2, 2026
feat: Let operators force the host-wide XDP attach mode
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