mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: fix checksum verification
@ 2013-08-09  4:01 Baruch Siach
  2013-08-09  7:32 ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Baruch Siach @ 2013-08-09  4:01 UTC (permalink / raw)
  To: barebox

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@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-08-09 10:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-09  4:01 [PATCH] net: fix checksum verification Baruch Siach
2013-08-09  7:32 ` Sascha Hauer
2013-08-09  8:50   ` Uwe Kleine-König
2013-08-09  8:57     ` Sascha Hauer
2013-08-09 10:16   ` Baruch Siach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox