2013-06-20 17:11:43 -07:00
|
|
|
#ifndef __LINUX_GRE_WRAPPER_H
|
|
|
|
#define __LINUX_GRE_WRAPPER_H
|
|
|
|
|
2015-12-10 20:03:01 -08:00
|
|
|
#include <linux/version.h>
|
2013-06-20 17:11:43 -07:00
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <net/ip_tunnels.h>
|
2015-12-10 20:03:01 -08:00
|
|
|
|
2016-07-07 21:49:20 -07:00
|
|
|
#ifdef USE_UPSTREAM_TUNNEL
|
2015-12-03 11:40:53 -08:00
|
|
|
#include_next <net/gre.h>
|
|
|
|
|
|
|
|
static inline int rpl_ipgre_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void rpl_ipgre_fini(void)
|
|
|
|
{}
|
|
|
|
|
2018-03-05 10:11:57 -08:00
|
|
|
static inline int rpl_ip6gre_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rpl_ip6gre_fini(void)
|
|
|
|
{}
|
|
|
|
|
|
|
|
static inline int rpl_ip6_tunnel_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rpl_ip6_tunnel_cleanup(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-03 11:40:53 -08:00
|
|
|
#define gre_fb_xmit dev_queue_xmit
|
|
|
|
|
2016-12-08 18:34:05 -08:00
|
|
|
#ifdef CONFIG_INET
|
|
|
|
#ifndef HAVE_NAME_ASSIGN_TYPE
|
|
|
|
static inline struct net_device *rpl_gretap_fb_dev_create(
|
|
|
|
struct net *net, const char *name, u8 name_assign_type) {
|
|
|
|
return gretap_fb_dev_create(net, name);
|
|
|
|
}
|
|
|
|
#define gretap_fb_dev_create rpl_gretap_fb_dev_create
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2015-12-03 11:40:53 -08:00
|
|
|
#else
|
2013-06-20 17:11:43 -07:00
|
|
|
#include_next <net/gre.h>
|
|
|
|
|
2018-02-27 08:36:28 -08:00
|
|
|
#define tnl_flags_to_gre_flags rpl_tnl_flags_to_gre_flags
|
2018-03-05 10:09:10 -08:00
|
|
|
static inline __be16 rpl_tnl_flags_to_gre_flags(__be16 tflags)
|
|
|
|
{
|
|
|
|
__be16 flags = 0;
|
|
|
|
|
|
|
|
if (tflags & TUNNEL_CSUM)
|
|
|
|
flags |= GRE_CSUM;
|
|
|
|
if (tflags & TUNNEL_ROUTING)
|
|
|
|
flags |= GRE_ROUTING;
|
|
|
|
if (tflags & TUNNEL_KEY)
|
|
|
|
flags |= GRE_KEY;
|
|
|
|
if (tflags & TUNNEL_SEQ)
|
|
|
|
flags |= GRE_SEQ;
|
|
|
|
if (tflags & TUNNEL_STRICT)
|
|
|
|
flags |= GRE_STRICT;
|
|
|
|
if (tflags & TUNNEL_REC)
|
|
|
|
flags |= GRE_REC;
|
|
|
|
if (tflags & TUNNEL_VERSION)
|
|
|
|
flags |= GRE_VERSION;
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define gre_flags_to_tnl_flags rpl_gre_flags_to_tnl_flags
|
|
|
|
static inline __be16 rpl_gre_flags_to_tnl_flags(__be16 flags)
|
|
|
|
{
|
|
|
|
__be16 tflags = 0;
|
|
|
|
|
|
|
|
if (flags & GRE_CSUM)
|
|
|
|
tflags |= TUNNEL_CSUM;
|
|
|
|
if (flags & GRE_ROUTING)
|
|
|
|
tflags |= TUNNEL_ROUTING;
|
|
|
|
if (flags & GRE_KEY)
|
|
|
|
tflags |= TUNNEL_KEY;
|
|
|
|
if (flags & GRE_SEQ)
|
|
|
|
tflags |= TUNNEL_SEQ;
|
|
|
|
if (flags & GRE_STRICT)
|
|
|
|
tflags |= TUNNEL_STRICT;
|
|
|
|
if (flags & GRE_REC)
|
|
|
|
tflags |= TUNNEL_REC;
|
|
|
|
if (flags & GRE_VERSION)
|
|
|
|
tflags |= TUNNEL_VERSION;
|
|
|
|
|
|
|
|
return tflags;
|
|
|
|
}
|
|
|
|
#define gre_tnl_flags_to_gre_flags rpl_gre_tnl_flags_to_gre_flags
|
|
|
|
static inline __be16 rpl_gre_tnl_flags_to_gre_flags(__be16 tflags)
|
2018-02-27 08:36:28 -08:00
|
|
|
{
|
|
|
|
__be16 flags = 0;
|
|
|
|
|
|
|
|
if (tflags & TUNNEL_CSUM)
|
|
|
|
flags |= GRE_CSUM;
|
|
|
|
if (tflags & TUNNEL_ROUTING)
|
|
|
|
flags |= GRE_ROUTING;
|
|
|
|
if (tflags & TUNNEL_KEY)
|
|
|
|
flags |= GRE_KEY;
|
|
|
|
if (tflags & TUNNEL_SEQ)
|
|
|
|
flags |= GRE_SEQ;
|
|
|
|
if (tflags & TUNNEL_STRICT)
|
|
|
|
flags |= GRE_STRICT;
|
|
|
|
if (tflags & TUNNEL_REC)
|
|
|
|
flags |= GRE_REC;
|
|
|
|
if (tflags & TUNNEL_VERSION)
|
|
|
|
flags |= GRE_VERSION;
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2013-12-22 19:43:58 -08:00
|
|
|
#ifndef HAVE_GRE_CISCO_REGISTER
|
2013-06-20 17:11:43 -07:00
|
|
|
|
2013-12-22 19:43:58 -08:00
|
|
|
/* GRE demux not available, implement our own demux. */
|
|
|
|
#define MAX_GRE_PROTO_PRIORITY 255
|
2013-06-20 17:11:43 -07:00
|
|
|
|
2013-12-22 19:43:58 -08:00
|
|
|
struct gre_cisco_protocol {
|
|
|
|
int (*handler)(struct sk_buff *skb, const struct tnl_ptk_info *tpi);
|
2014-04-05 16:17:35 -07:00
|
|
|
int (*err_handler)(struct sk_buff *skb, u32 info,
|
|
|
|
const struct tnl_ptk_info *tpi);
|
2013-12-22 19:43:58 -08:00
|
|
|
u8 priority;
|
2013-06-20 17:11:43 -07:00
|
|
|
};
|
|
|
|
|
2013-12-22 19:43:58 -08:00
|
|
|
#define gre_cisco_register rpl_gre_cisco_register
|
2015-04-20 18:19:53 -07:00
|
|
|
int rpl_gre_cisco_register(struct gre_cisco_protocol *proto);
|
2013-06-20 17:11:43 -07:00
|
|
|
|
2013-12-22 19:43:58 -08:00
|
|
|
#define gre_cisco_unregister rpl_gre_cisco_unregister
|
2015-04-20 18:19:53 -07:00
|
|
|
int rpl_gre_cisco_unregister(struct gre_cisco_protocol *proto);
|
2013-06-20 17:11:43 -07:00
|
|
|
|
2015-12-03 11:40:53 -08:00
|
|
|
#ifndef GRE_HEADER_SECTION
|
2013-06-20 17:11:43 -07:00
|
|
|
struct gre_base_hdr {
|
|
|
|
__be16 flags;
|
|
|
|
__be16 protocol;
|
|
|
|
};
|
|
|
|
#define GRE_HEADER_SECTION 4
|
2015-12-03 11:40:53 -08:00
|
|
|
#endif
|
2013-06-20 17:11:43 -07:00
|
|
|
|
2013-12-22 19:43:58 -08:00
|
|
|
#endif /* HAVE_GRE_CISCO_REGISTER */
|
2013-11-20 09:50:14 -08:00
|
|
|
|
2018-02-22 12:28:02 -08:00
|
|
|
#define gre_build_header rpl_gre_build_header
|
|
|
|
void rpl_gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
|
|
|
|
int hdr_len);
|
|
|
|
|
2015-12-03 11:40:53 -08:00
|
|
|
int rpl_ipgre_init(void);
|
|
|
|
void rpl_ipgre_fini(void);
|
2018-03-05 10:11:57 -08:00
|
|
|
int rpl_ip6gre_init(void);
|
|
|
|
void rpl_ip6gre_fini(void);
|
|
|
|
int rpl_ip6_tunnel_init(void);
|
|
|
|
void rpl_ip6_tunnel_cleanup(void);
|
2015-05-01 17:30:44 -07:00
|
|
|
|
2015-12-03 11:40:53 -08:00
|
|
|
#define gretap_fb_dev_create rpl_gretap_fb_dev_create
|
|
|
|
struct net_device *rpl_gretap_fb_dev_create(struct net *net, const char *name,
|
|
|
|
u8 name_assign_type);
|
2014-02-07 10:46:53 -08:00
|
|
|
|
2018-02-22 12:28:02 -08:00
|
|
|
#define gre_parse_header rpl_gre_parse_header
|
|
|
|
int rpl_gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
|
|
|
|
bool *csum_err, __be16 proto, int nhs);
|
|
|
|
|
2015-12-03 11:40:53 -08:00
|
|
|
#define gre_fb_xmit rpl_gre_fb_xmit
|
|
|
|
netdev_tx_t rpl_gre_fb_xmit(struct sk_buff *skb);
|
2016-07-07 21:49:20 -07:00
|
|
|
#endif /* USE_UPSTREAM_TUNNEL */
|
2013-08-02 11:38:51 -07:00
|
|
|
|
2015-12-03 11:40:53 -08:00
|
|
|
#define ipgre_init rpl_ipgre_init
|
|
|
|
#define ipgre_fini rpl_ipgre_fini
|
2018-03-05 10:11:57 -08:00
|
|
|
#define ip6gre_init rpl_ip6gre_init
|
|
|
|
#define ip6gre_fini rpl_ip6gre_fini
|
|
|
|
#define ip6_tunnel_init rpl_ip6_tunnel_init
|
|
|
|
#define ip6_tunnel_cleanup rpl_ip6_tunnel_cleanup
|
2013-08-02 11:38:51 -07:00
|
|
|
|
2016-07-07 19:35:33 -07:00
|
|
|
#define gre_fill_metadata_dst ovs_gre_fill_metadata_dst
|
|
|
|
int ovs_gre_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb);
|
|
|
|
|
2018-02-22 12:28:02 -08:00
|
|
|
|
2013-06-20 17:11:43 -07:00
|
|
|
#endif
|