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 csum diff #7907

Open
wants to merge 2 commits into
base: bpf-next_base
Choose a base branch
from

Conversation

puranjaymohan
Copy link
Contributor

No description provided.

The bpf_csum_diff() helper calls csum_partial() which is implemented by
some architectures like arm and x86 but other architectures rely on the
generic implementation in lib/checksum.c

The generic implementation in lib/checksum.c returns a 16 bit value but
the arch specific implementations can return more than 16 bits, this
works out because before the result is used it is passed through
csum_fold() that turns it into a 16-bit value.

bpf_csum_diff() directly returns the value from csum_partial() and
therefore the values could be different in different architectures.

Pass the result of bpf_csum_diff() through from32to16() before returning
to homogenize() the result for all architectures.

NOTE: from32to16() is used instead of csum_fold() because csum_fold()
does from32to16() + bitwise NOT of the result. The result of
bpf_csum_diff() can be refed into itself and using csum_fold() would
break that usage.

Signed-off-by: Puranjay Mohan <[email protected]>
The bpf_csum_diff() helper has been fixed to return a 16-bit value for
all archs, so now we don't need to mask the result.

This commit is basically reverting the below:

6185266 ("selftests/bpf: Mask bpf_csum_diff() return value to 16
bits in test_verifier")

Signed-off-by: Puranjay Mohan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant