Skip to content

Uplink override unit test fails on hosts with an IPv6 route #1226

Closed

Description

@privateip

One unit test of the eBPF uplink selection passes or fails depending on the machine it runs on. It expects an interface override made only of spaces to be rejected. The code treats that override as unset and falls back to detecting uplinks from the routing table. The test does not fake the routing table, so it fails on any machine with a usable IPv6 route and passes on CI runners, which have none.

The test and the code also disagree about what should happen: the test says a blank override is an error, the code says it means "detect automatically". Pick one, then make the test independent of the host.

Part of the MASQUE connector work in #970, where it showed up in a local unit run. Details are in the first comment.

Activity

  1. privateip commented on Oct 29, 2026

    @privateip
    ContributorAuthor

    Failing case: TestResolveInterfaces_EnvOverride/OnlyWhitespaceIsError in internal/plumbing/ebpf/attach.

    interfaces_test.go:106: ResolveInterfaces() error = <nil>, wantError = true
    

    ResolveInterfaces trims the override before checking it, so a whitespace-only config.EnvCNIEBPFInterfaces falls through to autoDetectInterfaces. The test stubs linkByNameFn and linkListFn (stubNonBondLinks) but not routeListFn or linkByIndexFn, so detection reads the host's real routes.

    Two fixes:

    1. Reject a whitespace-only override, as OnlyCommasIsError rejects ",,,".
    2. Keep treating it as unset, and have the case stub routeListFn and assert the fallback.

    Reproduce on a Linux host with an IPv6 default route on a physical interface:

    go test ./internal/plumbing/ebpf/attach -run 'TestResolveInterfaces_EnvOverride/OnlyWhitespaceIsError' -count=1
  2. added theissue type on Oct 29, 2026
  3. self-assigned this
    on Oct 30, 2026
  4. privateip commented on Oct 30, 2026

    @privateip
    ContributorAuthor

    Verdict: valid. Reproduced on main at 5aee71d.

    On a Linux host with an IPv6 default route, after generating the eBPF objects (task build:ebpf):

    go test ./internal/plumbing/ebpf/attach -run 'TestResolveInterfaces_EnvOverride/OnlyWhitespaceIsError' -count=1
    --- FAIL: TestResolveInterfaces_EnvOverride/OnlyWhitespaceIsError (0.00s)
        interfaces_test.go:106: ResolveInterfaces() error = <nil>, wantError = true
    

    Findings beyond the issue text:

    • ResolveInterfaces reads the override with os.Getenv, so an unset variable and an empty one are indistinguishable and both mean auto-detect. Only a value that trims to empty but was not empty is ambiguous today.
    • Nothing depends on a whitespace-only value meaning auto-detect. Every caller (internal/installer, internal/plumbing/srv6, and attach's own attach, health and uplink paths) passes the environment through unchanged; galactic-bgp bridges HostConf.EBPFInterfaces into the variable only when it is empty, and that field is written from a resolved interface list. The lab manifests set explicit interface lists, and the deployment manifests either leave the variable unset or set it to an empty string.
    • The docs (docs/cni/environment-variables.md) describe only set and unset, so rejecting whitespace-only needs a sentence there rather than a behavior reversal.
    • Other cases in TestResolveInterfaces_EnvOverride would also read the host routing table if they ever reached auto-detection; the table has no guard against that.
  5. privateip commented on Oct 30, 2026

    @privateip
    ContributorAuthor

    Approved plan (option 1 from the first comment).

    Root cause. ResolveInterfaces (internal/plumbing/ebpf/attach/interfaces.go) trims the override before deciding whether it is set, so a whitespace-only GALACTIC_CNI_EBPF_INTERFACES takes the auto-detect branch. TestResolveInterfaces_EnvOverride stubs the bond-expansion lookups but not routeListFn/linkByIndexFn, so that case reads the real routing table and its result depends on the host.

    Fix.

    • Decide "set" on the raw value: an unset or empty variable still auto-detects, while any non-empty value is parsed as an override, and one with no usable names (only commas, only whitespace, or a mix) is rejected with the existing error. This matches how ",,," is already treated.
    • In TestResolveInterfaces_EnvOverride, stub routeListFn and linkByIndexFn so they record a call and fail, and assert in every case that auto-detection was never reached. An override case can no longer pass or fail based on the host's routes.
    • Update docs/cni/environment-variables.md to say that empty means auto-detect and a whitespace-only value is an error.

    Tests. OnlyWhitespaceIsError keeps its expectation; it fails on main on a host with an IPv6 route and passes with the fix. Add a mixed whitespace-and-commas case. The auto-detect tests already cover the empty value.

    Risk. A node configured with a whitespace-only value now fails resolution instead of auto-detecting. No in-repo or deployment manifest sets such a value, and empty keeps its current meaning. galactic-bgp's bridge of HostConf.EBPFInterfaces is unaffected.

    Verification. task ci (lint, build, unit, e2e) plus task docs:check. Branch fix/issue-1226, shipped as one PR.

  6. privateip commented on Oct 30, 2026

    @privateip
    ContributorAuthor

    Fix is up for review in #1265.

  7. added a commit that references this issue on Oct 30, 2026
    7c2e6ab
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