Skip to content

Stateless NAT: Remove nots and not_as from NAT tables and processing logics #653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 1, 2025

Conversation

qmonnet
Copy link
Member

@qmonnet qmonnet commented Jun 30, 2025

Implement a function to collapse exclusion prefixes (nots, not_as) into allowed prefixes (ips, as_range) to create a list of smaller fragment prefixes representing the same IP addressing ranges, but without the need to keep track of any exclusion prefixes.

Use this function to get rid of exclusion prefixes altogether in the NAT tables. This allows us to greatly simplify the processing when building NAT tables and when computing the IP address mapping for stateless NAT.

One other consequence is that it allows us to revert e296c01 (we don't do it in this PR) and address #650.

@qmonnet qmonnet added this to the GW R1 milestone Jun 30, 2025
@qmonnet qmonnet self-assigned this Jun 30, 2025
@qmonnet qmonnet requested a review from a team as a code owner June 30, 2025 18:47
@qmonnet qmonnet added the area/nat Related to Network Address Translation (NAT) label Jun 30, 2025
Copy link
Collaborator

@daniel-noland daniel-noland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a couple small things from me (neither of which block).

I appreciate how much complexity this PR cuts. Nice work.

That said, I am very out of context on this PR so may want another reviewer

@qmonnet qmonnet force-pushed the pr/qmonnet/nat-no-excludes branch from 5b4d25a to ad47ea3 Compare July 1, 2025 14:29
@qmonnet qmonnet requested a review from mvachhar July 1, 2025 14:31
qmonnet and others added 6 commits July 1, 2025 15:34
Implement a function to "collapse" prefixes: take a set of allowed
prefixes, and another set of exclusion prefixes to apply to the first
set, and produce a new set of allowed prefixes that are smaller segments
representing the same IP address range as the combination of the initial
two sets - but without the use of exclusion prefixes.

Implement a function to run this on all expose objects in a Peering. The
function is not called yet.

Add unit tests to validate the algorithm.

Signed-off-by: Quentin Monnet <[email protected]>
Rather than optimizing the lists for prefixes by only removing exclusion
prefixes when they cover one half of allowed prefixes, split allowed
prefixes into smaller fragments to get rid of all exclusion prefixes
altogether.

We don't spend too much effort on the new error introduced in this
commit; it's more convenient at the moment to return a TrieError from
the function (because we return it in several locations), so just add an
"Other" error for the case where the internal algorithm has a bug.

Signed-off-by: Quentin Monnet <[email protected]>
We changed the way we build the stateless NAT tables; get rid of the
unused code.

Signed-off-by: Quentin Monnet <[email protected]>
We have optimised out the exclusion prefixes from the list of allowed
prefixes, so that the NAT tables no longer rely on it. Let's remove all
the associated processing in the NAT tables and the IpList structure,
hurray!

Signed-off-by: Quentin Monnet <[email protected]>
The fuzzer works by generating some random prefixes/excludes
then uses a simple oracle to test against a set of IP addrs
and compares it to the determination of the collapsed prefix
list.

[ Quentin: Shorten checks in prefix_oracle() ]

Signed-off-by: Manish Vachharajani <[email protected]>
Signed-off-by: Quentin Monnet <[email protected]>
@qmonnet qmonnet force-pushed the pr/qmonnet/nat-no-excludes branch from ad47ea3 to 30cc425 Compare July 1, 2025 14:34
@mvachhar mvachhar enabled auto-merge July 1, 2025 14:35
@mvachhar mvachhar added this pull request to the merge queue Jul 1, 2025
Merged via the queue into main with commit c3ad0ce Jul 1, 2025
16 checks passed
@mvachhar mvachhar deleted the pr/qmonnet/nat-no-excludes branch July 1, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/nat Related to Network Address Translation (NAT)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants