Skip to content

Integrate NAT66 and NAT64 with Local and Fabric shard delivery #1437

Closed

Description

@privateip

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

Deliverable

Ordered and hashed NAT66 and NAT64 egress selects a ready colocated shard through Local and keeps remote shard delivery through Fabric. It satisfies the NAT part of the "Deliver service consumers" phase exit.

Today ShardCandidate.Local in internal/plumbing/ebpf/egressroutemap/shardgroup.go excludes a node's own shard: it is never alive for tenants on that node. This Task replaces that exclusion with readiness-gated local selection.

References:

  • Selection: ShardGroupTable.Apply, GroupPolicy, TranslationClass and NAT64Class.
  • Node driver: internal/installer/egressgroup.go (egressShardCandidates, spec.drain, spec.nat64Standby).
  • Datapath: internal/plumbing/ebpf/natprog/nat.c (nat_ingress, nat66_*, nat64_*, nat_conn_table) and internal/plumbing/ebpf/natmap/conntable.go.
  • Service: cmd/galactic-nat/nat.go (setupNatDatapath).

Work items

  • Add shard destination resolution to Worker. Implement Worker reconciliation and its authenticated service API #1433 ships the shard destination kind as Resolved=False/DestinationKindUnsupported; this Task replaces that with resolution from NAT's trusted shard identity and locator, and documents the source in docs/worker/contract.md.
  • Make initial selection and refresh respect local readiness, class eligibility, drain, pins and standby.
  • Carry tenant identity from TAP ingress across the internal receive pair. Use one shard-owned session table at both the internal and the public XDP entries.
  • Return using the saved backend SID and physical locator. Route public masquerade addresses to their owning shard. Keep the shard locator distinct from the tenant-router locator.
  • Limit a pair failure to the affected eligibility, and document which established sessions survive it.
  • Expose NAT's Worker capability state and failure reasons through existing NAT diagnostics and go.miloapis.com/instrumentation metrics.

Dependencies

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

Acceptance

Run in the #1432 topology with one local and one remote shard path:

  • Both translations work for TCP, UDP and supported ICMP, with overlapping guest addresses and ports. Each guest sees the right external source and reverse delivery, including NAT64 IPv4 replies.
  • After the pair is recreated, NAT restarts and a shard drains, pins hold and state is reused as the contract says, and captures show no underlay hairpin.
  • task test:unit covers the selection changes, and the lab checks verify:nat-sharding, verify:nat-egress and verify:nat-return-route still pass.
  • The delivering PR targets integration/galactic-worker, carries this evidence and says Fixes datum-cloud/galactic#1437. 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

    Checked against integration/galactic-worker at 6e0de37.

    • resolveDestination in internal/worker/reconcile.go refuses every shard destination with DestinationKindUnsupported.
    • ShardGroupTable.Apply never marks a local shard alive, and anyPrimaryAlive ignores it. The datapath treats the LOCAL flag as metrics only (prog/usid.c, egress_shard_member.flags).
    • nat.c only accepts SRv6. It reads the tenant from the uSID Argument and the outer source, keys sessions on that source (conn_key.encap_src), and always re-encapsulates the return.

    So a tenant always reaches a remote shard, even when a ready shard runs on its own node.

    Plan

    1. Shard resolver in Worker. A ShardRef gains name, which names an EgressShard; a request that sets group or index is refused with MalformedSpec. A shard resolves only when it is not being deleted, has status.shardSID, and is Programmed and Ready. It is Local when spec.targetRef names this node, and Fabric otherwise. The shard's locator stays distinct from the node's router locator.
    2. NAT's claim. galactic-nat makes one veth_pair claim per VPC, with the EgressShard UID as attachment_uid. Worker allows that only when all three hold:
      • the caller is galactic-nat's ServiceAccount;
      • every destination is a shard;
      • the VPC has an admitted VPCAttachment on this node.
    3. Local selection.
      • A ready local candidate becomes alive. Drain, pins, NAT64 standby and class eligibility keep their current rules.
      • Worker writes a per-VPC egress_local_shard row while that VPC's pair is ready.
      • When usid_egress chooses the local member for an eligible VPC, it hands the packet to the Local tc program, unencapsulated, through skb->cb. That program redirects it into the pair.
      • A VPC with no row takes exactly today's path. This amends D28 under a new decision.
      • In ordered mode, Worker writes a PassThroughLocalNAT class route.
    4. NAT on the pair.
      • nat_ingress attaches natively to the pair's NAT end, outside the XDP dispatcher.
      • A map keyed by the NAT end supplies the VPC's Argument and this node's SID, so one session table serves both entry points without a layout change.
      • A return whose saved SID is on this node's locator is redirected into the pair, unencapsulated. Every other return is re-encapsulated as today.
    5. Failure scope. A pair failure removes only that VPC's eligibility. After the pair is recreated or NAT restarts, sessions are reused. A VPC's established flows through the local shard break only while that VPC's pair is down.
    6. Diagnostics. NAT state metrics show the Worker session, capability state and per-VPC Local handoff readiness with a reason. New datapath counters cover local forward, local return and a missing pair.

    Tests

    • Unit: selection and the resolver.
    • Root: NAT66 and NAT64 over the pair with overlapping guests, return through the pair, reuse after the pair is recreated, the ineligible-VPC path, and parity of the no-row path.
    • Lab: one local and one remote shard path, with captures, plus the existing NAT checks.
  4. privateip commented on Nov 21, 2026

    @privateip
    ContributorAuthor

    Fixed by #1461, merged into integration/galactic-worker as f32863f. NAT66 and NAT64 egress now use the node's own shard through a veth pair when it is ready, and the lab evidence is in the PR comments.

    Two follow-ups for the epic remain: the shard's IPv4 masquerade address is not advertised to the fabric, and removing galactic-nat leaves the pair links and rows it pinned.

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