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

[v1.14] bpf: nodeport: add RevDNAT-based FIB lookup for reply traffic #27381

Merged

Conversation

julianwiedmann
Copy link
Member

@julianwiedmann julianwiedmann commented Aug 9, 2023

Manual backport due to smaller conflicts / missing test infrastructure of

Once this PR is merged, you can update the PR labels via:

for pr in 26852 26638; do contrib/backporting/set-labels.py $pr done 1.14; done

or with

make add-labels BRANCH=v1.14 ISSUES=26852,26638

@maintainer-s-little-helper maintainer-s-little-helper bot added backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. kind/backports This PR provides functionality previously merged into master. labels Aug 9, 2023
@julianwiedmann julianwiedmann changed the title [v1.14] nodeport rednat fib [v1.14] bpf: nodeport: add RevDNAT-based FIB lookup for reply traffic Aug 9, 2023
@julianwiedmann
Copy link
Member Author

/test-backport-1.14

@kvaster
Copy link
Contributor

kvaster commented Aug 24, 2023

Any chances to have this merged soon in 14.x ?

@julianwiedmann
Copy link
Member Author

/test-backport-1.14

@julianwiedmann julianwiedmann marked this pull request as ready for review August 26, 2023 07:04
@julianwiedmann julianwiedmann requested a review from a team as a code owner August 26, 2023 07:04
[ upstream commit a0f3085 ]

In a following patch, we need easy access to the RevDNAT info for replies
by a local backend (from the LB*_REVERSE_NAT_MAP) and by a DSR backend
(from the SNAT_MAPPING_IPV* map).

For this we slightly rework the existing ct_has_nodeport_egress_entry*()
helpers, so that they return the rev_nat_index for non-DSR entries.

Then add a nodeport_rev_dnat_get_info_ipv*() helper that wraps the map
lookups for both cases, and returns the info as lb*_reverse_nat struct.

No functional change intended, the new helpers are not used yet.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
[ upstream commit 9efa9b9 ]

Align with lb6_rev_nat() and just pass in the needed parameters from the
ct_state struct. This enables a subsequent patch that wants to call
__lb4_rev_nat() without a ct_state struct.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
[ upstream commit 719be68 ]

The RevDNAT path currently uses __lb*_rev_nat() for rewriting replies by
local backends, and snat_v*_rewrite_egress() for rewriting DSR replies.

Both end up doing pretty much the same thing (we currently don't need the
ICMP support in the snat_* version), so switch the DSR path to also use
__lb*_rev_nat(). For this we employ the new nodeport_rev_dnat_get_info_*()
helpers that convert the DSR SNAT entry to lb*_reverse_nat struct.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
[ upstream commit e909425 ]

Now that we have access to the SNAT info which was used to rewrite the
inner packet, we no longer need to peek into the L3 header to obtain the
new source IP.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
[ upstream commit 3cfe559 ]

[ backporter's notes: the tests needed adjustments, v1.14 doesn't have the
  helpers from cilium#27134 ]

When replies by local / DSR backends enter to-netdev, they have been routed
to the interface using the backend IP as source IP. But depending on what
routing rules are installed on the system, the routing for the RevDNATed
packet is different.

Improve the RevDNAT code in to-netdev to first perform a FIB lookup (based
on the src IP from the RevDNAT info), and if needed redirect the packet to
the correct egress interface.

This requires that bpf_host is also attached to the chosen egress iface,
so that the actual RevDNAT rewrite gets performed there.

Also update some of the tests to cover this scenario.

[Note: ideally we would have this check much earlier in to-netdev, before
       even going through the HostFW code. But that requires shrinking the
       program size first, so postponing that to a follow-on PR]

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
@julianwiedmann
Copy link
Member Author

/test-backport-1.14

@julianwiedmann
Copy link
Member Author

(rebase to pick up the CI renames)

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Sep 5, 2023
@julianwiedmann julianwiedmann merged commit 9d7d669 into cilium:v1.14 Sep 5, 2023
56 checks passed
@julianwiedmann julianwiedmann deleted the v1.14-nodeport-rednat-fib branch September 5, 2023 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. kind/backports This PR provides functionality previously merged into master. ready-to-merge This PR has passed all tests and received consensus from code owners to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants