The 1's complement checksum in m->m_pkthdr.csum_data was not being properly
authorMatthew Dillon <dillon@dragonflybsd.org>
Fri, 10 Aug 2007 18:23:07 +0000 (18:23 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Fri, 10 Aug 2007 18:23:07 +0000 (18:23 +0000)
calculated.  With 1's complement you have to take the carry past 16 bits
and fold it back into the checksum.

sys/netinet/ip_input.c

index c44a9c7..2e39add 100644 (file)
@@ -65,7 +65,7 @@
  *
  *     @(#)ip_input.c  8.2 (Berkeley) 1/4/94
  * $FreeBSD: src/sys/netinet/ip_input.c,v 1.130.2.52 2003/03/07 07:01:28 silby Exp $
- * $DragonFly: src/sys/netinet/ip_input.c,v 1.67 2007/05/23 08:57:09 dillon Exp $
+ * $DragonFly: src/sys/netinet/ip_input.c,v 1.68 2007/08/10 18:23:07 dillon Exp $
  */
 
 #define        _IP_VHL
@@ -1293,6 +1293,15 @@ inserted:
                m_cat(m, q);
        }
 
+       /*
+        * Clean up the 1's complement checksum.  Carry over 16 bits must
+        * be added back.  This assumes no more then 65535 packet fragments
+        * were reassembled.
+        */
+       m->m_pkthdr.csum_data = (m->m_pkthdr.csum_data & 0xffff) +
+                               (m->m_pkthdr.csum_data >> 16);
+
+
 #ifdef IPDIVERT
        /*
         * Extract firewall instructions from the fragment structure.