diff --git a/acinclude.m4 b/acinclude.m4 index 321a74198..b8c9d6c06 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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 diff --git a/datapath/linux/compat/gre.c b/datapath/linux/compat/gre.c index 2b14c5ac0..e57528f80 100644 --- a/datapath/linux/compat/gre.c +++ b/datapath/linux/compat/gre.c @@ -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) { diff --git a/datapath/linux/compat/include/net/gre.h b/datapath/linux/compat/include/net/gre.h index 58fa97a8d..57293b6c2 100644 --- a/datapath/linux/compat/include/net/gre.h +++ b/datapath/linux/compat/include/net/gre.h @@ -56,6 +56,27 @@ static inline struct net_device *rpl_gretap_fb_dev_create( #else #include_next +#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) { diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c index 850e7032d..a95c5f804 100644 --- a/datapath/linux/compat/ip6_gre.c +++ b/datapath/linux/compat/ip6_gre.c @@ -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 */ /* diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c index 77c5b4765..676666150 100644 --- a/datapath/linux/compat/ip_gre.c +++ b/datapath/linux/compat/ip_gre.c @@ -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) {