From: Jesse Gross Date: Tue, 7 Dec 2010 02:58:30 +0000 (-0800) Subject: datapath: Compatibility code for csum_replace4. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02a8cc607590c0f13eb3727ffda8e6ea7898a140;p=openvswitch datapath: Compatibility code for csum_replace4. Kernels ealier than 2.6.25 did not define csum_replace4, so implement it ourselves. Signed-off-by: Jesse Gross Acked-by: Ben Pfaff --- diff --git a/datapath/linux-2.6/compat-2.6/include/net/checksum.h b/datapath/linux-2.6/compat-2.6/include/net/checksum.h index 96fd3a69..a8c47d85 100644 --- a/datapath/linux-2.6/compat-2.6/include/net/checksum.h +++ b/datapath/linux-2.6/compat-2.6/include/net/checksum.h @@ -18,4 +18,13 @@ static inline __wsum csum_unfold(__sum16 n) csum_and_copy_to_user(src, dst, len, sum, NULL, err_ptr) #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) +static inline void csum_replace4(__sum16 *sum, __be32 from, __be32 to) +{ + __be32 diff[] = { ~from, to }; + + sum = csum_fold(csum_partial((char *)diff, sizeof(diff), ~csum_unfold(*sum))); +} +#endif + #endif /* checksum.h */