[2/3] [nat] introduce NatAddress trait - #335
Merged
Merged
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
NatFamily traitNatAddress trait
nicolaskagami
marked this pull request as ready for review
August 6, 2026 18:00
nicolaskagami
force-pushed
the
nsk/nat-1-portrange
branch
from
August 7, 2026 12:48
a01c3aa to
d7008db
Compare
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
2 times, most recently
from
August 7, 2026 13:47
22d9c68 to
1b86758
Compare
nicolaskagami
force-pushed
the
nsk/nat-1-portrange
branch
from
August 7, 2026 18:48
d7008db to
25b94af
Compare
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 7, 2026 18:48
1b86758 to
6265bc6
Compare
internet-diglett
requested changes
Aug 7, 2026
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
2 times, most recently
from
August 8, 2026 02:52
8293a3e to
c597b42
Compare
bnaecker
approved these changes
Aug 10, 2026
bnaecker
left a comment
Contributor
There was a problem hiding this comment.
Looks good, nice cleanup. Just a few questions / nits.
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 11, 2026 11:12
c597b42 to
75f67a5
Compare
internet-diglett
approved these changes
Aug 13, 2026
internet-diglett
left a comment
Contributor
There was a problem hiding this comment.
This looks really good, thank you for working on this!
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.
Tie each IP address family to its p4 table, match key, and action types via a trait, with the table operations provided as default methods. Replaces the duplicated per-family entry points.
nicolaskagami
force-pushed
the
nsk/nat-2-nat-family
branch
from
August 14, 2026 11:51
75f67a5 to
7b2ea46
Compare
nicolaskagami
added a commit
that referenced
this pull request
Aug 14, 2026
This PR: - Introduces a `NatEntry` and `NatMap` to replace duplicated v4/v6 logic (net -203 LOC). This is the last of 3 PRs simplifying and de-duplicating some of the `nat.rs` code. - #334 - #335 - #336 Obs: - I decided to upgrade the IPv6 log error from `trace` to `error` to match the IPv4 one but I'm happy to do it the other way around. - Renamed `ipv4_generation` to `generation`, since it applies to both even though the nexus API nomenclature is out-of-date.
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:
NatAddresstrait, tying each IP address family to its p4 table, match key, and action types. Replaces duplicated per-family entry points.This is the second of 3 PRs simplifying and de-duplicating some of the
nat.rscode.PortRangeto struct #334NatAddresstrait #335Obs: Changes are almost entirely equivalent, except for the ordering of some things and the log message
nat tables->nat table.