Skip to content

Commit 31088cb

Browse files
committed
Merge branch 'report-erspan-version-field-just-for-erspan-tunnels'
Lorenzo Bianconi says: ==================== report erspan version field just for erspan tunnels Do not report erspan_version to userpsace for non erspan tunnels. Report IFLA_GRE_ERSPAN_INDEX only for erspan version 1 in ip6gre_fill_info ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 9e8db59 + 103d024 commit 31088cb

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

net/ipv4/ip_gre.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,9 +1457,23 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
14571457
struct ip_tunnel_parm *p = &t->parms;
14581458
__be16 o_flags = p->o_flags;
14591459

1460-
if ((t->erspan_ver == 1 || t->erspan_ver == 2) &&
1461-
!t->collect_md)
1462-
o_flags |= TUNNEL_KEY;
1460+
if (t->erspan_ver == 1 || t->erspan_ver == 2) {
1461+
if (!t->collect_md)
1462+
o_flags |= TUNNEL_KEY;
1463+
1464+
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, t->erspan_ver))
1465+
goto nla_put_failure;
1466+
1467+
if (t->erspan_ver == 1) {
1468+
if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, t->index))
1469+
goto nla_put_failure;
1470+
} else {
1471+
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, t->dir))
1472+
goto nla_put_failure;
1473+
if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, t->hwid))
1474+
goto nla_put_failure;
1475+
}
1476+
}
14631477

14641478
if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) ||
14651479
nla_put_be16(skb, IFLA_GRE_IFLAGS,
@@ -1495,19 +1509,6 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
14951509
goto nla_put_failure;
14961510
}
14971511

1498-
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, t->erspan_ver))
1499-
goto nla_put_failure;
1500-
1501-
if (t->erspan_ver == 1) {
1502-
if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, t->index))
1503-
goto nla_put_failure;
1504-
} else if (t->erspan_ver == 2) {
1505-
if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, t->dir))
1506-
goto nla_put_failure;
1507-
if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, t->hwid))
1508-
goto nla_put_failure;
1509-
}
1510-
15111512
return 0;
15121513

15131514
nla_put_failure:

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)