Skip to content

fix(attach): Deliver same-node traffic on a tagged public side - #1560

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

privateip merged 2 commits into
epic/1399-vlan-transportfrom
fix/issue-1556

Conversation

@privateip

@privateip privateip commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

When the backend runs on the gateway's own node and the public side carries a VLAN tag, requests to the VIP time out. The cluster network plugin's program on the public VLAN interface ran before Galactic's decapsulation program, passed the packet on, and the kernel dropped it. Galactic's program now runs first on those interfaces and leaves other traffic to the plugin. The gateway reports same-node delivery only while that order holds.

Fixes #1556

Test plan

  • New kernel test of UDP and TCP exchanges through IPv4 and IPv6 VIPs with a same-node backend: 8 of 10 cases time out before this change, 10 of 10 pass after it
  • task lint, task build, task test:unit, and the affected root packages in a privileged container
  • CI root job
  • Lab retest, not run here; the epic's final lab pass covers it

On a tagged public side, edge_lb hands a same-node packet to the kernel
on the public VLAN netdevice, so only that interface's tc ingress can
claim it. A cluster CNI such as Cilium attaches its host program there
through tcx, which the kernel runs before clsact filters, and passes
traffic not its own with TC_ACT_OK. That ends classification, so
usid_ingress never ran and the packet met the discard route for the
node's own locator. A bond is unaffected: its members claim the packet
and carry no CNI program.

Attach usid_ingress also as a pinned tcx link at the head of the chain
on each selected interface that is neither a bond nor a bond member,
and remove it on detach. Unclaimed traffic returns TC_ACT_UNSPEC, which
tcx takes as "next", so later programs still see it. IngressAttachedTo,
which gates the gateway's status.localDelivery, now fails while another
tcx program runs ahead of usid_ingress on such an interface.

TestVLANTransport_SameNodeExchange runs real UDP and TCP exchanges with
an IPv6 and an IPv4 VIP whose backend is on the gateway's node, request
and reply, with a tcx stand-in for the CNI, in both host modes, over an
untagged and a tagged single NIC and bond, and a tagged bond with the
XDP dispatcher.

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

Copy link
Copy Markdown
Contributor Author

Same-node gateway delivery timed out on a tagged public side because a cluster CNI's tcx program ran ahead of usid_ingress on the public VLAN netdevice. This change puts usid_ingress at the head of that interface's tcx chain and adds the end-to-end root test the issue asks for.

Fixes #1556

Root cause

  1. On a tagged public side, edge_lb runs on the public VLAN netdevice and hands a same-node packet to the kernel with XDP_PASS. The kernel classifies it only there.
  2. usid_ingress is a clsact filter. The kernel runs a hook's tcx programs before its clsact filters, and a tcx program that returns TC_ACT_OK ends classification.
  3. Cilium attaches cil_from_netdev through tcx (anchored at the tail) to every interface that holds an address, the public VLAN netdevice included, and passes traffic that is not its own with TC_ACT_OK. usid_ingress never runs, and the packet meets the discard route for the node's own locator.

An untagged bond never hit this, because its members claim the packet and hold no address, so no CNI program sits on them. The earlier passing C4 smoke run claimed it on the members too, through a stale native edge_lb hook that #1553 later retired.

Change

  • attach.Attach and attach.Watch also attach usid_ingress as a tcx link anchored at the head on each selected interface that is neither a bond nor a bond member. The link is pinned under /sys/fs/bpf/galactic/ingress_tcx, keyed by network namespace and ifindex. attach.Detach removes it. A kernel without tcx gets no link.
  • Traffic usid_ingress does not claim returns TC_ACT_UNSPEC, which tcx takes as "next". The CNI's program still sees every packet that is not claimed. With no other tcx program present, the clsact filter runs usid_ingress a second time on those packets, and it leaves them unclaimed again.
  • attach.IngressAttachedTo now fails while another tcx program runs ahead of usid_ingress on such an interface. galactic-gateway asks it before reporting status.localDelivery, so a node that cannot deliver locally no longer says it can.
  • Docs: the CNI architecture's design decisions and §3 of the transport contract.

Tests

TestVLANTransport_SameNodeExchange (internal/plumbing/ebpf/edgeattach) runs real UDP and TCP exchanges with an IPv6 and an IPv4 VIP. The only backend is a socket in a namespace behind a veth host link on the gateway's own node, and the client is a socket on the router. The test covers the request (edge_lb hand-up, then the usid_ingress claim and VIP translation) and the reply (usid_egress, then public_uplink_table as srv6.ResolvePublicUplink resolves it, out the public side with its tag). A tcx program that passes everything with TC_ACT_OK stands in for Cilium.

It runs in both host modes, on 5 topologies:

  • untagged single NIC
  • untagged bond
  • tagged single NIC
  • tagged bond
  • tagged bond with the XDP dispatcher

