[3/3] [nat] unify per-family NAT mapping - #336
Open
nicolaskagami wants to merge 1 commit into
Open
Conversation
This was referenced Aug 6, 2026
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 6, 2026 13:44
2c7f158 to
ce64fd3
Compare
nicolaskagami
force-pushed
the
nsk/nat-3-natmap
branch
from
August 6, 2026 13:46
4dc3943 to
529d8bc
Compare
nicolaskagami
marked this pull request as ready for review
August 6, 2026 18:00
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 7, 2026 12:48
ce64fd3 to
22d9c68
Compare
nicolaskagami
force-pushed
the
nsk/nat-3-natmap
branch
2 times, most recently
from
August 7, 2026 13:47
789c30c to
61774ca
Compare
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 7, 2026 13:47
22d9c68 to
1b86758
Compare
nicolaskagami
force-pushed
the
nsk/nat-3-natmap
branch
from
August 7, 2026 18:20
61774ca to
a1c1e4e
Compare
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 7, 2026 18:48
1b86758 to
6265bc6
Compare
nicolaskagami
force-pushed
the
nsk/nat-3-natmap
branch
2 times, most recently
from
August 7, 2026 21:36
020bd98 to
a1b1cb9
Compare
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 7, 2026 21:36
6265bc6 to
8293a3e
Compare
nicolaskagami
marked this pull request as draft
August 7, 2026 21:49
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 8, 2026 02:52
8293a3e to
c597b42
Compare
nicolaskagami
force-pushed
the
nsk/nat-3-natmap
branch
3 times, most recently
from
August 10, 2026 17:14
ccd1c40 to
d515c3d
Compare
nicolaskagami
marked this pull request as ready for review
August 10, 2026 19:33
bnaecker
approved these changes
Aug 10, 2026
bnaecker
left a comment
Contributor
There was a problem hiding this comment.
Looks good, thanks! I have a few nits and suggestions, but they're for new issues not this PR. Nice cleanup here.
nicolaskagami
force-pushed
the
nsk/nat-3-natmap
branch
from
August 11, 2026 11:12
d515c3d to
7ee059d
Compare
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 11, 2026 11:12
c597b42 to
75f67a5
Compare
internet-diglett
left a comment
Contributor
There was a problem hiding this comment.
Looks really good, just one comment
nicolaskagami
force-pushed
the
nsk/nat-3-natmap
branch
from
August 13, 2026 22:59
7ee059d to
55a6051
Compare
internet-diglett
approved these changes
Aug 13, 2026
nicolaskagami
added a commit
that referenced
this pull request
Aug 14, 2026
This PR: - Moves the `PortRange` trait into a struct, validating the `low <= high` invariant by construction. - Simplifies `overlap` function. This is the first of 3 PRs simplifying and de-duplicating some of the `nat.rs` code. - #334 - #335 - #336 Left for future work: - Expanding `PortRange` usage further. - Storing ranges in a way that codifies its non-overlapping invariant and stores sorted for faster operations.
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 14, 2026 11:51
75f67a5 to
7b2ea46
Compare
nicolaskagami
force-pushed
the
nsk/nat-3-natmap
branch
from
August 14, 2026 11:55
55a6051 to
1e580a3
Compare
nicolaskagami
added a commit
that referenced
this pull request
Aug 14, 2026
This PR: - Introduces a `NatAddress` trait, tying each IP address family to its p4 table, match key, and action types. Replaces duplicated per-family entry points. - Fixes a bug where we'd clear our internal representation of the mappings if the underlying code failed to reset. This is the second of 3 PRs simplifying and de-duplicating some of the `nat.rs` code. - #334 - #335 - #336 Obs: Changes are almost entirely equivalent, except for the ordering of some things and the log message `nat tables` -> `nat table`.
Replace the duplicated v4/v6 mapping storage and logic with a single NatEntry type and a NatMap generic over NatAddress; the public API keeps its per-family signatures as thin wrappers.
nicolaskagami
force-pushed
the
nsk/nat-3-natmap
branch
from
August 14, 2026 12:11
1e580a3 to
f415415
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR:
NatEntryandNatMapto replace duplicated v4/v6 logic (net -203 LOC).This is the last of 3 PRs simplifying and de-duplicating some of the
nat.rscode.PortRangeto struct #334NatAddresstrait #335Obs:
tracetoerrorto match the IPv4 one but I'm happy to do it the other way around.ipv4_generationtogeneration, since it applies to both even though the nexus API nomenclature is out-of-date.