[ovs-dev] [PATCH] compat: Fix upstream 4.4.119 kernel

Greg Rose gvrose8192 at gmail.com
Fri Apr 20 18:13:07 UTC 2018


The Linux 4.4.119 kernel (and perhaps others) from kernel.org
backports some dst_cache code that breaks the openvswitch kernel
due to a duplicated name "dst_cache_destroy".  For most cases the
"USE_UPSTREAM_TUNNEL" covers this but in this case the dst_cache
feature needs to be separated out.

Add the necessary compatibility detection layer in acinclude.m4 and
then fixup the source files so that if the built-in kernel includes
dst_cache support then exclude our own compatibility code.

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

diff --git a/acinclude.m4 b/acinclude.m4
index dd264b3..60186d3 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -533,6 +533,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
                         [OVS_GREP_IFELSE([$KSRC/include/net/dst_cache.h], [dst_cache],
                                          [OVS_DEFINE([USE_UPSTREAM_TUNNEL])])])])
 
+  OVS_GREP_IFELSE([$KSRC/include/net/dst_cache.h], [dst_cache],
+                  [OVS_DEFINE([USE_BUILTIN_DST_CACHE])])
   OVS_GREP_IFELSE([$KSRC/include/net/mpls.h], [mpls_hdr],
                   [OVS_DEFINE([MPLS_HEADER_IS_L3])])
   OVS_GREP_IFELSE([$KSRC/include/linux/net.h], [sock_create_kern.*net],
diff --git a/datapath/linux/compat/dst_cache.c b/datapath/linux/compat/dst_cache.c
index b936516..45990cb 100644
--- a/datapath/linux/compat/dst_cache.c
+++ b/datapath/linux/compat/dst_cache.c
@@ -9,6 +9,7 @@
  * (at your option) any later version.
  */
 
+#ifndef USE_BUILTIN_DST_CACHE
 #include <linux/kernel.h>
 #include <linux/percpu.h>
 #include <net/dst_cache.h>
@@ -169,3 +170,4 @@ void rpl_dst_cache_destroy(struct dst_cache *dst_cache)
 }
 EXPORT_SYMBOL_GPL(rpl_dst_cache_destroy);
 #endif /*USE_UPSTREAM_TUNNEL */
+#endif /* USE_BUILTIN_DST_CACHE */
diff --git a/datapath/linux/compat/include/net/dst_cache.h b/datapath/linux/compat/include/net/dst_cache.h
index ff4d83b..6084d4e 100644
--- a/datapath/linux/compat/include/net/dst_cache.h
+++ b/datapath/linux/compat/include/net/dst_cache.h
@@ -1,6 +1,10 @@
 #ifndef _NET_DST_CACHE_WRAPPER_H
 #define _NET_DST_CACHE_WRAPPER_H
 
+#ifdef USE_BUILTIN_DST_CACHE
+#include_next <net/dst_cache.h>
+#else
+
 #include <linux/jiffies.h>
 #include <net/dst.h>
 #if IS_ENABLED(CONFIG_IPV6)
@@ -106,4 +110,5 @@ int rpl_dst_cache_init(struct dst_cache *dst_cache, gfp_t gfp);
 void rpl_dst_cache_destroy(struct dst_cache *dst_cache);
 
 #endif /* USE_UPSTREAM_TUNNEL */
+#endif /* USE_BUILTIN_DST_CACHE */
 #endif
-- 
1.8.3.1



More information about the dev mailing list