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: consistently use has_l4_header in IPv4 SNAT path #25741

Merged
merged 1 commit into from May 30, 2023

Conversation

julianwiedmann
Copy link
Member

Clean up a redundant IPv4 header validation, and make the IPv4 SNAT code a bit more consistent.

Note that this won't help to actually fix IPv4 fragmentation vs SNAT. That's going to land via #25340.

We currently don't support IPv4 fragmentation in the SNAT path (or more
precisely, we don't have support for loading the L4 ports of a fragment).

But we already have two spots that correctly check whether the packet has
a L4 header (or only requires L3 SNAT). Make this consistent across the
whole flow, so that it also gets applied in the CT lookup.

Passing this through to snat_v4_nat_handle_icmp_frag_needed() also avoids a
revalidation of the outer header.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
@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. labels May 29, 2023
@julianwiedmann julianwiedmann requested a review from a team as a code owner May 29, 2023 11:13
@julianwiedmann
Copy link
Member Author

/test

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.

Nice cleanup!

@@ -1044,6 +1040,7 @@ snat_v4_nat(struct __ctx_buff *ctx, const struct ipv4_nat_target *target, __s8 *
return DROP_INVALID;

snat_v4_init_tuple(ip4, NAT_DIR_EGRESS, &tuple);
has_l4_header = ipv4_has_l4_header(ip4);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be replaced by ipv4_ct_extract_l4_ports in #25340.

@maintainer-s-little-helper maintainer-s-little-helper bot added ready-to-merge This PR has passed all tests and received consensus from code owners to merge. labels May 29, 2023
@julianwiedmann julianwiedmann merged commit d68e6e5 into cilium:main May 30, 2023
63 checks passed
@julianwiedmann julianwiedmann deleted the 1.14-bpf-has-l4-header branch May 30, 2023 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

2 participants