mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Baruch Siach <baruch@tkos.co.il>
To: barebox@lists.infradead.org
Subject: [PATCH] net: fix checksum verification
Date: Fri,  9 Aug 2013 07:01:24 +0300	[thread overview]
Message-ID: <ce9d0dc069aa93694635e8bd5ac2fbd94bd2fa24.1376020752.git.baruch@tkos.co.il> (raw)

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

             reply	other threads:[~2013-08-09  4:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09  4:01 Baruch Siach [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ce9d0dc069aa93694635e8bd5ac2fbd94bd2fa24.1376020752.git.baruch@tkos.co.il \
    --to=baruch@tkos.co.il \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox