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: Remove duplicate code in bpf_sock.c #10862

Merged
merged 1 commit into from Apr 8, 2020
Merged

Conversation

brb
Copy link
Member

@brb brb commented Apr 6, 2020

This commit refactors __sock{4,6}_xlate() functions in a way that they can be used to replace __sock{4,6}_snd_xlate().

The refactoring also allows us to get rid of the sock6_xlate_snd_v4_in_v6() function.

@brb brb added pending-review sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. kind/cleanup This includes no functional changes. release-note/misc This PR makes changes that have no direct user impact. labels Apr 6, 2020
@brb brb requested review from borkmann and a team April 6, 2020 13:48
@maintainer-s-little-helper maintainer-s-little-helper bot added this to In progress in 1.8.0 Apr 6, 2020
@brb
Copy link
Member Author

brb commented Apr 6, 2020

test-me-please

Copy link
Member

@tklauser tklauser left a comment

Choose a reason for hiding this comment

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

Would it make sense to add -DHOOK_CONNECT to LB_OPTIONS in bpf/Makefile so it gets compile-tested too in various option combinations?

Copy link
Member

@borkmann borkmann left a comment

Choose a reason for hiding this comment

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

Makes sense, but why do we need even more ifdef wrt HOOK_CONNECT at all? Either we could leave the sanity check in place (which doesn't hurt much either) or if we really want to remove it then via const bool so compiler optimizes it out. I'd probably do the former so __sock4_xlate() could stay unchanged, for example.

@coveralls
Copy link

coveralls commented Apr 6, 2020

Coverage Status

Coverage increased (+0.02%) to 45.877% when pulling 6705034 on pr/brb/refactor-sock-xlate into 9393dca on master.

@brb
Copy link
Member Author

brb commented Apr 6, 2020

Makes sense, but why do we need even more ifdef wrt HOOK_CONNECT at all

@borkmann It was just to save a few CPU cycles considering that the unnecessary checks would be in the fastpath in the case of UDP. If you think that's not worth doing, then I can remove the ifdefs from the checks.

@borkmann
Copy link
Member

borkmann commented Apr 6, 2020

Makes sense, but why do we need even more ifdef wrt HOOK_CONNECT at all

@borkmann It was just to save a few CPU cycles considering that the unnecessary checks would be in the fastpath in the case of UDP. If you think that's not worth doing, then I can remove the ifdefs from the checks.

But in such case I'd just go for const bool udp_only or such where you pass in constant true/false from callsites, so we have less ifdef in the code and compiler can optimize it out.

@brb brb force-pushed the pr/brb/refactor-sock-xlate branch from 0f9ef14 to 1960340 Compare April 6, 2020 15:53
@brb
Copy link
Member Author

brb commented Apr 6, 2020

test-me-please

@brb
Copy link
Member Author

brb commented Apr 6, 2020

@tklauser HOOK_CONNECT has been removed.

@brb brb requested review from tklauser and borkmann April 6, 2020 15:59
Copy link
Member

@tklauser tklauser left a comment

Choose a reason for hiding this comment

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

Even nicer without the HOOK_CONNECT define! Two small nits/questions inline. Otherwise LGTM.

bpf/bpf_sock.c Outdated Show resolved Hide resolved
bpf/bpf_sock.c Show resolved Hide resolved
@brb brb force-pushed the pr/brb/refactor-sock-xlate branch from 1960340 to 82fe288 Compare April 6, 2020 18:38
@brb
Copy link
Member Author

brb commented Apr 6, 2020

test-me-please

1 similar comment
@brb
Copy link
Member Author

brb commented Apr 6, 2020

test-me-please

@brb brb force-pushed the pr/brb/refactor-sock-xlate branch from 82fe288 to 6705034 Compare April 7, 2020 06:40
@brb
Copy link
Member Author

brb commented Apr 7, 2020

test-me-please

This commit refactors __sock{4,6}_xlate() functions in a way that they
can be used to replace __sock{4,6}_snd_xlate().

The refactoring also allows us to get rid of the sock6_xlate_snd_v4_in_v6()
function.

Signed-off-by: Martynas Pumputis <m@lambda.lt>
@brb
Copy link
Member Author

brb commented Apr 7, 2020

test-me-please

@brb
Copy link
Member Author

brb commented Apr 7, 2020

CI hit the flake #10669. As my code changes are tested by the flaking test, re-running the CI.

@brb
Copy link
Member Author

brb commented Apr 8, 2020

test-me-please

1 similar comment
@brb
Copy link
Member Author

brb commented Apr 8, 2020

test-me-please

@brb
Copy link
Member Author

brb commented Apr 8, 2020

test-me-please

@borkmann borkmann merged commit d8fee7c into master Apr 8, 2020
1.8.0 automation moved this from In progress to Merged Apr 8, 2020
@borkmann borkmann deleted the pr/brb/refactor-sock-xlate branch April 8, 2020 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup This includes no functional changes. 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
No open projects
1.8.0
  
Merged
Development

Successfully merging this pull request may close these issues.

None yet

4 participants