Skip to content

fix(gateway): Let the kernel resolve an unresolved next hop - #1101

Merged
privateip merged 1 commit into
mainfrom
fix/issue-1085
Oct 26, 2026
Merged

privateip merged 1 commit into
mainfrom
fix/issue-1085

Conversation

@privateip

@privateip privateip commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The gateway's load balancer drops every packet whose next hop toward the backend has no neighbor entry yet, and nothing asks the kernel to resolve it, so the drops last until the kernel learns the neighbor some other way.

It now hands those packets to the kernel, which resolves the neighbor and forwards them, while later packets stay on the fast path. A new counter tracks these handoffs, and they no longer count as drops.

This removes one cause of the TCP flows a gateway node loses after rejoining the fabric, not the main one, which the linked issue tracks.

Test plan

  • On a real kernel, the first packet to an unresolved next hop reaches it, the kernel resolves the neighbor, and the next packet stays on the fast path with no drops
  • IPv6 and IPv4 VIP packets leave correctly framed and count as handoffs, and these tests fail on the previous datapath
  • Lint, build, unit, root-gated and end-to-end tests pass, and the lab's gateway ingress, restart and backend-health checks pass

Related to #1085

🤖 Generated with Claude Code

@privateip privateip self-assigned this Oct 25, 2026
@privateip
privateip force-pushed the fix/issue-1085 branch 2 times, most recently from 1f1ead7 to 433ade9 Compare October 26, 2026 01:08
@privateip privateip changed the title fix(gateway): Forward VIP packets whose next hop is still unresolved fix(gateway): Let the kernel resolve an unresolved next hop Oct 26, 2026
edge_lb dropped every load-balanced packet whose FIB lookup returned BPF_FIB_LKUP_RET_NO_NEIGH. XDP cannot start neighbor resolution, so nothing asked the kernel to resolve the next hop toward the backend, and packets to it kept dropping until the kernel learned the neighbor some other way, as after a link flap or a gateway restart.

push_outer_header now hands such a packet to the kernel instead. It keeps the encapsulation, writes the arriving frame's MAC addresses in front of it so the stack takes it as addressed to this host, and edge_lb returns XDP_PASS without going through the dispatcher's later slots. The kernel forwards it to the backend's uSID, queuing it while it solicits the neighbor, and later packets find the entry and stay in XDP.

These packets are not counted as drops: they no longer move fib_no_neigh or the VIP's dropped packets, and are counted in a new single-entry neigh_fallbacks map, exported as galactic_edge_neigh_fallbacks_total. The counter records the handoff, not delivery: the kernel drops what it cannot resolve, and on this path the packet crosses the node's netfilter FORWARD hook, which the XDP path never does. A new map rather than a drop_reasons slot leaves every existing pinned map's layout unchanged, so upgrade and rollback recreate nothing.

edge_return and the ICMP error paths still drop on NO_NEIGH: a DSR reply passed to the kernel is INVALID to connection tracking and kube-proxy drops it before any neighbor lookup.

verify-gateway-backend-health.sh sent a TCP request ahead of its fixed-port UDP probes only because edge_lb dropped the first packets to an unresolved next hop, so that warm-up goes.

A real-kernel test attaches edge_lb to a tap uplink with the backend's next hop in another namespace, and shows the first packet reaching that next hop, the kernel resolving the neighbor, and the second packet staying in XDP with no drop reason moving. Test runs check the framing and counters for IPv6 and IPv4 VIPs. Both fail against the previous datapath.

This removes one cause of the TCP flows a gateway node loses after rejoining the fabric, not the main one, which is tracked in the issue.

Related to #1085

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@privateip
privateip marked this pull request as ready for review October 26, 2026 01:43
@privateip
privateip requested a review from a team as a code owner October 26, 2026 01:43
@privateip
privateip enabled auto-merge October 26, 2026 01:43
@privateip

privateip commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

The first review pass at 8a64d8c held. pr-adversary found no blocker; its decisions were the unrun lab node-loss check and the unrun root tests and CI, and its warning was that host-firewall drops on the kernel handoff path are invisible. pr-conventions-reviewer held on warnings (commit subject over 72 characters, summary over four sentences), a squash nit, and decisions on landing order against #845 and a lab check before merge. Between them they ran diff and file reads, gh pr checks, an open-PR overlap scan, go vet and the edgemetrics unit tests.

The human then decided the open items. The lab was redeployed from the branch and the gateway ingress, restart and backend-health checks pass. The node-loss check still fails for a different cause on main (the returning node's route back to clients lags the transit router sending it VIP traffic, and the reply redirect fails uncounted), which is recorded on #1085. The PR was narrowed to "Related to #1085", #1101 lands before #845, the firewall caveat is documentation only, and the human chose to ship now and soak on staging. The human also approved squashing the branch into one commit, done before the second pass.

The second pass at 433ade9 had pr-rereviewer hold on one item, the firewall caveat missing from the metric help and metrics reference, with every other first-pass finding confirmed fixed, and pr-conventions-reviewer returned MERGE. The caveat was then added to the metric help and the metrics reference at 5bd2c07, with edgemetrics tests and lint passing, and the human approved it.

Local validation on the code, unchanged since 8a64d8c apart from that help text and doc sentence: lint, build, unit tests, root-gated tests for the edge packages and the Kind e2e all passed.

CI on 5bd2c07: all 18 checks pass, including Build, Lint, Unit Tests, Unit Tests (root) and E2E Tests. The first Build run timed out installing dependencies and passed on re-run.

Auto-merge is enabled with the merge method. The ruleset requires one approving review with code owner review and last-push approval, so the PR waits for a human approval.

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

Unresolved next hop now goes to the kernel via XDP_PASS instead of being dropped, and the oversize/PTB check still runs first since the FIB lookup reports FRAG_NEEDED before NO_NEIGH. No new loop or VRF leak: the kernel routes in the ingress interface's VRF, the same context the FIB lookup used, and XDP only runs on ingress so the forwarded packet is not re-captured.

  • Real-kernel coverage is genuine: TestEdgeLB_KernelResolvesUnresolvedNextHop uses a veth pair with no neighbor entry, asserts none exists beforehand, then asserts the packet reaches the next hop, a valid entry appears, and the second packet stays in XDP (fallbacks stays 1, zero drops). The IPv6 and IPv4 VIP cases are covered by the test-run table test, and the outer next header is checked for 41 versus 4.
  • Behaviour is the same on a roll: XDP_PASS skips the dispatcher's later slots, but only for the unresolved-hop packet, and it is bounded by the first resolution.
  • edgedsr.c push_outer_header: the fallback restores the original MACs and sets EtherType to IPv6. This assumes an untagged frame with a 14-byte Ethernet header, which holds where VLANs are offloaded to the NIC; a software-tagged frame would be mis-framed.
  • The fallback leaves the inner packet and outer source (the gateway's own encap source) untouched, so the kernel sees a forwarded packet sourced from a local address. That is fine with IPv6 and no rp_filter, but is unexercised under a restrictive host firewall (documented in the PR).

Follow-ups:

  • If net.ipv6.conf.*.forwarding is 0 on a gateway node, XDP_PASS packets are dropped by the kernel silently while neigh_fallbacks_total still rises. Consider an alert or a startup check; the metric doc says it counts the handoff, not delivery.
  • No test covers a next hop that never answers (kernel drops after queueing). Worth a case that checks no loop or growth.
  • Staging soak before the stable sites pick up the gateway image; the change lands on an edge datapath that tracks the release tag.

@privateip
privateip merged commit 04333af into main Oct 26, 2026
22 of 23 checks passed
@privateip
privateip deleted the fix/issue-1085 branch October 26, 2026 01:49
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.

3 participants