Merged
Conversation
e37d8ef to
1d6792c
Compare
Nat the first packet of a port-forwarded flow using the state created. This helps in consistency and in exposing a single method to nat a packet. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Let masquerading and port forwarding use the same type for actions. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Write packet port-forwarding utils using the new pattern matching. Return failures as errors and log them. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
The utils: - use the new pattern matching - distinguish between source and destination address/port nat. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Use the new functions based on header pattern matching to masquerade flows. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Rename: PortFwFlowStatus -> NatFlowStatus AtomicPortFwFlowStatus -> AtomicNatFlowStatus .. so that the same types can be used for masquerading Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Moves the types renamed in the prior commit to common/ so that they can be used for masquerading. Note that while the types are moved, the uses of the types and semantics may be NAT flavor specific. In other words, only the types are moved but not some of the implementations. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Add field status with type AtomicNatFlowStatus to the masquerade states created for the flow pair to masquerade traffic. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Adds simple flow status state machines for masqueraded flows.
With the state machine defined:
1) icmp traffic can only be oneway or twoway. The timeout for
icmp traffic will not configurable by the user.
2) UDP traffic can be in oneway, twoway or established (3 way).
Only when reaching established flow timeouts will be the ones
configured by the user.
3) TCP traffic uses the same SM as for port-forwarding, reversed.
Until flows reach established state, their timeouts will not
be the user configured ones.
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
- Set the initial timeout for a masqueraded flow. - Update FlowStatus of masqueraded flows according to SM and proto. - Set subsequent flow timeouts depending on the FlowStatus. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Allow "patching" the flow status depending on the application. This is only implemented for DNS and relying on transport ports as application identifiers. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
- fix displays for clearer logs - remove duplicate logs - add tracing target to net/flows. We can't have linkme as a dependency of net, so we declare the target in flow-entry on behalf of net. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
1d6792c to
b9efa1e
Compare
qmonnet
approved these changes
Apr 28, 2026
Member
qmonnet
left a comment
There was a problem hiding this comment.
Looks OK to me. This is another large PR and I can't claim to have looked into every single detail, but I went through all commits and they make sense. Given that unit tests are still passing, we're reasonably confident that we don't break everything, so the PR seems good to go. 🚢
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.
Fixes: https://github.com/githedgehog/internal/issues/364
NOTE: this targets #1499
NOTE: this recreates #1501, which can be ignored