Skip to content

fix(nat): Fix validation for one-direction NAT #664

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 2 commits into from
Jul 2, 2025

Conversation

qmonnet
Copy link
Member

@qmonnet qmonnet commented Jul 2, 2025

This is similar to commit 7344ee0: when we only NAT on one direction, then one of the two VPCs uses its ips prefix list as public ips (no NAT), and these are the prefixes we should compare public addresses from as_range in other expose objects with.

In particular, we need to do this comparison when validating VpcManifest objects: when checking for prefix overlap, we may have to check the as_range blocks of an expose object with the ips blocks of another, if the latter expose has no as_range.

Note that even in that case, we still check for overlap between the ips lists of both expose objects, as we can't afford to have overlap for them (ips lists of exposes in a same manifest).

This is similar to commit 7344ee0 ("fix(nat): Use ips if as_range
are empty for stateless src NAT 1st lookup"): when we only NAT on one
direction, then one of the two VPCs uses its "ips" prefix list as public
IPs (no NAT), and these are the prefixes we should compare public
addresses from as_range in other expose objects with.

In particular, we need to do this comparison when validating VpcManifest
objects: when checking for prefix overlap, we may have to check the
as_range blocks of an expose object with the ips blocks of another, if
the latter expose has no as_range.

Note that even in that case, we still check for overlap between the ips
lists of both expose objects, as we can't afford to have overlap for
them (ips lists of exposes in a same manifest).

Signed-off-by: Quentin Monnet <[email protected]>
@qmonnet qmonnet added this to the GW R1 milestone Jul 2, 2025
@qmonnet qmonnet requested a review from mvachhar July 2, 2025 00:37
@qmonnet qmonnet self-assigned this Jul 2, 2025
@qmonnet qmonnet requested a review from a team as a code owner July 2, 2025 00:37
@qmonnet qmonnet added the area/nat Related to Network Address Translation (NAT) label Jul 2, 2025
@qmonnet qmonnet enabled auto-merge July 2, 2025 00:37
Copy link
Contributor

@mvachhar mvachhar left a comment

Choose a reason for hiding this comment

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

Is there any way that we can build a small set of functions that give us the exposed IPs for one of these peering blocks so that we don't have to keep having this "If this is empty then that is empty then check this type of logic"?

A given VpcExpose may or may not required NAT, depending on whether the
as_range list contains any prefix or not. This has consequences in some
portions of the NAT processing logics: at times, we need to consider the
publicly-exposed addresses for an expose object, and these may not be in
as_range, but in ips, if NAT is not in use for this expose.

Add some helper methods to handle public IPs in a more convenient way.
This makes the logics easier to follow when we need to refer to these
public IPs whether they are in as_range or ips.

Note that this commit does not account for the case where we have an
empty as_range list but non-empty not_as, given that this case is
currently rejected at validation time.

Suggested-by: Manish Vachharajani <[email protected]>
Signed-off-by: Quentin Monnet <[email protected]>
@qmonnet
Copy link
Member Author

qmonnet commented Jul 2, 2025

@mvachhar I think there is, please take a look at the last commit.

@qmonnet qmonnet requested a review from mvachhar July 2, 2025 13:54
@qmonnet qmonnet added this pull request to the merge queue Jul 2, 2025
Merged via the queue into main with commit e5a86b6 Jul 2, 2025
16 checks passed
@qmonnet qmonnet deleted the pr/qmonnet/valid-ip-asrange branch July 2, 2025 15:54
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.

2 participants