9
0
Fork 0

net: fix checksum verification

Checksum calculation on data including its own checksum (as is the case with
IP headers) should give 0xffff before bit flipping. Current code works well
for the correct checksum case, but fails to identify errors.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Baruch Siach 2013-08-11 07:35:45 +03:00 committed by Sascha Hauer
parent 9b0907bd68
commit b5abbd8074
1 changed files with 1 additions and 1 deletions

View File

@ -41,7 +41,7 @@ static unsigned int net_ip_id;
int net_checksum_ok(unsigned char *ptr, int len)
{
return net_checksum(ptr, len) + 1;
return net_checksum(ptr, len) == 0xffff;
}
uint16_t net_checksum(unsigned char *ptr, int len)