[ovs-dev] [PATCH] datapath: Fix ip tunnel compilation for newer kernel.

Pravin B Shelar pshelar at ovn.org
Mon Jul 11 18:49:23 UTC 2016


compat iptunnel_xmit is used in backported tunnel code. but
it was only defined for kernel older than 3.18, This patch fixes
it by compiling it for all kernel which needs to use backported
tunnel implementation.

Reported-by: Justin Pettit <jpettit at ovn.org>
Reported-by: Joe Stringer <joe at ovn.org>
Signed-off-by: Pravin B Shelar <pshelar at ovn.org>
---
 datapath/linux/compat/include/net/ip_tunnels.h | 13 ++---------
 datapath/linux/compat/include/net/udp_tunnel.h | 32 +++++++++++---------------
 datapath/linux/compat/ip_tunnels_core.c        |  7 ++----
 3 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/datapath/linux/compat/include/net/ip_tunnels.h b/datapath/linux/compat/include/net/ip_tunnels.h
index e3f9b60..7c5c9b5 100644
--- a/datapath/linux/compat/include/net/ip_tunnels.h
+++ b/datapath/linux/compat/include/net/ip_tunnels.h
@@ -8,7 +8,7 @@
  * Only function that do not depend on ip_tunnel structure can
  * be used. Those needs to be explicitly defined in this header file. */
 #include_next <net/ip_tunnels.h>
-#endif
+#else
 
 #include <linux/if_tunnel.h>
 #include <linux/types.h>
@@ -19,7 +19,6 @@
 #include <net/ip.h>
 #include <net/rtnetlink.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)
 #define __iptunnel_pull_header rpl___iptunnel_pull_header
 int rpl___iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
 			   __be16 inner_proto, bool raw_proto, bool xnet);
@@ -30,9 +29,7 @@ static inline int rpl_iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
 {
 	return rpl___iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);
 }
-#endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)
 int ovs_iptunnel_handle_offloads(struct sk_buff *skb,
 				 bool csum_help, int gso_type_mask,
 				 void (*fix_segment)(struct sk_buff *));
@@ -46,11 +43,6 @@ int ovs_iptunnel_handle_offloads(struct sk_buff *skb,
 struct sk_buff *rpl_iptunnel_handle_offloads(struct sk_buff *skb,
 					 bool csum_help,
 					 int gso_type_mask);
-#else
-
-#define ovs_iptunnel_handle_offloads(skb, csum_help, gso_type_mask, fix_segment) \
-	iptunnel_handle_offloads(skb, gso_type_mask)
-#endif
 
 #define iptunnel_xmit rpl_iptunnel_xmit
 void rpl_iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
@@ -102,7 +94,6 @@ struct tnl_ptk_info {
 #define skb_is_encapsulated ovs_skb_is_encapsulated
 bool ovs_skb_is_encapsulated(struct sk_buff *skb);
 
-#ifndef USE_UPSTREAM_TUNNEL
 /* Used to memset ip_tunnel padding. */
 #define IP_TUNNEL_KEY_SIZE	offsetofend(struct ip_tunnel_key, tp_dst)
 
@@ -334,7 +325,6 @@ int rpl_ip_tunnel_get_iflink(const struct net_device *dev);
 
 #define ip_tunnel_get_link_net rpl_ip_tunnel_get_link_net
 struct net *rpl_ip_tunnel_get_link_net(const struct net_device *dev);
-#endif /* USE_UPSTREAM_TUNNEL */
 
 #ifndef HAVE___IP_TUNNEL_CHANGE_MTU
 #define __ip_tunnel_change_mtu rpl___ip_tunnel_change_mtu
@@ -356,4 +346,5 @@ static inline int iptunnel_pull_offloads(struct sk_buff *skb)
 	skb->encapsulation = 0;
 	return 0;
 }
+#endif /* USE_UPSTREAM_TUNNEL */
 #endif /* __NET_IP_TUNNELS_H */
diff --git a/datapath/linux/compat/include/net/udp_tunnel.h b/datapath/linux/compat/include/net/udp_tunnel.h
index e154197..f1e8853 100644
--- a/datapath/linux/compat/include/net/udp_tunnel.h
+++ b/datapath/linux/compat/include/net/udp_tunnel.h
@@ -11,6 +11,19 @@
 #ifdef USE_UPSTREAM_TUNNEL
 #include_next <net/udp_tunnel.h>
 
+/* this is to handle the return type change in handle-offload
+ * functions.
+ */
+static inline int
+rpl_udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum,
+			       bool is_vxlan)
+{
+	if (skb_is_gso(skb) && skb_is_encapsulated(skb)) {
+		return -ENOSYS;
+	}
+	return udp_tunnel_handle_offloads(skb, udp_csum);
+}
+
 #else
 
 #include <net/addrconf.h>
@@ -143,23 +156,7 @@ static inline void udp_tunnel_gro_complete(struct sk_buff *skb, int nhoff)
 	skb_shinfo(skb)->gso_type |= uh->check ?
 		SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL;
 }
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0)
-/* this is to handle the return type change in handle-offload
- * functions.
- */
-static inline int
-rpl_udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum,
-			       bool is_vxlan)
-{
-	if (skb_is_gso(skb) && skb_is_encapsulated(skb)) {
-		return -ENOSYS;
-	}
-	return udp_tunnel_handle_offloads(skb, udp_csum);
-}
 
-#else
 void ovs_udp_gso(struct sk_buff *skb);
 void ovs_udp_csum_gso(struct sk_buff *skb);
 
@@ -188,10 +185,9 @@ static inline int rpl_udp_tunnel_handle_offloads(struct sk_buff *skb,
 
 	return ovs_iptunnel_handle_offloads(skb, udp_csum, type, fix_segment);
 }
-#endif
+#endif /* USE_UPSTREAM_TUNNEL */
 
 #define udp_tunnel_handle_offloads rpl_udp_tunnel_handle_offloads
-
 static inline void ovs_udp_tun_rx_dst(struct ip_tunnel_info *info,
 				  struct sk_buff *skb,
 				  unsigned short family,
diff --git a/datapath/linux/compat/ip_tunnels_core.c b/datapath/linux/compat/ip_tunnels_core.c
index c22f5dd..65b5aea 100644
--- a/datapath/linux/compat/ip_tunnels_core.c
+++ b/datapath/linux/compat/ip_tunnels_core.c
@@ -37,7 +37,7 @@
 #include "gso.h"
 #include "vport-netdev.h"
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
+#ifndef USE_UPSTREAM_TUNNEL
 void rpl_iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
                       __be32 src, __be32 dst, __u8 proto, __u8 tos, __u8 ttl,
                       __be16 df, bool xnet)
@@ -87,9 +87,7 @@ void rpl_iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
 	iptunnel_xmit_stats(dev, pkt_len);
 }
 EXPORT_SYMBOL_GPL(rpl_iptunnel_xmit);
-#endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)
 int ovs_iptunnel_handle_offloads(struct sk_buff *skb,
 				 bool csum_help, int gso_type_mask,
 				 void (*fix_segment)(struct sk_buff *))
@@ -175,8 +173,7 @@ int rpl___iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
 	return iptunnel_pull_offloads(skb);
 }
 EXPORT_SYMBOL_GPL(rpl___iptunnel_pull_header);
-
-#endif
+#endif /* USE_UPSTREAM_TUNNEL */
 
 bool ovs_skb_is_encapsulated(struct sk_buff *skb)
 {
-- 
1.9.1




More information about the dev mailing list