From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Khorenko Date: Wed, 12 Aug 2026 15:03:57 +0200 Subject: [Devel] [PATCH DRAFT vz10 1/5] Revert "ve/net/gre: Disable ERSPAN support in ip_gre module" In-Reply-To: <20260812130401.154702-1-khorenko@virtuozzo.com> References: <20260812130401.154702-1-khorenko@virtuozzo.com> Message-ID: <20260812130401.154702-2-khorenko@virtuozzo.com> List-Id: This reverts commit a6adc8063402a38c6d951113453df6bf8ddcfb0e. ERSPAN was disabled under CONFIG_VE because at the time it was not wired into the per-Container GRE infrastructure: erspan devices did not set NETIF_F_VIRTUAL, so register_netdevice() would reject them inside a CT, and erspan_net_ops was not gated by any VE feature bit. Rather than carry the feature permanently disabled, bring the code back so that the following commit can properly containerize ERSPAN under a dedicated VE feature bit. https://virtuozzo.atlassian.net/browse/VSTOR-141173 Feature: net: disable ERSPAN support in ip_gre module Signed-off-by: Konstantin Khorenko --- net/ipv4/ip_gre.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index f618aae250334..d776eb8d9f76c 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -1134,7 +1134,6 @@ static int ipgre_tap_validate(struct nlattr *tb[], struct nlattr *data[], return ipgre_tunnel_validate(tb, data, extack); } -#ifndef CONFIG_VE static int erspan_validate(struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) { @@ -1174,7 +1173,6 @@ static int erspan_validate(struct nlattr *tb[], struct nlattr *data[], return 0; } -#endif static int ipgre_netlink_parms(struct net_device *dev, struct nlattr *data[], @@ -1245,7 +1243,6 @@ static int ipgre_netlink_parms(struct net_device *dev, return 0; } -#ifndef CONFIG_VE static int erspan_netlink_parms(struct net_device *dev, struct nlattr *data[], struct nlattr *tb[], @@ -1289,7 +1286,6 @@ static int erspan_netlink_parms(struct net_device *dev, return 0; } -#endif /* This function returns true when ENCAP attributes are present in the nl msg */ static bool ipgre_netlink_encap_parms(struct nlattr *data[], @@ -1428,7 +1424,6 @@ static int ipgre_newlink(struct net *src_net, struct net_device *dev, return ip_tunnel_newlink(dev, tb, &p, fwmark); } -#ifndef CONFIG_VE static int erspan_newlink(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) @@ -1446,7 +1441,6 @@ static int erspan_newlink(struct net *src_net, struct net_device *dev, return err; return ip_tunnel_newlink(dev, tb, &p, fwmark); } -#endif static int ipgre_changelink(struct net_device *dev, struct nlattr *tb[], struct nlattr *data[], @@ -1477,7 +1471,6 @@ static int ipgre_changelink(struct net_device *dev, struct nlattr *tb[], return 0; } -#ifndef CONFIG_VE static int erspan_changelink(struct net_device *dev, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) @@ -1504,7 +1497,6 @@ static int erspan_changelink(struct net_device *dev, struct nlattr *tb[], return 0; } -#endif static size_t ipgre_get_size(const struct net_device *dev) { @@ -1602,7 +1594,6 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev) return -EMSGSIZE; } -#ifndef CONFIG_VE static int erspan_fill_info(struct sk_buff *skb, const struct net_device *dev) { struct ip_tunnel *t = netdev_priv(dev); @@ -1643,7 +1634,6 @@ static void erspan_setup(struct net_device *dev) ip_tunnel_setup(dev, erspan_net_id); t->erspan_ver = 1; } -#endif static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = { [IFLA_GRE_LINK] = { .type = NLA_U32 }, @@ -1699,7 +1689,6 @@ static struct rtnl_link_ops ipgre_tap_ops __read_mostly = { .get_link_net = ip_tunnel_get_link_net, }; -#ifndef CONFIG_VE static struct rtnl_link_ops erspan_link_ops __read_mostly = { .kind = "erspan", .maxtype = IFLA_GRE_MAX, @@ -1714,7 +1703,6 @@ static struct rtnl_link_ops erspan_link_ops __read_mostly = { .fill_info = erspan_fill_info, .get_link_net = ip_tunnel_get_link_net, }; -#endif struct net_device *gretap_fb_dev_create(struct net *net, const char *name, u8 name_assign_type) @@ -1786,7 +1774,6 @@ static struct pernet_operations ipgre_tap_net_ops = { .size = sizeof(struct ip_tunnel_net), }; -#ifndef CONFIG_VE static int __net_init erspan_init_net(struct net *net) { return ip_tunnel_init_net(net, erspan_net_id, @@ -1806,7 +1793,6 @@ static struct pernet_operations erspan_net_ops = { .id = &erspan_net_id, .size = sizeof(struct ip_tunnel_net), }; -#endif static int __init ipgre_init(void) { @@ -1821,11 +1807,11 @@ static int __init ipgre_init(void) err = register_pernet_device(&ipgre_tap_net_ops); if (err < 0) goto pnet_tap_failed; -#ifndef CONFIG_VE + err = register_pernet_device(&erspan_net_ops); if (err < 0) goto pnet_erspan_failed; -#endif + err = gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO); if (err < 0) { pr_info("%s: can't add protocol\n", __func__); @@ -1839,27 +1825,22 @@ static int __init ipgre_init(void) err = rtnl_link_register(&ipgre_tap_ops); if (err < 0) goto tap_ops_failed; -#ifndef CONFIG_VE + err = rtnl_link_register(&erspan_link_ops); if (err < 0) goto erspan_link_failed; -#endif return 0; -#ifndef CONFIG_VE erspan_link_failed: -#endif rtnl_link_unregister(&ipgre_tap_ops); tap_ops_failed: rtnl_link_unregister(&ipgre_link_ops); rtnl_link_failed: gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO); add_proto_failed: -#ifndef CONFIG_VE unregister_pernet_device(&erspan_net_ops); pnet_erspan_failed: -#endif unregister_pernet_device(&ipgre_tap_net_ops); pnet_tap_failed: unregister_pernet_device(&ipgre_net_ops); @@ -1870,15 +1851,11 @@ static void __exit ipgre_fini(void) { rtnl_link_unregister(&ipgre_tap_ops); rtnl_link_unregister(&ipgre_link_ops); -#ifndef CONFIG_VE rtnl_link_unregister(&erspan_link_ops); -#endif gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO); unregister_pernet_device(&ipgre_tap_net_ops); unregister_pernet_device(&ipgre_net_ops); -#ifndef CONFIG_VE unregister_pernet_device(&erspan_net_ops); -#endif } module_init(ipgre_init); @@ -1887,9 +1864,7 @@ MODULE_DESCRIPTION("IPv4 GRE tunnels over IP library"); MODULE_LICENSE("GPL"); MODULE_ALIAS_RTNL_LINK("gre"); MODULE_ALIAS_RTNL_LINK("gretap"); -#ifndef CONFIG_VE MODULE_ALIAS_RTNL_LINK("erspan"); -MODULE_ALIAS_NETDEV("erspan0"); -#endif MODULE_ALIAS_NETDEV("gre0"); MODULE_ALIAS_NETDEV("gretap0"); +MODULE_ALIAS_NETDEV("erspan0"); -- 2.43.0