[PATCH] net: fix checksum verification
Baruch Siach
baruch at tkos.co.il
Fri Aug 9 00:01:24 EDT 2013
Checksum verification on data including its own checksum (as is the case with
IP headers) should give zero. Current code works well for the correct checksum
case, but fails to identify (most) errors.
Signed-off-by: Baruch Siach <baruch at tkos.co.il>
---
Untested. From code inspection only.
net/net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/net.c b/net/net.c
index 0bd9084..bd7a578 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) == 0;
}
uint16_t net_checksum(unsigned char *ptr, int len)
--
1.8.4.rc1
More information about the barebox
mailing list