Re: [PATCH v6 2/2] lib: checksum: Use aligned accesses for ip_fast_csum and csum_ipv6_magic tests

From: Guenter Roeck
Date: Mon Feb 12 2024 - 13:26:57 EST

On 2/12/24 10:09, Charlie Jenkins wrote:
[ ... ]

Almost. Turns out the csum parameter of csum_ipv6_magic() needs to be in
network byte order, and the length parameter needs to be in host byte order.
So instead of
data.len = data_ptr->len;
data.csum = (__force __wsum)htonl((__force u32)data_ptr->csum);
it needs to be something like
data.len = ntohl(data_ptr->len);
data.csum = data_ptr->csum;

Also, as you mentioned, either the returned checksum or the expected
checksum needs to be converted for the comparison because one is in
network byte order and the other in host byte order.

Address conversions are indeed not needed.


Aww that makes sense thank you. I was reversing everything except len
and the solution was to only reverse len... Thank you for figuring that
out for me.

I will send out another version with your change. Should I add a
signed-off-by with your tag for this patch?

No need. I'll send you a Tested-by: tag on the final version (if it works ;-).