Skip to content

Integrate Gateway Maglev selection and direct server return #1438

Closed

Description

@privateip

Parent: Deliver Galactic Worker with Local and Fabric delivery for tenant services

Deliverable

External VIP traffic reaches a local or remote backend selected by Maglev and returns directly to the client (DSR). It satisfies the NLB part of the "Deliver service consumers" phase exit.

References:

  • Datapath: internal/plumbing/ebpf/edgeprog/edgedsr.c (edge_lb, edge_return).
  • Maglev: internal/maglev, internal/gateway/kerneldatapath.go (buildMaglevTable, KernelDatapath.ApplyRule).
  • Attach: cmd/galactic-gateway/gateway.go (joinDispatcher, attachDirect) and internal/plumbing/ebpf/edgeattach (ResolveTargets).
  • Backend SID: internal/plumbing/srv6/usid.go (ComputeBackendSID, BackendSlot).

#1411 (allocated backend SIDs) is related and does not block this Task. This Task works with today's hashed BackendSlot and must not prevent a later switch to allocated SIDs.

Work items

  • Add backend destination resolution to Worker. Implement Worker reconciliation and its authenticated service API #1433 ships the backend destination kind as Resolved=False/DestinationKindUnsupported; this Task replaces that with resolution from the gateway's backend SID and locator, and documents the source in docs/worker/contract.md.
  • Apply locality after the shared Maglev selection. Implement the dispatcher-claimed local handoff at each public RX path, keeping backend SID and translation bindings. Keep the existing remote encapsulation path.
  • Coordinate NAT and gateway dispatcher claims on the shared NIC (slots SlotGatewayLB, SlotGatewayReturn, SlotNAT).
  • Verify the DSR reverse binding, port restoration, public next hop and public-service policy on TAP ingress.
  • Define per-family withdrawal when handoff coverage fails, including bond member changes and client-facing aggregate routes.
  • Expose the gateway's Worker capability state and failure reasons through existing gateway diagnostics and metrics.

Dependencies

Blocked by #1434, #1435 and #1436. Runs in parallel with #1437, #1439 and #1440.

Acceptance

Run in the #1432 topology with external clients only:

  • IPv4 and IPv6 VIPs carry TCP and UDP for every combination of gateway placement and local or remote backend placement. Each request reaches the correct TAP, and each public reply carries the VIP and service port.
  • When a hook or a public neighbor is removed, captures show the withdrawal, the change in actual ingress reachability, and isolation from default NAT.
  • The lab checks verify:gateway, verify:gateway-ingress, verify:gateway-ingress-ipv4 and verify:gateway-restart still pass.
  • The delivering PR targets integration/galactic-worker, carries this evidence and says Fixes datum-cloud/galactic#1438. GitHub does not auto-close from a non-default base, so close this issue explicitly when the PR merges and record the PR and merged SHA.

Activity

  1. added theissue type on Nov 18, 2026
  2. self-assigned this
    on Nov 19, 2026
  3. privateip commented on Nov 19, 2026

    @privateip
    ContributorAuthor

    Triage

    Valid on integration/galactic-worker at 0967308, confirmed by reading the source:

    • resolveDestination answers every backend destination with DestinationKindUnsupported (internal/worker/reconcile.go).
    • edge_lb always encapsulates toward the backend SID (lb_forward in internal/plumbing/ebpf/edgeprog/edgedsr.c), so a backend on the gateway's own node is never reached through the Local handoff.
    • local_rx accepts IPv6 only and applies no VIP translation, and local_meta.h carries only the TAP, so a Local delivery could not keep the backend SID or its translation binding.
    • When the gateway loses coverage of a public target, it fails readiness and keeps advertising.

    Plan

    Backend resolver. Worker resolves a BackendRef{node, slot} from the Bound ServiceVIPBinding that galactic-router wrote for that node, where BackendSlot(backendAddress, backendPort) equals the slot. The binding's target attachment supplies the VPC, TAP and addresses, and BGPRouter supplies the node's locator. Worker recomputes the backend SID and takes nothing from the request. The backend resolves to Local on this node and to Fabric anywhere else. If the binding isn't Bound, or two bindings share a slot, the destination reports why. #1411 later changes only the slot lookup.

    Locality after Maglev. Every gateway keeps the same Maglev table. After a backend is selected, a per-node map from backend SID to TAP decides where it goes:

    • Hit: edge_lb hands off to Local through dispatcher metadata (version 2: TAP plus backend SID) and returns XDP_PASS.
    • Miss: the existing SRv6 encapsulation, unchanged.

    The gateway fills the map only from Worker claim status that reports Ready. local_rx then:

    • checks that the SID names this node and the TAP's VRF;
    • applies the same vip_xlat_table row usid_ingress uses, keyed on the slot (with SIIT for IPv4 VIPs);
    • decides PublicService policy, sets the decided mark, and redirects into the TAP.

    DSR return (D43). A guest's reply takes the existing VIP branch of usid_egress:

    • it applies the reverse binding and restores the service port;
    • for an IPv4 VIP it translates back to IPv4;
    • it redirects to public_uplink_table before any egress_route_table lookup.

    So a reply needs neither a default pass-through nor a Local branch in usid_egress, and never reaches default NAT.

    Local backend not Ready. Worker never falls back from Local to Fabric. A Local backend whose handoff isn't Ready is reported through the existing backend-health mechanism, so it leaves Maglev selection on every gateway, as an unhealthy backend does today. Until that converges, its flows are dropped and counted (DROP_REASON_LOCAL_UNAVAILABLE), and the VIP stays served.

    Per-family withdrawal (D44). Only a loss of public-path coverage withdraws anything: a public target losing load-balancer coverage (bond members included), or no public_uplink_table row for a family. The gateway then withdraws that family's advertisement for each affected rule. A covering client-facing aggregate is reported as AggregateStillAttracts; the gateway doesn't suppress it.

    Dispatcher sharing. Gateway (SlotGatewayLB, SlotGatewayReturn) and NAT (SlotNAT) keep separate slots and leases on the shared NIC. A root test checks that releasing either side leaves the other serving.

    Diagnostics. Gateway conditions and metrics report the Worker capability state, the Local handoff state and withdrawn families.

    Lab. Combined placement is guests hosted on the gateway edge nodes (dfw-worker2, dfw-worker3). Compute workers (dfw-worker, dfw-worker4) host remote backends only; the gateway doesn't run on compute workers. The new check covers IPv4 and IPv6 VIPs over TCP and UDP from external clients, with every gateway placed against a local backend, the other edge node's backend and both compute workers' backends. It also shows:

    • a single Local backend's hook removal taking it out of selection while the VIP is still served;
    • a public-path coverage loss withdrawing the family;
    • isolation from default NAT.

    The existing gateway checks are rerun.

    Tests. Worker resolver unit tests, edge_lb-to-TAP and reply root tests (IPv4 and IPv6, TCP and UDP), dispatcher slot sharing, backend-health feed and per-family withdrawal controller tests, plus task ci and the root suite.

  4. privateip commented on Nov 19, 2026

    @privateip
    ContributorAuthor

    Deviations from the approved plan

    The coordinator has approved both.

    1. A missing public uplink also marks local backends not ready. While this node's public_uplink_table has no next hop, the gateway reports every backend on its node as not ready in NetworkGateway status.localBackends, with reason PublicUplinkMissing. galactic-router then publishes LocalHandoffNotReady for those backends, so every gateway takes them out of Maglev selection. This is in addition to the planned per-family withdrawal (D44). Those backends' replies leave through that single next hop, so they fail whichever gateway selected them.
    2. The lab proves removal from selection with TAP carrier loss. Worker re-attaches a removed local_rx in the same resync pass that reads it back, so removing that hook never shows up as not ready. The lab therefore checks a different thing for each failure:
      • Removing local_rx: Worker repairs it within its resync, and no flow to the affected backend is encapsulated in the meantime.
      • A guest's TAP losing carrier: the backend goes LocalHandoffNotReady, leaves selection on every gateway, the VIP is still served by its other backends, and the backend recovers.

    Two further points:

    • The lab withdraws the site aggregate. In the lab, the site's FRR originates each VIP aggregate to Null0. During the withdrawal step, verify:gateway-local also withdraws that aggregate for the family under test, through a lab-only fixture, so the change in actual ingress reachability is visible. The gateway cannot see aggregates originated in FRR config, so AggregateStillAttracts only reports covering BGPAdvertisements.
    • Local handoff needs backend health filtering. Taking a not-ready Local backend out of selection depends on GALACTIC_GATEWAY_BACKEND_HEALTH being on for every gateway. Without it, the gateway only drops that backend's flows.
  5. privateip commented on Nov 21, 2026

    @privateip
    ContributorAuthor

    Draft PR #1474, stacked on #1461.

  6. privateip commented on Nov 22, 2026

    @privateip
    ContributorAuthor

    Delivered by #1474, merged into integration/galactic-worker as e97daf7. The lab evidence for each acceptance bullet is on the PR. The change also fixes a Worker Local defect found during the lab runs: the public receive program sat behind a cluster CNI's tcx program on the bond master.

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