[PATCH v2] net: fix checksum verification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
Untested.

v2: net_checksum() doesn't flip bits. Fix accordingly.

 net/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/net.c b/net/net.c
index 0bd9084..058a4d3 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)
-- 
1.8.4.rc1


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




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux