From 02a8cc607590c0f13eb3727ffda8e6ea7898a140 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Mon, 6 Dec 2010 18:58:30 -0800 Subject: [PATCH] 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 --- datapath/linux-2.6/compat-2.6/include/net/checksum.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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 */ -- 2.30.2