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: xdp replace inline asm in csum helpers #32543

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jack-R-lantern
Copy link
Contributor

@Jack-R-lantern Jack-R-lantern commented May 15, 2024

Please ensure your pull request adheres to the following guidelines:

  • For first time contributors, read Submitting a pull request
  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • If your commit description contains a Fixes: <commit-id> tag, then
    please add the commit author[s] as reviewer[s] to this issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.
  • Are you a user of Cilium? Please add yourself to the Users doc
  • Thanks for contributing!

This commit is a refactoring due to native support for the bpf_xdp_load_bytes.
replace inline asm to native support xdp_load_bytes()

Fixes: #29487

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 15, 2024
@github-actions github-actions bot added the kind/community-contribution This was a contribution made by a community member. label May 15, 2024
@Jack-R-lantern Jack-R-lantern force-pushed the ISSUE-29487/bpf-xdp-replace-inline-assembly-in-csum-helpers branch 2 times, most recently from 463bf29 to 45f6b05 Compare May 15, 2024 10:18
@Jack-R-lantern Jack-R-lantern marked this pull request as ready for review May 15, 2024 10:23
@Jack-R-lantern Jack-R-lantern requested a review from a team as a code owner May 15, 2024 10:23
@Jack-R-lantern Jack-R-lantern requested a review from jibi May 15, 2024 10:23
@Jack-R-lantern
Copy link
Contributor Author

Jack-R-lantern commented May 20, 2024

@julianwiedmann please review

@@ -156,28 +156,15 @@ l3_csum_replace(const struct xdp_md *ctx, __u64 off, const __u32 from,
__u32 flags)
{
__u32 size = flags & BPF_F_HDR_FIELD_MASK;
__sum16 *sum;
int ret;
__sum16 sum[1];
Copy link
Member

Choose a reason for hiding this comment

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

why not just __sum16 sum; and then pass &sum to the different functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Inside xdp_load_bytes, there is a part that calls memcpy.

This is fine if it's an inline asm, but
xdp_load_bytes, it requires memory.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

yep, xdp_load_bytes takes a pointer, I was just suggesting to use:

__sum16 sum;
// ..
ret = xdp_load_bytes(ctx, off, &sum, 2);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, that was my mistake, I apologize. I'll accept the offer right away

@jibi jibi 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 24, 2024
@maintainer-s-little-helper maintainer-s-little-helper bot removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels May 24, 2024
@jibi
Copy link
Member

jibi commented May 24, 2024

/test

@Jack-R-lantern Jack-R-lantern force-pushed the ISSUE-29487/bpf-xdp-replace-inline-assembly-in-csum-helpers branch 2 times, most recently from a440100 to 4cb5680 Compare May 24, 2024 13:46
@Jack-R-lantern Jack-R-lantern requested a review from jibi May 24, 2024 14:27
@Jack-R-lantern Jack-R-lantern force-pushed the ISSUE-29487/bpf-xdp-replace-inline-assembly-in-csum-helpers branch 3 times, most recently from 4fc7847 to 1235c76 Compare May 27, 2024 02:21
@joestringer
Copy link
Member

/test

@jibi
Copy link
Member

jibi commented Jun 6, 2024

I retriggered the failed tests, not sure if the failures are related to these changes

@Jack-R-lantern
Copy link
Contributor Author

I retriggered the failed tests, not sure if the failures are related to these changes

I think there's something wrong with my code, I'll check it out a bit more and fix it.

This commit is a refactoring due to native support for
the bpf_xdp_load_bytes.

Signed-off-by: Jack-R-lantern <tjdfkr2421@gmail.com>
@Jack-R-lantern Jack-R-lantern force-pushed the ISSUE-29487/bpf-xdp-replace-inline-assembly-in-csum-helpers branch from 1235c76 to c025bce Compare June 6, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/community-contribution This was a contribution made by a community member. 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.

bpf: xdp: replace inline assembly in csum helpers
3 participants