-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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: fix skip_tunnel_nodeport_revnat #33113
Merged
Merged
Conversation
This file contains 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
cc @learnitall took me a while to figure this out 😆 |
/test |
92f629c
to
5ff682a
Compare
/test |
1 similar comment
/test |
Woah, nice catch. That's quite the bug 😲. My apologies for the extra work here, I owe you one. |
learnitall
approved these changes
Jun 14, 2024
Changed release note label to misc since this is not a user-facing change. |
gentoo-root
reviewed
Jun 18, 2024
5ff682a
to
1b8149b
Compare
gentoo-root
approved these changes
Jun 18, 2024
/test |
Removing r2m here, looks like ci-e2e is hitting a failure that doesn't resolve on rerun. |
1b8149b
to
07de675
Compare
/test |
07de675
to
cfcce9c
Compare
/test |
1 similar comment
/test |
The test contains a bug since it passes min_port and max_port in struct ip{4,6}_nat_target in network instead of host byte order. It doesn't fail because of a series of "fortunate" circumstances, which boil down to invoking the following function __u16 __snat_try_keep_port(__u16 start, __u16 end, __u16 val) { return val >= start && val <= end ? val : __snat_clamp_port_range(start, end, (__u16)get_prandom_u32()); } with the following arguments: __snat_try_keep_port(htons(port), htons(port), port) since htons(port) <= port <= htons(port) is (almost) never true, we end up invoking __u16 __snat_clamp_port_range(__u16 start, __u16 end, __u16 val) { return (val % (__u16)(end - start)) + start; } Since start == end, we end up executing val % 0. This seems to cause UB which somehow leads to the code just using val. Of course, this all comes crashing down when trying to modify any of the code in this path. Fix the test by converting to host byte order as appropriate and by extending the valid port range by one. Fixes: c1761f7 ("bpf: Implement handling of flag_skip_tunnel for revNAT nodeport traffic") Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
cfcce9c
to
53bb025
Compare
/test |
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.
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.
bpf: fix skip_tunnel_nodeport_revnat