[ovs-dev] [PATCH 2/2] datapath: Harmonize [get|set]_skb_csum_pointers().

Jesse Gross jesse at nicira.com
Thu Dec 16 04:15:59 UTC 2010


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 callers.  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 at nicira.com>
---
 datapath/checksum.h |    4 ++--
 datapath/datapath.c |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/datapath/checksum.h b/datapath/checksum.h
index 7d65396..ad5cd01 100644
--- a/datapath/checksum.h
+++ b/datapath/checksum.h
@@ -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
 }
diff --git a/datapath/datapath.c b/datapath/datapath.c
index fded95c..cf16323 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -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);
-- 
1.7.1





More information about the dev mailing list