Messages in this thread | | | From | David Laight <> | Subject | RE: [PATCH] amd64: Fix csum_partial_copy_generic() | Date | Thu, 19 Oct 2023 10:33:50 +0000 |
| |
> Wireshark shows a bad checksum warning: > 'Checksum: 0x0000 incorrect, should be 0xffff'
Does the ICMP message contain the non-inverted checksum? Usually it is inverted before transmission so that a checksum of the whole buffer (including the checksum) is 0xffff.
If the checksum() function does the reduction mod 0xffff with 'add with carry' it is only zero if the buffer is zero. So initialising to 0xffff does make sense. OTOH the value could be reduced using 'csum64 % 0xffff' which generates 0x0 not 0xffff (and might be faster code).
There is a different potential issue that IPv6 mandates a non-zero checksum field. But a naive ~checksum(buffer, len) can generate zero.
The simple fix is to initialise the checksum with 1 and add 1 back after the invert so: buffer->csum = ~checksum(1, buffer, len) + 1;
I'm guessing the current code has an extra conditional in the hot path?
David
- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
| |