Skip to content
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

net/tstun: do SNAT after filterPacketOutboundToWireGuard #12133

Merged
merged 1 commit into from
May 14, 2024
Merged

Conversation

maisem
Copy link
Collaborator

@maisem maisem commented May 14, 2024

In a configuration where the local node (ip1) has a different IP (ip2) that it uses to communicate with a peer (ip3) we would do UDP flow tracking on the ip2->ip3 tuple. When we receive the response from the peer ip3->ip2 we would dnat it back to ip3->ip1 which would then not match the flow track state and the packet would get dropped.

To fix this, we should do flow tracking on the ip1->ip3 tuple instead of ip2->ip3 which requires doing SNAT after the running filterPacketOutboundToWireGuard.

Updates tailscale/corp#19971, tailscale/corp#8020

@maisem
Copy link
Collaborator Author

maisem commented May 14, 2024

TODO: figure out how to write tests for this.

In a configuration where the local node (ip1) has a different IP (ip2)
that it uses to communicate with a peer (ip3) we would do UDP flow
tracking on the `ip2->ip3` tuple. When we receive the response from
the peer `ip3->ip2` we would dnat it back to `ip3->ip1` which would
then not match the flow track state and the packet would get dropped.

To fix this, we should do flow tracking on the `ip1->ip3` tuple instead
of `ip2->ip3` which requires doing SNAT after the running filterPacketOutboundToWireGuard.

Updates tailscale/corp#19971, tailscale/corp#8020

Signed-off-by: Maisem Ali <maisem@tailscale.com>
Copy link
Member

@andrew-d andrew-d left a comment

Choose a reason for hiding this comment

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

We should write tests for this, but I'm convinced that this is right and I'm happy to (1) merge now, and (2) keep the bug open until we have tests for it. I'd love to test this in an unstable, too 😃

@maisem maisem merged commit 1f51bb6 into main May 14, 2024
45 of 48 checks passed
@maisem maisem deleted the maisem/fix-nat branch May 14, 2024 21:19
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.

None yet

3 participants