Skip to content

Gateway drops new TCP flows for 30 s after its node rejoins the fabric #1085

Description

@privateip

Summary

A gateway node that rejoins the fabric drops most new TCP flows to a VIP for up to about 30 seconds after the fabric routes the VIP to it again. The edge XDP program (internal/plumbing/ebpf/edgeprog/edgedsr.c) treats BPF_FIB_LKUP_RET_NO_NEIGH like any other FIB failure: it counts fib_no_neigh and returns XDP_DROP. Nothing then prompts the kernel to resolve the missing neighbor, so the gateway keeps dropping until the kernel learns the neighbor some other way.

task verify:gateway-node-loss in the containerlab lab fails on this, reproducibly.

Steps to reproduce

  1. Deploy the lab from main with task deploy.
  2. Run task verify:gateway-node-loss. It takes one gateway node's fabric links down, checks the VIP through the site's other gateway node, brings the links back, waits until the transit router routes the VIP through the returning node and LACP settles, then checks the VIP through it.

What happens

The check through the returning node answers 1 or 3 of 8 TCP flows, while all 8 UDP flows succeed, and the task fails. The returning node's galactic_edge_drops_total{reason="fib_no_neigh"} rises, as does its TCP rule-drop counter for the VIP. A check repeated about 30 seconds later answers 8 of 8, and so does every check afterwards.

Expected

A gateway node serves every flow the fabric sends it from the moment it advertises the VIP again. When a FIB lookup returns NO_NEIGH, the packet should either reach the kernel so it resolves the neighbor, as usid_ingress does for the same case, or the gateway should resolve its next hops before it advertises.

Notes

The same counter has been seen rising on gateway restarts, which may also explain occasional lost VIP requests in verify:gateway-restart.

Activity

  1. added theissue type on Oct 24, 2026
  2. self-assigned this
    on Oct 25, 2026
  3. privateip commented on Oct 26, 2026

    @privateip
    ContributorAuthor

    The NO_NEIGH drop this issue names is real, but it is not what loses most of the flows. In the lab it costs one packet per rejoin, and #1101 hands that packet to the kernel instead. With #1101 deployed, the node-loss check still answers 3 of 8 TCP flows in 6 of 9 runs, with no gateway drop counter moving.

    The main cause is a gap between the two directions after the links come back. The transit router starts hashing VIP flows to the returning gateway node within a second, before its BGP table holds the node's path again. The node's own route back to the clients returns 3 to 33 seconds later. Until it does, the reply path's FIB lookup resolves the client through the node's default route, which in the lab is the management interface. The XDP redirect to that interface fails inside the kernel after the program has returned, so no gateway counter records the loss.

    UDP only looked healthy because the check runs its UDP flows after the TCP ones, by which time the route is back.

    Still open:

    • Why the transit router's forwarding regains the node's next hop before BGP re-learns its path, and whether production upstreams behave the same way.
    • The gateway cannot see these drops at all. A redirect to an interface the XDP program does not run on should at least be counted.
  4. privateip commented on Nov 17, 2026

    @privateip
    ContributorAuthor

    Re-checked against main at 974132e. The issue is still valid, and part of it is fixed.

    Fixed on main

    Still open

    • The main cause, a withdrawn ECMP next hop reinstalled before BGP is up, is fixed by draft fix(fabric-router): Stop zebra reinstalling withdrawn next hops #1114 (FRR zebra patch). It still merges cleanly into main, its CI is green, and it targets the FRR 10.7.1 that main pins. The arm64 image build is the only item left in its test plan.
    • edge_return still drops a reply whose next hop has no neighbor entry (edgedsr.c edge_return_v6/edge_return_v4, count_fib_drop then XDP_DROP). Handing that reply to the kernel, the way fix(gateway): Let the kernel resolve an unresolved next hop #1101 does on the forward path, would not help. The kernel has no conntrack entry for a DSR reply, so it marks the reply INVALID and KUBE-FORWARD drops it before neighbor resolution starts. This is the reason edge_return exists (see its header comment).
    • A redirect that fails inside the kernel after the program returns is still invisible. leave_via counts only a refused bpf_redirect call, and nothing observes xdp:xdp_redirect_err. This is how the lab's replies to the management interface were lost without any gateway counter moving.

    I have not re-run verify:gateway-node-loss this time. The only running lab belongs to other work, and the check takes fabric links down. The run results above in this thread still stand.

  5. privateip commented on Nov 17, 2026

    @privateip
    ContributorAuthor

    Plan for the part with no fix yet: making redirect transmit failures visible.

    Root cause. leave_via in internal/plumbing/ebpf/edgeprog/edgedsr.c counts redirect_failed only when the bpf_redirect call itself is refused. A redirect can still fail in the kernel after the program has returned:

    • If the target device has no ndo_xdp_xmit, the kernel fires xdp:xdp_redirect_err.
    • If the target is a veth whose peer runs no XDP program, the frames are dropped at flush and the kernel fires xdp:xdp_bulk_tx with drops > 0.

    Nothing in galactic observes either tracepoint.

    Fix.

    • A small BPF tracepoint program counts both events, keyed by target ifindex and errno.
    • galactic-gateway attaches it with the edge datapath and keeps running without it if the attach fails.
    • edgemetrics exports it as galactic_edge_redirect_xmit_drops_total{ifname,reason}.
    • docs/gateway/packet-paths.md documents it.

    I chose this over checking in the hot path whether each egress interface can transmit XDP frames. That check would need userspace to track every interface's XDP features, and a veth's answer changes with its peer.

    Tests. A root-gated test sends a VIP reply through edge_return to a veth whose peer has no XDP program and asserts that the counter counts the dropped frame. The test fails on main. A collector unit test covers the metric.

    Risk. The change adds observability only, with no change to any packet verdict. xdp_bulk_tx has no program ID, so its count covers every XDP program on the node that redirects, and the ifname label separates them.

    Not covered. edge_return still drops a reply whose next hop has no neighbor entry. As noted above, a kernel handoff would not help there. The issue also stays open until #1114 lands.

  6. privateip commented on Nov 17, 2026

    @privateip
    ContributorAuthor

    Implementation changes to the plan above, found while building and testing the fix:

    • Raw tracepoints instead of tracepoints. A tracepoint attach looks up the event through tracefs, which the gateway pod does not mount, so it would always fail there. The programs attach to xdp_redirect_err and xdp_bulk_tx as raw tracepoints, by name, and read the target ifindex through a CO-RE relocation against the kernel's BTF. On a kernel whose xdp_redirect_err arguments differ, the error is still counted, under ifindex 0.
    • The veth example was wrong. On Linux 7.3, a native XDP redirect into a veth whose peer runs no XDP program was delivered. The case the counter covers is a target whose driver has no ndo_xdp_xmit, which reports redirect_eopnotsupp. The docs and help text no longer name veth.
    • Test setup. The regression test sends a VIP reply through edge_return to a dummy interface. The reply arrives over a veth, because XDP on a veth runs from NAPI and flushes redirects as a NIC driver does, while a tap's write path never flushes them. On main, edge_return claims the reply, counts no drop, and the frame never leaves the dummy. With the fix, the counter records it under redirect_eopnotsupp.
    • Labels and attribution. The labels are interface and reason. Neither tracepoint can be tied to the gateway's programs: under the dispatcher, xdp_redirect_err reports the dispatcher's program ID. So both stages count every XDP program on the node.
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