From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from tango.tkos.co.il ([62.219.50.35]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7duO-0001hQ-Bl for barebox@lists.infradead.org; Fri, 09 Aug 2013 04:02:39 +0000 From: Baruch Siach Date: Fri, 9 Aug 2013 07:01:24 +0300 Message-Id: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH] net: fix checksum verification To: barebox@lists.infradead.org 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 --- 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