Module Name: src
Committed By: snj
Date: Fri May 1 01:56:16 UTC 2009
Modified Files:
src/sys/dev/ic [netbsd-5]: gem.c hme.c
Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #595):
sys/dev/ic/gem.c: revision 1.83
sys/dev/ic/hme.c: revision 1.73
Fix a bug in calculation of checksum deduction:
- To get 16 bit one's complement value from uint32_t variable,
higher 16 bits should be ignored.
- RFC 1624 describes methods to recalculate checksum field in headers,
i.e. one's complement of one's complement sum that could be 0x0000,
but we don't have to use the strategy to deduct one's complement sum
itself which won't be zero but should be 0xffff.
Found on debugging mec(4) on sgimips O2.
To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.78.4.1 src/sys/dev/ic/gem.c
cvs rdiff -u -r1.66.10.2 -r1.66.10.3 src/sys/dev/ic/hme.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/gem.c
diff -u src/sys/dev/ic/gem.c:1.78 src/sys/dev/ic/gem.c:1.78.4.1
--- src/sys/dev/ic/gem.c:1.78 Mon Sep 15 19:50:28 2008
+++ src/sys/dev/ic/gem.c Fri May 1 01:56:16 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: gem.c,v 1.78 2008/09/15 19:50:28 jdc Exp $ */
+/* $NetBSD: gem.c,v 1.78.4.1 2009/05/01 01:56:16 snj Exp $ */
/*
*
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.78 2008/09/15 19:50:28 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.78.4.1 2009/05/01 01:56:16 snj Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -1853,9 +1853,8 @@
optsum = (optsum >> 16) +
(optsum & 0xffff);
- /* Deduct ip opts sum from hwsum (rfc 1624). */
- m->m_pkthdr.csum_data =
- ~((~m->m_pkthdr.csum_data) - ~optsum);
+ /* Deduct ip opts sum from hwsum. */
+ m->m_pkthdr.csum_data += (uint16_t)~optsum;
while (m->m_pkthdr.csum_data >> 16)
m->m_pkthdr.csum_data =
Index: src/sys/dev/ic/hme.c
diff -u src/sys/dev/ic/hme.c:1.66.10.2 src/sys/dev/ic/hme.c:1.66.10.3
--- src/sys/dev/ic/hme.c:1.66.10.2 Fri May 1 01:54:09 2009
+++ src/sys/dev/ic/hme.c Fri May 1 01:56:16 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: hme.c,v 1.66.10.2 2009/05/01 01:54:09 snj Exp $ */
+/* $NetBSD: hme.c,v 1.66.10.3 2009/05/01 01:56:16 snj Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hme.c,v 1.66.10.2 2009/05/01 01:54:09 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hme.c,v 1.66.10.3 2009/05/01 01:56:16 snj Exp $");
/* #define HMEDEBUG */
@@ -807,9 +807,8 @@
while (optsum >> 16)
optsum = (optsum >> 16) + (optsum & 0xffff);
- /* Deduct the ip opts sum from the hwsum (rfc 1624). */
- m0->m_pkthdr.csum_data = ~((~m0->m_pkthdr.csum_data) -
- ~optsum);
+ /* Deduct the ip opts sum from the hwsum. */
+ m0->m_pkthdr.csum_data += (uint16_t)~optsum;
while (m0->m_pkthdr.csum_data >> 16)
m0->m_pkthdr.csum_data =