#include "vport-netdev.h"
static int gre_tap_net_id __read_mostly;
-static int ipgre_net_id __read_mostly;
static unsigned int erspan_net_id __read_mostly;
static void erspan_build_header(struct sk_buff *skb,
__be32 id, u32 index,
bool truncate, bool is_ipv4);
-static struct rtnl_link_ops ipgre_link_ops __read_mostly;
static bool ip_gre_loaded = false;
#define ip_gre_calc_hlen rpl_ip_gre_calc_hlen
tpi->proto == htons(ETH_P_ERSPAN2))
itn = net_generic(net, erspan_net_id);
else
- itn = net_generic(net, ipgre_net_id);
+ return PACKET_RCVD;
res = __ipgre_rcv(skb, tpi, itn, hdr_len, false);
- if (res == PACKET_NEXT && tpi->proto == htons(ETH_P_TEB)) {
- /* ipgre tunnels in collect metadata mode should receive
- * also ETH_P_TEB traffic.
- */
- itn = net_generic(net, ipgre_net_id);
- res = __ipgre_rcv(skb, tpi, itn, hdr_len, true);
- }
+
return res;
}
.err_handler = __gre_err,
};
-static int __net_init ipgre_init_net(struct net *net)
-{
- return ip_tunnel_init_net(net, ipgre_net_id, &ipgre_link_ops, NULL);
-}
-
-static void __net_exit ipgre_exit_net(struct net *net)
-{
- struct ip_tunnel_net *itn = net_generic(net, ipgre_net_id);
-
- ip_tunnel_delete_net(itn, &ipgre_link_ops);
-}
-
-static struct pernet_operations ipgre_net_ops = {
- .init = ipgre_init_net,
- .exit = ipgre_exit_net,
- .id = &ipgre_net_id,
- .size = sizeof(struct ip_tunnel_net),
-};
-
#ifdef HAVE_EXT_ACK_IN_RTNL_LINKOPS
static int ipgre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
#endif
};
-static void ipgre_tunnel_setup(struct net_device *dev)
-{
- dev->netdev_ops = &ipgre_netdev_ops;
- dev->type = ARPHRD_IPGRE;
- ip_tunnel_setup(dev, ipgre_net_id);
-}
-
static void ipgre_tap_setup(struct net_device *dev)
{
ether_setup(dev);
[IFLA_GRE_ERSPAN_HWID] = { .type = NLA_U16 },
};
-static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
- .kind = "gre",
- .maxtype = RPL_IFLA_GRE_MAX,
- .policy = ipgre_policy,
- .priv_size = sizeof(struct ip_tunnel),
- .setup = ipgre_tunnel_setup,
- .validate = ipgre_tunnel_validate,
- .newlink = ipgre_newlink,
- .dellink = ip_tunnel_dellink,
- .get_size = ipgre_get_size,
- .fill_info = ipgre_fill_info,
-#ifdef HAVE_GET_LINK_NET
- .get_link_net = ip_tunnel_get_link_net,
-#endif
-};
-
static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
.kind = "ovs_gretap",
.maxtype = RPL_IFLA_GRE_MAX,
goto pnet_erspan_failed;
}
- err = register_pernet_device(&ipgre_net_ops);
- if (err < 0) {
- if (err == -EEXIST)
- goto ip_gre_loaded;
- else
- goto pnet_ipgre_failed;
- }
-
err = gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO);
if (err < 0) {
pr_info("%s: can't add protocol\n", __func__);
return 0;
add_proto_failed:
- unregister_pernet_device(&ipgre_net_ops);
-pnet_ipgre_failed:
unregister_pernet_device(&erspan_net_ops);
pnet_erspan_failed:
unregister_pernet_device(&ipgre_tap_net_ops);
if (!ip_gre_loaded) {
gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO);
- unregister_pernet_device(&ipgre_net_ops);
unregister_pernet_device(&erspan_net_ops);
unregister_pernet_device(&ipgre_tap_net_ops);
}