summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorBaruch Siach <baruch@tkos.co.il>2013-08-11 07:35:45 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2013-08-12 07:58:50 +0200
commitb5abbd80740063d63f9630b27760484e0c4a36a4 (patch)
treeb50dc003e1aae2203fcfb1011188b4925b1a94b6 /net
parent9b0907bd68ffc23ed27cc3c5f51ff505d64beb78 (diff)
downloadbarebox-b5abbd80740063d63f9630b27760484e0c4a36a4.tar.gz
barebox-b5abbd80740063d63f9630b27760484e0c4a36a4.tar.xz
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>
Diffstat (limited to 'net')
-rw-r--r--net/net.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/net.c b/net/net.c
index 0bd9084dd0..058a4d3285 100644
--- a/net/net.c
+++ b/net/net.c
@@ -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)