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

bpf: nat: fully switch to snat_v*_rewrite_helpers() #29403

Merged
merged 4 commits into from
Dec 1, 2023

Conversation

julianwiedmann
Copy link
Member

@julianwiedmann julianwiedmann commented Nov 27, 2023

Fix up a thinko in the new IPv6 SNAT rewrite helper (along what @gentoo-root fixed for IPv4 in #28768). Then finish the conversion of the SNAT code to the generic rewrite helpers.

@julianwiedmann julianwiedmann added sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/misc This PR makes changes that have no direct user impact. feature/snat Relates to SNAT or Masquerading of traffic labels Nov 27, 2023
@julianwiedmann
Copy link
Member Author

/test

@julianwiedmann julianwiedmann added the feature/ipv6 Relates to IPv6 protocol support label Nov 29, 2023
@julianwiedmann julianwiedmann changed the title 1.15 bpf nat csum bpf: nat: fully switch to snat_v*_rewrite_helpers() Nov 29, 2023
@julianwiedmann julianwiedmann marked this pull request as ready for review November 29, 2023 10:54
@julianwiedmann julianwiedmann requested a review from a team as a code owner November 29, 2023 10:54
@julianwiedmann julianwiedmann added kind/bug This is a bug in the Cilium logic. kind/enhancement This would improve or streamline existing functionality. dont-merge/blocked Another PR must be merged before this one. labels Nov 29, 2023
@julianwiedmann
Copy link
Member Author

Fine to review, but I really want to rebase on-top of #29510 before merging 😬.

Copy link
Contributor

@gentoo-root gentoo-root left a comment

Choose a reason for hiding this comment

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

Fantastic cleanup!

Similar to 495af07 ("bpf: Fix csum logic in snat_v4_rewrite_headers"),
we mustn't mix the diff from the L4 port-rewrite into the diff used for the
pseudo-header update.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
When a local endpoint sends an ICMP_FRAG_NEEDED message, it contains some
inner packet that was originally addressed to the endpoint. The endpoint's
address/port in this inner packet potentially needs to be SNATed again, to
return it to its pre-revSNAT state.

snat_v4_icmp_rewrite_egress_embedded() handles the .daddr / .dport rewrite
of such an inner packet, based on an SNAT entry. Replace it with the
common snat_v4_rewrite_headers() helper.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
Use the common snat_v6_rewrite_headers() helper from the IPv6 RevSNAT path.
This is essentially a 1-to-1 replacement, except that we need to ensure
that the L4 port rewrite is skipped for ICMPV6_PKT_TOOBIG packets.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
When loading the ICMP identifier field, store it in-place instead of going
through a temporary variable.

Also as the `tuple` is zero-initialized, we don't need to do this again for
the port field(s).

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
@julianwiedmann julianwiedmann added kind/cleanup This includes no functional changes. and removed kind/enhancement This would improve or streamline existing functionality. labels Dec 1, 2023
@julianwiedmann
Copy link
Member Author

/test

@julianwiedmann julianwiedmann removed the dont-merge/blocked Another PR must be merged before this one. label Dec 1, 2023
@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 Dec 1, 2023
@julianwiedmann julianwiedmann added this pull request to the merge queue Dec 1, 2023
Merged via the queue into cilium:main with commit 815da3e Dec 1, 2023
@julianwiedmann julianwiedmann deleted the 1.15-bpf-nat-csum branch December 1, 2023 15:22
@julianwiedmann
Copy link
Member Author

@ysksuzuki mentioned that 14ca07d was helping quite a bit with complexity 🎉

@julianwiedmann julianwiedmann added the kind/complexity-issue Relates to BPF complexity or program size issues label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/ipv6 Relates to IPv6 protocol support feature/snat Relates to SNAT or Masquerading of traffic kind/bug This is a bug in the Cilium logic. kind/cleanup This includes no functional changes. kind/complexity-issue Relates to BPF complexity or program size issues ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants