Explain why ptclcsum_finalize is correct
authorXiao Jia <stfairy@gmail.com>
Wed, 28 Oct 2015 00:36:39 +0000 (17:36 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 3 Nov 2015 17:00:38 +0000 (12:00 -0500)
Signed-off-by: Xiao Jia <stfairy@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/include/ip.h

index 7744c51..6e8f7dd 100644 (file)
@@ -672,6 +672,10 @@ static inline void ptclcsum_finalize(struct block *bp, unsigned int feat)
 
        if (flag && (flag & feat) != flag) {
                csum_store = bp->rp + bp->checksum_start + bp->checksum_offset;
+               /* NOTE pseudo-header partial checksum (if any) is already placed at
+                * csum_store (e.g. tcpcksum), and the ptclcsum() below will include
+                * that partial checksum as part of the calculation.
+                */
                hnputs((uint16_t *)csum_store,
                       ptclcsum(bp, bp->checksum_start,
                                BLEN(bp) - bp->checksum_start));