You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uplink override unit test fails on hosts with an IPv6 route #1226
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.
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:
Reject a whitespace-only override, as OnlyCommasIsError rejects ",,,".
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
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.
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.
Activity
privateip commentedon Oct 29, 2026
Failing case:
TestResolveInterfaces_EnvOverride/OnlyWhitespaceIsErrorininternal/plumbing/ebpf/attach.ResolveInterfacestrims the override before checking it, so a whitespace-onlyconfig.EnvCNIEBPFInterfacesfalls through toautoDetectInterfaces. The test stubslinkByNameFnandlinkListFn(stubNonBondLinks) but notrouteListFnorlinkByIndexFn, so detection reads the host's real routes.Two fixes:
OnlyCommasIsErrorrejects",,,".routeListFnand assert the fallback.Reproduce on a Linux host with an IPv6 default route on a physical interface:
privateip commentedon Oct 30, 2026
Verdict: valid. Reproduced on
mainat 5aee71d.On a Linux host with an IPv6 default route, after generating the eBPF objects (
task build:ebpf):Findings beyond the issue text:
ResolveInterfacesreads the override withos.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.internal/installer,internal/plumbing/srv6, andattach's own attach, health and uplink paths) passes the environment through unchanged;galactic-bgpbridgesHostConf.EBPFInterfacesinto 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.docs/cni/environment-variables.md) describe only set and unset, so rejecting whitespace-only needs a sentence there rather than a behavior reversal.TestResolveInterfaces_EnvOverridewould also read the host routing table if they ever reached auto-detection; the table has no guard against that.privateip commentedon Oct 30, 2026
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-onlyGALACTIC_CNI_EBPF_INTERFACEStakes the auto-detect branch.TestResolveInterfaces_EnvOverridestubs the bond-expansion lookups but notrouteListFn/linkByIndexFn, so that case reads the real routing table and its result depends on the host.Fix.
",,,"is already treated.TestResolveInterfaces_EnvOverride, stubrouteListFnandlinkByIndexFnso 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.docs/cni/environment-variables.mdto say that empty means auto-detect and a whitespace-only value is an error.Tests.
OnlyWhitespaceIsErrorkeeps its expectation; it fails onmainon 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 ofHostConf.EBPFInterfacesis unaffected.Verification.
task ci(lint, build, unit, e2e) plustask docs:check. Branchfix/issue-1226, shipped as one PR.privateip commentedon Oct 30, 2026
Fix is up for review in #1265.
fix(cni): Reject a whitespace-only eBPF interface override