Skip to content

Commit 103d024

Browse files
LorenzoBianconidavem330
authored andcommitted
net: ip6_gre: do not report erspan_ver for ip6gre or ip6gretap
Report erspan version field to userspace in ip6gre_fill_info just for erspan_v6 tunnels. Moreover report IFLA_GRE_ERSPAN_INDEX only for erspan version 1. The issue can be triggered with the following reproducer: $ip link add name gre6 type ip6gre local 2001::1 remote 2002::2 $ip link set gre6 up $ip -d link sh gre6 14: grep6@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1448 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/gre6 2001::1 peer 2002::2 promiscuity 0 minmtu 0 maxmtu 0 ip6gre remote 2002::2 local 2001::1 hoplimit 64 encaplimit 4 tclass 0x00 flowlabel 0x00000 erspan_index 0 erspan_ver 0 addrgenmode eui64 Fixes: 94d7d8f ("ip6_gre: add erspan v2 support") Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2bdf700 commit 103d024

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

net/ipv6/ip6_gre.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,9 +2104,23 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev)
21042104
struct __ip6_tnl_parm *p = &t->parms;
21052105
__be16 o_flags = p->o_flags;
21062106

2107-
if ((p->erspan_ver == 1 || p->erspan_ver == 2) &&
2108-
!p->collect_md)
2109-
o_flags |= TUNNEL_KEY;
2107+
if (p->erspan_ver == 1 || p->erspan_ver == 2) {
2108+
if (!p->collect_md)
2109+
o_flags |= TUNNEL_KEY;
2110+
2111+
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, p->erspan_ver))
2112+
goto nla_put_failure;
2113+
2114+
if (p->erspan_ver == 1) {
2115+
if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, p->index))
2116+
goto nla_put_failure;
2117+
} else {
2118+
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, p->dir))
2119+
goto nla_put_failure;
2120+
if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, p->hwid))
2121+
goto nla_put_failure;
2122+
}
2123+
}
21102124

21112125
if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) ||
21122126
nla_put_be16(skb, IFLA_GRE_IFLAGS,
@@ -2121,8 +2135,7 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev)
21212135
nla_put_u8(skb, IFLA_GRE_ENCAP_LIMIT, p->encap_limit) ||
21222136
nla_put_be32(skb, IFLA_GRE_FLOWINFO, p->flowinfo) ||
21232137
nla_put_u32(skb, IFLA_GRE_FLAGS, p->flags) ||
2124-
nla_put_u32(skb, IFLA_GRE_FWMARK, p->fwmark) ||
2125-
nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, p->index))
2138+
nla_put_u32(skb, IFLA_GRE_FWMARK, p->fwmark))
21262139
goto nla_put_failure;
21272140

21282141
if (nla_put_u16(skb, IFLA_GRE_ENCAP_TYPE,
@@ -2140,19 +2153,6 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev)
21402153
goto nla_put_failure;
21412154
}
21422155

2143-
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, p->erspan_ver))
2144-
goto nla_put_failure;
2145-
2146-
if (p->erspan_ver == 1) {
2147-
if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, p->index))
2148-
goto nla_put_failure;
2149-
} else if (p->erspan_ver == 2) {
2150-
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, p->dir))
2151-
goto nla_put_failure;
2152-
if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, p->hwid))
2153-
goto nla_put_failure;
2154-
}
2155-
21562156
return 0;
21572157

21582158
nla_put_failure:

0 commit comments

Comments
 (0)