Skip to content

Masquerading clean-ups#1389

Draft
qmonnet wants to merge 6 commits intomainfrom
pr/qmonnet/nat-clean-ups
Draft

Masquerading clean-ups#1389
qmonnet wants to merge 6 commits intomainfrom
pr/qmonnet/nat-clean-ups

Conversation

@qmonnet
Copy link
Member

@qmonnet qmonnet commented Mar 24, 2026

WIP

qmonnet added 6 commits March 24, 2026 13:43
Tiny clean-up fixes for test_default_expose: Move done_reason check
fist, move blank lines to the relevant locations.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
We do not support initiating a masqueraded connection for the
destination of a packet (we only support initiating when masquerading
the source side). As such, there is no need to ever look up for the
destination translation information when trying to establish a new
connection: this is dead code, and should be removed.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
We can already build NatTranslationData objects by instantiating the
struct fields directly, but it takes six lines and is less readable than
a one-liner builder call. If we want to build an empty instance, we have
the default() method for that. Let's make new() accept arguments.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
In some cases, the flow table entries should contain NAT information
that does not correspond to any allocated resources: this is the case
for the entries for return flows, for example, where we do not actually
need to reserve the IPs and ports to use via the allocator. Instead of
holding pointers towards NAT objects that we later need to de-allocate,
turn NatFlowState into an enum with a variant simply holding the
computed values to use.

We move NatFlowState and its sub-types into a dedicated file to provide
a clean implementation, such that the changes in the other files are
minimal and result in some code simplification.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
We do not actually need to allocate resources for reverse flow. As we
only support initiating masquerading on the source side, there is no
risk that a reverse flow would allocate resources, so no risk that IPs
and ports used for reverse flows in the flow table actually collide with
IPs and ports that the allocator would attempt to assign to other flows.

Instead of allocating these resources, and holding references to
allocated resources in the flow table, we simply hold an IP address and
a port.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
Remove the destination masquerading tables. They are unused now that we
do not allocate resources for reverse flows.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant