2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-13 14:07:02 +00:00

compat: Clean up gre_calc_hlen

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>
This commit is contained in:
Greg Rose
2019-07-03 10:04:54 -07:00
committed by Ben Pfaff
parent b943fba797
commit 6d97adeea9
5 changed files with 29 additions and 43 deletions

View 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

View 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)
{

View 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)
{

View 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 */
/*

View 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)
{