Skip to content

Commit 36ed85f

Browse files
author
Herton R. Krzesinski
committed
Merge: ip_gre: do not report erspan version on GRE interface
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1806 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2150168 Upstream Status: net.git commit ee49669 commit ee49669 Author: Hangbin Liu <liuhangbin@gmail.com> Date: Sat Dec 3 11:28:58 2022 +0800 ip_gre: do not report erspan version on GRE interface Although the type I ERSPAN is based on the barebones IP + GRE encapsulation and no extra ERSPAN header. Report erspan version on GRE interface looks unreasonable. Fix this by separating the erspan and gre fill info. IPv6 GRE does not have this info as IPv6 only supports erspan version 1 and 2. Reported-by: Jianlin Shi <jishi@redhat.com> Fixes: f989d54 ("erspan: Add type I version 0 support.") Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Acked-by: William Tu <u9012063@gmail.com> Link: https://lore.kernel.org/r/20221203032858.3130339-1-liuhangbin@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Hangbin Liu <haliu@redhat.com> Approved-by: Antoine Tenart <atenart@redhat.com> Approved-by: John B. Wyatt IV <jwyatt@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 5cd23cf + 740af19 commit 36ed85f

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

net/ipv4/ip_gre.c

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,24 +1498,6 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
14981498
struct ip_tunnel_parm *p = &t->parms;
14991499
__be16 o_flags = p->o_flags;
15001500

1501-
if (t->erspan_ver <= 2) {
1502-
if (t->erspan_ver != 0 && !t->collect_md)
1503-
o_flags |= TUNNEL_KEY;
1504-
1505-
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, t->erspan_ver))
1506-
goto nla_put_failure;
1507-
1508-
if (t->erspan_ver == 1) {
1509-
if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, t->index))
1510-
goto nla_put_failure;
1511-
} else if (t->erspan_ver == 2) {
1512-
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, t->dir))
1513-
goto nla_put_failure;
1514-
if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, t->hwid))
1515-
goto nla_put_failure;
1516-
}
1517-
}
1518-
15191501
if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) ||
15201502
nla_put_be16(skb, IFLA_GRE_IFLAGS,
15211503
gre_tnl_flags_to_gre_flags(p->i_flags)) ||
@@ -1556,6 +1538,34 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
15561538
return -EMSGSIZE;
15571539
}
15581540

1541+
static int erspan_fill_info(struct sk_buff *skb, const struct net_device *dev)
1542+
{
1543+
struct ip_tunnel *t = netdev_priv(dev);
1544+
1545+
if (t->erspan_ver <= 2) {
1546+
if (t->erspan_ver != 0 && !t->collect_md)
1547+
t->parms.o_flags |= TUNNEL_KEY;
1548+
1549+
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, t->erspan_ver))
1550+
goto nla_put_failure;
1551+
1552+
if (t->erspan_ver == 1) {
1553+
if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, t->index))
1554+
goto nla_put_failure;
1555+
} else if (t->erspan_ver == 2) {
1556+
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, t->dir))
1557+
goto nla_put_failure;
1558+
if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, t->hwid))
1559+
goto nla_put_failure;
1560+
}
1561+
}
1562+
1563+
return ipgre_fill_info(skb, dev);
1564+
1565+
nla_put_failure:
1566+
return -EMSGSIZE;
1567+
}
1568+
15591569
static void erspan_setup(struct net_device *dev)
15601570
{
15611571
struct ip_tunnel *t = netdev_priv(dev);
@@ -1634,7 +1644,7 @@ static struct rtnl_link_ops erspan_link_ops __read_mostly = {
16341644
.changelink = erspan_changelink,
16351645
.dellink = ip_tunnel_dellink,
16361646
.get_size = ipgre_get_size,
1637-
.fill_info = ipgre_fill_info,
1647+
.fill_info = erspan_fill_info,
16381648
.get_link_net = ip_tunnel_get_link_net,
16391649
};
16401650

0 commit comments

Comments
 (0)