Results on the epic branch before this change: 2 of 10 pass, the untagged bond in each host mode. The other 8 time out. local_deliveries rises, and usid_ingress never claims:

ipv6 udp exchange through 2001:db8:100::10: read udp6 [2001:db8:ffff::1]:42037->[2001:db8:100::10]:443: i/o timeout (local_deliveries 1; edge drop_reasons; usid nonzero drop_reasons map[16:4 24:4 28:4])

With this change, all 10 pass:

--- PASS: TestVLANTransport_SameNodeExchange (6.71s)
    --- PASS: TestVLANTransport_SameNodeExchange/native/public-tagged=false/bond=false/dispatch=false (0.66s)
    --- PASS: TestVLANTransport_SameNodeExchange/native/public-tagged=false/bond=true/dispatch=false (0.64s)
    --- PASS: TestVLANTransport_SameNodeExchange/native/public-tagged=true/bond=false/dispatch=false (0.66s)
    --- PASS: TestVLANTransport_SameNodeExchange/native/public-tagged=true/bond=true/dispatch=false (0.68s)
    --- PASS: TestVLANTransport_SameNodeExchange/native/public-tagged=true/bond=true/dispatch=true (0.67s)
    --- PASS: TestVLANTransport_SameNodeExchange/generic/public-tagged=false/bond=false/dispatch=false (0.67s)
    --- PASS: TestVLANTransport_SameNodeExchange/generic/public-tagged=false/bond=true/dispatch=false (0.70s)
    --- PASS: TestVLANTransport_SameNodeExchange/generic/public-tagged=true/bond=false/dispatch=false (0.68s)
    --- PASS: TestVLANTransport_SameNodeExchange/generic/public-tagged=true/bond=true/dispatch=false (0.67s)
    --- PASS: TestVLANTransport_SameNodeExchange/generic/public-tagged=true/bond=true/dispatch=true (0.66s)
PASS

TestAttach_HeadOfTCXAheadOfClusterCNI (internal/plumbing/ebpf/attach) checks four things on a real kernel:

  1. usid_ingress lands first in the tcx chain, ahead of a CNI program that is already attached.
  2. It appears once, however often it is re-attached.
  3. IngressAttachedTo passes.
  4. After Detach, only the CNI program is left and IngressAttachedTo fails.

The IngressAttachedTo unit test gains tcx-ordering cases.

Validation

  • task lint, task build and task test:unit pass.
  • With -race as root in a privileged container, these packages pass: attach, edgeattach, attachreg, prog and installer.
  • The full root suite also ran in that container. The only failures were tests that need iptables (missing from the image) or that hit netlink churn, plus a default route the container already holds. None are in the packages this change touches. CI's root job is the reference run.

The lab was not run. Row V10 in C4 is retested in #1405's final retest.

IngressAttachedTo read the first tcx program's name to tell usid_ingress
from another program, but opening a program by ID needs CAP_SYS_ADMIN,
which galactic-gateway does not hold. The check would then fail with the
head link in place, and the gateway would never report local delivery.

Compare the first program's ID with the program of the head link
galactic-cni pinned, which needs no more than CAP_BPF, and keep the
name only as a fallback.
@privateip privateip changed the title fix(attach): Same-node delivery on a tagged public side reaches the backend fix(attach): Deliver same-node traffic on a tagged public side Dec 1, 2026
@privateip
privateip marked this pull request as ready for review December 1, 2026 10:00
@privateip
privateip requested a review from a team as a code owner December 1, 2026 10:00
@privateip
privateip merged commit 0b2f841 into epic/1399-vlan-transport Dec 1, 2026
29 checks passed
@privateip
privateip deleted the fix/issue-1556 branch December 1, 2026 10:00
@privateip

Copy link
Copy Markdown
Contributor Author

Both reviewers agreed on a second pass over head 0b74461: pr-rereviewer returned merge, and pr-conventions-reviewer returned merge. The remaining notes were a cosmetic commit-subject nit that the 72-character rule already satisfies, merge-order notes on #598, #1558, #1549 and #1559, and a reminder to wait for the CI root job, which was done.

The first pass held on two points. The adversarial reviewer held on the name lookup that needed CAP_SYS_ADMIN, which commit 0b74461 fixed. The conventions reviewer held on the title and body, which were rewritten. No findings from the second pass needed applying.

Each reviewer ran its own read of the diff against the base branch and the repository's conventions; the per-reviewer RAN lists were not carried into this hand-off, so they are not reproduced here.

CI on 0b74461: all checks passed (26 passed, 2 skipped by design). The ruleset on the base branch has no pull-request rule, so there is no required review and auto-merge can complete without a human approval. The merge method was the default merge commit, and the PR merged as soon as it was marked ready.

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