From: Jesse Gross Date: Thu, 16 Dec 2010 00:50:40 +0000 (-0800) Subject: datapath: Harmonize [get|set]_skb_csum_pointers(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0ce13c4dc34f44d81e0001882a0be88321b5c87;p=openvswitch datapath: Harmonize [get|set]_skb_csum_pointers(). 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 Acked-by: Ben Pfaff --- diff --git a/datapath/checksum.h b/datapath/checksum.h index 7d653961..ad5cd01b 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 fded95ce..cf163234 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);