Re: [PATCH v6 0/2] lib: checksum: Fix issues with checksum tests

From: Guenter Roeck
Date: Sun Feb 11 2024 - 14:18:48 EST


Hi,

On 2/7/24 16:22, Charlie Jenkins wrote:
The ip_fast_csum and csum_ipv6_magic tests did not have the data
types properly casted, and improperly misaligned data.

Signed-off-by: Charlie Jenkins <charlie@xxxxxxxxxxxx>

I sorted out most of the problems with this version, but I still get:

# test_csum_ipv6_magic: ASSERTION FAILED at lib/checksum_kunit.c:513
Expected ( u64)csum_result == ( u64)expected, but
( u64)csum_result == 16630 (0x40f6)
( u64)expected == 65535 (0xffff)
not ok 5 test_csum_ipv6_magic

on m68k:q800. This is suspicious because there is no 0xffff in
expected_csum_ipv6_magic[]. With some debugging information:

####### num_tests=86 i=84 expect array size=84
####### MAX_LEN=512 WORD_ALIGNMENT=4 magic data size=42

That means the loop

for (int i = 0; i < num_tests; i++) {
...
expected = (__force __sum16)expected_csum_ipv6_magic[i];
...
}

will access data beyond the end of the expected_csum_ipv6_magic[] array,
possibly because m68k doesn't pad struct csum_ipv6_magic_data to 44 bytes.

In this context, is the comment about proto having to be 0 really true ?
It seems to me that the calculated checksum must be identical on both
little and big endian systems. After all, they need to be able to talk
to each other.

Thanks,
Guenter