Skip to content

galactic-nat leaves Local pair pins and map rows when its datapath is disabled #1479

Closed

Description

@privateip

Summary

Since #1461, galactic-nat pins state for each Local pair so that a restart keeps sessions translating: a native XDP link at /sys/fs/bpf/galactic-nat/links/local-<NAT end> (cmd/galactic-nat/workerlocal.go), plus rows in nat_local_pair, nat_local_return and nat_vlan_egress (internal/plumbing/ebpf/natmap/local.go).

That state is removed only while the Worker integration is running: per claim through Unprogram/detach, and as stale rows through Prune, which only cmd/galactic-nat/worker.go calls. The integration starts only when worker_socket is set and the datapath is enabled (cmd/galactic-nat/root.go). turnOffDatapath (cmd/galactic-nat/nat.go) clears the dispatcher slot but leaves the Local pins and rows, and there is no uninstall hook.

The lab case shows the gap. deploy/containerlab/scripts/verify-nat-local.sh removes the pins and deletes the map rows by hand during teardown, with a comment that names this gap.

Impact

When the integration is switched off, the datapath is set to disabled, or galactic-nat is uninstalled, the pinned XDP links stay attached to any pair that still exists. Local pairs then keep translating after the shard reports DatapathDisabled and its advertisement is withdrawn. That lasts until Worker withdraws the claims at session-lease expiry (120 s by default) and deletes the pairs. This is inferred from the code and the restart behavior; it was not measured for the disable case.

Afterwards, pins and rows keyed to deleted interfaces stay behind until a later start with the integration on runs Prune. No cross-tenant effect was found.

Expected behavior

Starting galactic-nat with the integration off or the datapath disabled removes its Local pins and rows, the same as Prune with an empty keep set. Uninstalling galactic-nat removes them as well, or the operations docs state the cleanup step.

Parent criterion

Part of #1430: NAT66 and NAT64 integrate with Local delivery and stop translating when the shard's datapath is disabled.

Acceptance

  • Unit (cmd/galactic-nat): with worker_socket empty, or the datapath disabled, startup calls the Local plumbing's Prune with an empty keep set (fake plumbing).
  • Root test: pins and rows left by a prior run are gone after such a start (kernel Local plumbing).
  • Lab: verify:nat-local-shard's teardown disables the datapath (or unsets worker_socket), restarts galactic-nat, and passes verify-nat-local-clean.sh's pin and row checks before any manual removal. The manual rm and bpftool deletes in verify-nat-local.sh are removed.
  • task ci passes.

Activity

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

    @privateip
    ContributorAuthor

    Confirmed against integration/galactic-worker at f32863f, from source:

    • runCmd in cmd/galactic-nat/root.go starts the Worker integration only when worker_socket is set and the datapath is enabled. No other branch touches Local state.
    • turnOffDatapath (cmd/galactic-nat/nat.go) empties only the dispatcher slot.
    • kernelLocal.Prune (cmd/galactic-nat/workerlocal.go) is called only from worker.go, inside the running integration.

    Two more gaps, beyond the issue text:

    • Prune never removes nat_vlan_egress rows, yet verify-nat-local-clean.sh requires that map to be empty.
    • Prune fails if the links pin directory is missing.

    No runtime reproduction yet. The lab case will confirm the fix.

  4. privateip commented on Nov 21, 2026

    @privateip
    ContributorAuthor

    Plan for the fix, on branch fix/issue-1479 against integration/galactic-worker:

    1. Startup cleanup. When worker_socket is empty or the datapath is disabled, galactic-nat calls the Local plumbing's Prune with an empty keep set.
      • With the datapath enabled, it uses the maps the process loaded.
      • With the datapath disabled, it opens the pinned nat_local_pair, nat_local_return and nat_vlan_egress maps. A pin that is missing counts as empty. Nothing is created on a node that never ran galactic-nat.
      • A failure is logged and startup continues, like turnOffDatapath.
    2. Prune. With an empty keep set, Prune also clears nat_vlan_egress. Only kernelLocal.syncVLANs writes that map; nat.c only reads it. A missing links directory counts as empty.
    3. Tests.
      • Unit, with fake plumbing: Prune(nil) runs, and the integration doesn't start, when worker_socket is empty or the datapath is disabled. When both are on, the integration starts and Prune isn't called.
      • Root, with the kernel plumbing: a pair is programmed, with a VLAN row, and the objects are closed. After a start with the integration off:
        • the link pin is gone;
        • the NAT end runs no XDP program;
        • all three maps are empty;
        • a second start is a no-op.
    4. Lab. verify-nat-local.sh already restarts galactic-nat without GALACTIC_NAT_WORKER_SOCKET during teardown. Right after that restart, it now checks that the pins and rows are gone, while Local's pairs still exist. The manual rm and bpftool deletes are removed.
    5. Docs. docs/nat/configuration.md describes the cleanup at startup and the step to take on uninstall.

    Behavior change: a restart with the integration off stops Local translation at once instead of at lease expiry. No API or config changes.

  5. privateip commented on Nov 21, 2026

    @privateip
    ContributorAuthor

    Fixed by #1480, merged into integration/galactic-worker as 252ce63.

    galactic-nat now removes its Local pair links and map rows when it starts with worker_socket empty or the datapath disabled. The lab case showed them removed while 4 Local pairs still existed, with no manual cleanup. The uninstall step is in docs/nat/configuration.md.

    The change is not yet on main or in a release. It ships with the integration branch.

  6. added 3 commits that reference this issue on Nov 24, 2026
    982aaf3
    7b3bc6b
    88afee1
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