[ovs-dev] [PATCH] compat: Add skb_checksum_simple_complete()

Greg Rose gvrose8192 at gmail.com
Fri Jun 1 20:07:43 UTC 2018


A recent patch to gre.c added a call to skb_checksum_simple_complete()
which is not present in kernels before 3.16.  Fix up the compatability
layer to allow compile on older kernels that do not have it.

Signed-off-by: Greg Rose <gvrose8192 at gmail.com>
---
 acinclude.m4                                 |  5 +++++
 datapath/linux/compat/include/linux/skbuff.h | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/acinclude.m4 b/acinclude.m4
index 7a653cb..991a627 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -872,6 +872,11 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
                   [IFLA_GRE_ERSPAN_HWID])
   OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
                   [IFLA_IPTUN_FWMARK])
+  OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/skbuff.h], [sk_buff],
+                        [csum_valid],
+                        [OVS_DEFINE([HAVE_SKBUFF_CSUM_VALID])])
+  OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],
+                  [skb_checksum_simple_validate])
 
   if cmp -s datapath/linux/kcompat.h.new \
             datapath/linux/kcompat.h >/dev/null 2>&1; then
diff --git a/datapath/linux/compat/include/linux/skbuff.h b/datapath/linux/compat/include/linux/skbuff.h
index 63ffcaa..c50cac2 100644
--- a/datapath/linux/compat/include/linux/skbuff.h
+++ b/datapath/linux/compat/include/linux/skbuff.h
@@ -32,7 +32,11 @@ static inline __wsum null_compute_pseudo(struct sk_buff *skb, int proto)
 #ifndef HAVE_SKB_CHECKSUM_CONVERT
 static inline bool __skb_checksum_convert_check(struct sk_buff *skb)
 {
+#ifdef HAVE_SKBUFF_CSUM_VALID
 	return (skb->ip_summed == CHECKSUM_NONE && skb->csum_valid);
+#else
+	return skb->ip_summed == CHECKSUM_NONE;
+#endif
 }
 
 static inline void __skb_checksum_convert(struct sk_buff *skb,
@@ -50,6 +54,21 @@ do {									\
 } while (0)
 
 #endif
+
+#ifndef SKB_CHECKSUM_SIMPLE_VALIDATE
+
+#define __skb_checksum_validate(skb, proto, complete,			\
+				zero_okay, check, compute_pseudo)	\
+({									\
+	__sum16 __ret = 0;						\
+	__ret;								\
+})
+
+
+#define skb_checksum_simple_validate(skb)				\
+	__skb_checksum_validate(skb, 0, true, false, 0, null_compute_pseudo)
+#endif
+
 #ifndef HAVE_SKB_COPY_FROM_LINEAR_DATA_OFFSET
 static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb,
 						    const int offset, void *to,
-- 
1.8.3.1



More information about the dev mailing list