Message ID | 1541543066-4355-1-git-send-email-gvrose8192@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev,1/2] gre: Remove dead ipgre code | expand |
On Tue, Nov 6, 2018 at 2:24 PM Greg Rose <gvrose8192@gmail.com> wrote: > > Open vSwitch uses gretap, not ipgre for gre tunneling. Remove dead > code for ipgre type tunnels. > > Signed-off-by: Greg Rose <gvrose8192@gmail.com> > --- LGTM. Acked-by: William Tu <u9012063@gmail.com> > datapath/linux/compat/ip_gre.c | 65 ++---------------------------------------- > 1 file changed, 2 insertions(+), 63 deletions(-) > > diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c > index 6ac2dd9..0faf8ab 100644 > --- a/datapath/linux/compat/ip_gre.c > +++ b/datapath/linux/compat/ip_gre.c > @@ -64,13 +64,11 @@ > #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 > @@ -316,16 +314,10 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi, > 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; > } > > @@ -727,25 +719,6 @@ static const struct gre_protocol ipgre_protocol = { > .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) > @@ -1205,13 +1178,6 @@ static const struct net_device_ops erspan_netdev_ops = { > #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); > @@ -1352,22 +1318,6 @@ static const struct nla_policy ipgre_policy[RPL_IFLA_GRE_MAX + 1] = { > [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, > @@ -1655,14 +1605,6 @@ int rpl_ipgre_init(void) > 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__); > @@ -1696,8 +1638,6 @@ ip_gre_loaded: > 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); > @@ -1713,7 +1653,6 @@ void rpl_ipgre_fini(void) > > 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); > } > -- > 1.8.3.1 >
diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c index 6ac2dd9..0faf8ab 100644 --- a/datapath/linux/compat/ip_gre.c +++ b/datapath/linux/compat/ip_gre.c @@ -64,13 +64,11 @@ #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 @@ -316,16 +314,10 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi, 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; } @@ -727,25 +719,6 @@ static const struct gre_protocol ipgre_protocol = { .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) @@ -1205,13 +1178,6 @@ static const struct net_device_ops erspan_netdev_ops = { #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); @@ -1352,22 +1318,6 @@ static const struct nla_policy ipgre_policy[RPL_IFLA_GRE_MAX + 1] = { [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, @@ -1655,14 +1605,6 @@ int rpl_ipgre_init(void) 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__); @@ -1696,8 +1638,6 @@ ip_gre_loaded: 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); @@ -1713,7 +1653,6 @@ void rpl_ipgre_fini(void) 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); }
Open vSwitch uses gretap, not ipgre for gre tunneling. Remove dead code for ipgre type tunnels. Signed-off-by: Greg Rose <gvrose8192@gmail.com> --- datapath/linux/compat/ip_gre.c | 65 ++---------------------------------------- 1 file changed, 2 insertions(+), 63 deletions(-)