datapath: Compatibility code for csum_replace4.
authorJesse Gross <jesse@nicira.com>
Tue, 7 Dec 2010 02:58:30 +0000 (18:58 -0800)
committerJesse Gross <jesse@nicira.com>
Fri, 10 Dec 2010 01:43:36 +0000 (17:43 -0800)
Kernels ealier than 2.6.25 did not define csum_replace4, so
implement it ourselves.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/linux-2.6/compat-2.6/include/net/checksum.h

index 96fd3a6986c8b30427e56b15e204fbaececc522c..a8c47d855e4b3590b36ba54c9ebe684becc0963a 100644 (file)
@@ -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 */