Skip to content

Let operators force a host-wide XDP attach mode for generic-mode testing #1534

Done

Description

@privateip

Parent: #1399

Dependencies

None. Can start now.

Gap

xdpmode.Select (internal/plumbing/ebpf/xdpmode/mode.go) picks generic XDP only when the host has a bnxt_en NIC, and nothing overrides it. Hosts with bnxt_en run every gateway, NAT and dispatcher attachment in generic mode (docs/operations/xdp-attach-mode.md). The containerlab lab has only veths, so it always selects native and never runs Galactic's programs in generic mode.

That leaves the tagged-transport generic-mode rows without an environment. Those rows are in the #1399 contract (docs/designs/vlan-transport/acceptance.md, environment L) and in the acceptance of #1403 and #1405. VLAN tag handling also differs by mode: generic XDP sees the tag in skb metadata before the kernel untags it, as #1488 showed.

Deliverable

A host-wide setting that forces the XDP attach mode for every Galactic XDP attachment on a host, plus a containerlab option that runs the lab in generic mode.

Work items

  • Add one setting that forces native or generic mode. It applies to every caller of xdpmode.Select, which today means cmd/galactic-gateway/gateway.go and cmd/galactic-nat/nat.go, and through them the shared dispatcher. When the setting is unset, today's driver-based decision is unchanged.
  • Keep the host-wide rule that a host never mixes native and generic redirect paths. Two components on one host that resolve different modes must fail clearly at startup or attach, never attach in mixed modes.
  • Reject an invalid value with a clear error. Log the source of the decision (forced or driver-based) next to the existing decision reason.
  • Add a containerlab variable or Taskfile option that deploys every lab node in generic mode, and document it in deploy/containerlab/README.md.
  • Update docs/operations/xdp-attach-mode.md and the component environment-variable references.

Acceptance

Lab checks deferred. Under #1399's 2026-11-30 decision, this PR carries unit tests and real-kernel root tests. Every check below that needs the shared containerlab lab runs in #1405's end-of-epic lab pass instead, and is not a merge gate here.

  • Unit tests cover: unset (driver-based result unchanged, including the bnxt_en case), forced generic on a host without bnxt_en, forced native, an invalid value, and the mixed-mode rejection.
  • A lab run with the generic option shows xdpgeneric in ip -d link show for every gateway, NAT and dispatcher attachment. The existing lab baseline checks pass in that mode and in the default mode.
  • With the setting unset, the lab deploys in native mode exactly as before.
  • The delivering PR includes unit and real-kernel root test results and closes this task. Automate configurable tagged and untagged transport acceptance #1405 records the native and generic XDP lab results at epic closeout.

Activity

  1. added theissue type on Nov 30, 2026
  2. self-assigned this
    on Nov 30, 2026
  3. privateip commented on Nov 30, 2026

    @privateip
    ContributorAuthor

    Verdict: valid. On epic/1399-vlan-transport (352fe3a), xdpmode.Select has no override, and docs/operations/xdp-attach-mode.md says there is no override variable. Its only callers are cmd/galactic-gateway/gateway.go and cmd/galactic-nat/nat.go.

    Approved plan

    Setting. GALACTIC_XDP_MODE / --xdp-mode, values auto (default; empty means the same), native or generic. It is one name shared by galactic-gateway and galactic-nat (internal/config), not a per-component variable. Any other value fails Validate with a message listing the accepted values. auto keeps today's driver-based decision, including bnxt_en.

    Selection. xdpmode.Select takes the setting. A forced mode still runs the sysfs checks (missing target, unreadable driver). Decision gains a Source (forced or driver), and both callers log it next to the existing mode and reason. Forcing native on a host with a bnxt_en NIC is allowed and logs a warning citing #673.

    Mixed-mode guard. Before any attach, each component claims the host's mode under /sys/fs/bpf/galactic-xdp/modes/<component>/, records its mode and source there, and holds a flock on that directory for its lifetime. If another component holds a live claim in a different mode, startup fails with an error naming both components, modes and sources. A claim whose holder has exited is stale and is replaced. This holds whatever the source of either decision, in both direct and dispatch attach.

    Before this change, the dispatcher's host_mode record let a later process migrate the links it covers while an earlier process in the other mode went not-ready, so interfaces only the earlier one covered could stay in the old mode. With the guard, the later process fails at startup instead, which also covers a bnxt_en NIC hot-added while one pod is running. The existing host_mode record and migration logic stay as they are.

    Lab. A Taskfile variable XDP_MODE sets GALACTIC_XDP_MODE on every NAT and gateway DaemonSet during deploy, task lab:xdp-mode switches a running lab, and task verify:xdp-mode checks every gateway, NAT and dispatcher attachment for xdpgeneric or xdp. Unset, the lab deploys natively as before.

    Docs. docs/operations/xdp-attach-mode.md, the gateway and NAT configuration references, and deploy/containerlab/README.md.

    Tests. Unit tests cover unset (driver result unchanged, bnxt_en included), forced generic without bnxt_en, forced native with and without bnxt_en, an invalid value, the mixed-mode rejection, stale-claim replacement, and a new pod starting beside an old one that writes no claim. A real-bpffs case runs in task test:unit-root.

    Verification. task ci, then a lab run in default mode and in generic mode with the baseline checks, plus a mixed-mode negative case, ending with the lab back in native mode.

  4. privateip commented on Nov 30, 2026

    @privateip
    ContributorAuthor

    Delivered by #1535, merged into the epic branch epic/1399-vlan-transport as dd624af. GALACTIC_XDP_MODE (auto, native, generic) forces the host-wide XDP attach mode, and a per-host claim stops two components from running different modes. The lab option and verify:xdp-mode are in place. The lab checks for this task run in #1405's end-of-epic lab pass, as #1399 decided. Closed by hand because Fixes only fires when the epic branch merges into main.

  5. added a commit that references this issue on Dec 2, 2026
    6b00c77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions