datapath: Harmonize [get|set]_skb_csum_pointers().
authorJesse Gross <jesse@nicira.com>
Thu, 16 Dec 2010 00:50:40 +0000 (16:50 -0800)
committerJesse Gross <jesse@nicira.com>
Thu, 16 Dec 2010 17:42:14 +0000 (09:42 -0800)
The functions to get and set the checksum pointers consistently across
different kernel versions had different interpretations of what the
csum_offset pointer was relative to, which is confusing, to say the least.
This makes the meaning be the same as skb->csum_offset in modern kernels
and updates the caller.  For a given function the results were consistent
across kernel versions and the callers knew what the meaning should be, so
this doesn't actually fix any bugs.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/checksum.h
datapath/datapath.c

index 7d653961eb5000f3451f629364886713139cae91..ad5cd01ba6ab87c57c257284ad14dade8e42d67a 100644 (file)
@@ -82,10 +82,10 @@ static inline void get_skb_csum_pointers(const struct sk_buff *skb,
                                         u16 *csum_start, u16 *csum_offset)
 {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
-       *csum_start = skb->csum_start - skb_headroom(skb);
+       *csum_start = skb->csum_start;
        *csum_offset = skb->csum_offset;
 #else
-       *csum_start = skb_transport_header(skb) - skb->data;
+       *csum_start = skb_headroom(skb) + skb_transport_offset(skb);
        *csum_offset = skb->csum;
 #endif
 }
index fded95ce191cc157e0b3e7c06864816d73d60491..cf163234086b3800f8593b6259c1015ffd22c135 100644 (file)
@@ -1938,6 +1938,8 @@ success:
                        u16 csum_start, csum_offset;
 
                        get_skb_csum_pointers(skb, &csum_start, &csum_offset);
+                       csum_start -= skb_headroom(skb);
+
                        BUG_ON(csum_start >= skb_headlen(skb));
                        retval = skb_copy_and_csum_datagram(skb, csum_start, buf + csum_start,
                                                            copy_bytes - csum_start, &csum);