RE: [PATCH v15 5/5] kunit: Add tests for csum_ipv6_magic and ip_fast_csum

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Guenter Roeck
> Sent: 23 January 2024 01:06
...
> >>     +#define SUPPORTED_ALIGNMENT (1 << NET_IP_ALIGN)
> >>      /* Values for a little endian CPU. Byte swap each half on big endian CPU. */
> >>      static const u32 random_init_sum = 0x2847aab;
> >>     @@ -486,7 +488,7 @@ static void test_csum_fixed_random_inputs(struct kunit *test)
> >>      	__sum16 result, expec;
> >>      	assert_setup_correct(test);
> >>     -	for (align = 0; align < TEST_BUFLEN; ++align) {
> >>     +	for (align = 0; align < TEST_BUFLEN; align += SUPPORTED_ALIGNMENT) {
...

That is all wrong.
NET_IP_ALIGN is the offset for the base of ethernet frames.
If zero the IP header will (usually) be misaligned.
If two the mac addresses are misaligned in order to align
the IP header (6+6+2 bytes in).
I don't think any other values are actually valid, but
there is always that possibility.

So the definition should really be:
#define SUPPORTED_ALIGNMENT (NET_IP_ALIGN ? 4 : 1)

(Which might happen to be the same values :-)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux