From e0ce13c4dc34f44d81e0001882a0be88321b5c87 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Wed, 15 Dec 2010 16:50:40 -0800 Subject: [PATCH] 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 --- 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 7d653961e..ad5cd01ba 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 fded95ce1..cf1632340 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); -- 2.43.0