]> git.proxmox.com Git - ovs.git/commitdiff
compat: Clean up gre_calc_hlen
authorGreg Rose <gvrose8192@gmail.com>
Wed, 3 Jul 2019 17:04:54 +0000 (10:04 -0700)
committerBen Pfaff <blp@ovn.org>
Wed, 3 Jul 2019 18:16:23 +0000 (11:16 -0700)
It's proliferated throughout three .c files so let's pull them all
together in gre.h where the inline function belongs. This requires
some adjustments to the compat layer so that the various iterations
of gre_calc_hlen and ip_gre_calc_hlen since the 3.10 kernel are
handled correctly.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
acinclude.m4
datapath/linux/compat/gre.c
datapath/linux/compat/include/net/gre.h
datapath/linux/compat/ip6_gre.c
datapath/linux/compat/ip_gre.c

index 321a741985dbbf6fc0773bb13a7eddb0a7afc980..b8c9d6c06fbab1e147a1e07cb33743624c21a3d4 100644 (file)
@@ -966,6 +966,10 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
   OVS_FIND_PARAM_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_helper.h],
                         [nf_ct_helper_ext_add], [nf_conntrack_helper],
                         [OVS_DEFINE([HAVE_NF_CT_HELPER_EXT_ADD_TAKES_HELPER])])
+  OVS_GREP_IFELSE([$KSRC/include/net/gre.h], [gre_calc_hlen],
+                  [OVS_DEFINE([HAVE_GRE_CALC_HLEN])])
+  OVS_GREP_IFELSE([$KSRC/include/net/gre.h], [ip_gre_calc_hlen],
+                  [OVS_DEFINE([HAVE_IP_GRE_CALC_HLEN])])
 
   if cmp -s datapath/linux/kcompat.h.new \
             datapath/linux/kcompat.h >/dev/null 2>&1; then
index 2b14c5ac0fe025e213b1a149cf697e1f6f20aef0..e57528f806c4f5a8afaca4f01c5ad686aa705d1b 100644 (file)
@@ -139,21 +139,6 @@ void rpl_gre_exit(void)
 }
 EXPORT_SYMBOL_GPL(rpl_gre_exit);
 
-#define ip_gre_calc_hlen rpl_ip_gre_calc_hlen
-#define gre_calc_hlen rpl_ip_gre_calc_hlen
-static int rpl_ip_gre_calc_hlen(__be16 o_flags)
-{
-       int addend = 4;
-
-       if (o_flags & TUNNEL_CSUM)
-               addend += 4;
-       if (o_flags & TUNNEL_KEY)
-               addend += 4;
-       if (o_flags & TUNNEL_SEQ)
-               addend += 4;
-       return addend;
-}
-
 void rpl_gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
                          int hdr_len)
 {
index 58fa97a8d23aeb0d73d92fe7deb22d234207a901..57293b6c24556611de4015cbe22df4658d3cee55 100644 (file)
@@ -56,6 +56,27 @@ static inline struct net_device *rpl_gretap_fb_dev_create(
 #else
 #include_next <net/gre.h>
 
+#ifndef HAVE_GRE_CALC_HLEN
+static inline int gre_calc_hlen(__be16 o_flags)
+{
+       int addend = 4;
+
+       if (o_flags & TUNNEL_CSUM)
+               addend += 4;
+       if (o_flags & TUNNEL_KEY)
+               addend += 4;
+       if (o_flags & TUNNEL_SEQ)
+               addend += 4;
+       return addend;
+}
+
+#define ip_gre_calc_hlen gre_calc_hlen
+#else
+#ifdef HAVE_IP_GRE_CALC_HLEN
+#define gre_calc_hlen ip_gre_calc_hlen
+#endif
+#endif
+
 #define tnl_flags_to_gre_flags rpl_tnl_flags_to_gre_flags
 static inline __be16 rpl_tnl_flags_to_gre_flags(__be16 tflags)
 {
index 850e7032df4dd723612e461941aa1516cdfb14b7..a95c5f8043a496b8a0b017861e23131465e82a01 100644 (file)
@@ -83,20 +83,6 @@ static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
 static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu);
 static void ip6erspan_tnl_link_config(struct ip6_tnl *t, int set_mtu);
 
-#define gre_calc_hlen rpl_ip_gre_calc_hlen
-static int rpl_ip_gre_calc_hlen(__be16 o_flags)
-{
-       int addend = 4;
-
-       if (o_flags & TUNNEL_CSUM)
-               addend += 4;
-       if (o_flags & TUNNEL_KEY)
-               addend += 4;
-       if (o_flags & TUNNEL_SEQ)
-               addend += 4;
-       return addend;
-}
-
 /* Tunnel hash table */
 
 /*
index 77c5b476507637d9eda20851a5a7635114ebe64c..6766661508740e81c7c6c312a0a241a44268eb7f 100644 (file)
@@ -71,20 +71,6 @@ static void erspan_build_header(struct sk_buff *skb,
 
 static bool ip_gre_loaded = false;
 
-#define ip_gre_calc_hlen rpl_ip_gre_calc_hlen
-static int ip_gre_calc_hlen(__be16 o_flags)
-{
-       int addend = 4;
-
-       if (o_flags & TUNNEL_CSUM)
-               addend += 4;
-       if (o_flags & TUNNEL_KEY)
-               addend += 4;
-       if (o_flags & TUNNEL_SEQ)
-               addend += 4;
-       return addend;
-}
-
 /* Returns the least-significant 32 bits of a __be64. */
 static __be32 tunnel_id_to_key(__be64 x)
 {
@@ -100,6 +86,10 @@ struct dst_ops md_dst_ops = {
        .family =               AF_UNSPEC,
 };
 
+#ifndef ip_gre_calc_hlen
+#define ip_gre_calc_hlen gre_calc_hlen
+#endif
+
 static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
                      int gre_hdr_len)
 {