[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a75691c5f09e4dbf9257f690684ee79d@AcuMS.aculab.com>
Date: Thu, 19 Oct 2023 10:33:50 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'gus Gusenleitner Klaus' <gus@...a.com>,
Al Viro <viro@....linux.org.uk>,
Thomas Gleixner <tglx@...utronix.de>
CC: lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...hat.com>, "bp@...en8.de" <bp@...en8.de>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"x86@...nel.org" <x86@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
"dsahern@...nel.org" <dsahern@...nel.org>,
"edumazet@...gle.com" <edumazet@...gle.com>,
"kuba@...nel.org" <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Subject: RE: [PATCH] amd64: Fix csum_partial_copy_generic()
> 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)
Powered by blists - more mailing lists