Skip to content

Commit e189c87

Browse files
ffmancerajfvogel
authored andcommitted
ipv6: fix omitted netlink attributes when using RTEXT_FILTER_SKIP_STATS
[ Upstream commit 7ac6ea4a3e0898db76aecccd68fb2c403eb7d24e ] Using RTEXT_FILTER_SKIP_STATS is incorrectly skipping non-stats IPv6 netlink attributes on link dump. This causes issues on userspace tools, e.g iproute2 is not rendering address generation mode as it should due to missing netlink attribute. Move the filling of IFLA_INET6_STATS and IFLA_INET6_ICMP6STATS to a helper function guarded by a flag check to avoid hitting the same situation in the future. Fixes: d5566fd ("rtnetlink: RTEXT_FILTER_SKIP_STATS support to avoid dumping inet/inet6 stats") Signed-off-by: Fernando Fernandez Mancera <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit de579015d132e742af32611900b038ffbe5a0850) Signed-off-by: Jack Vogel <[email protected]>
1 parent 2dac393 commit e189c87

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

net/ipv6/addrconf.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5807,6 +5807,27 @@ static void snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int attrtype,
58075807
}
58085808
}
58095809

5810+
static int inet6_fill_ifla6_stats_attrs(struct sk_buff *skb,
5811+
struct inet6_dev *idev)
5812+
{
5813+
struct nlattr *nla;
5814+
5815+
nla = nla_reserve(skb, IFLA_INET6_STATS, IPSTATS_MIB_MAX * sizeof(u64));
5816+
if (!nla)
5817+
goto nla_put_failure;
5818+
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_STATS, nla_len(nla));
5819+
5820+
nla = nla_reserve(skb, IFLA_INET6_ICMP6STATS, ICMP6_MIB_MAX * sizeof(u64));
5821+
if (!nla)
5822+
goto nla_put_failure;
5823+
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_ICMP6STATS, nla_len(nla));
5824+
5825+
return 0;
5826+
5827+
nla_put_failure:
5828+
return -EMSGSIZE;
5829+
}
5830+
58105831
static int inet6_fill_ifla6_attrs(struct sk_buff *skb, struct inet6_dev *idev,
58115832
u32 ext_filter_mask)
58125833
{
@@ -5829,18 +5850,10 @@ static int inet6_fill_ifla6_attrs(struct sk_buff *skb, struct inet6_dev *idev,
58295850

58305851
/* XXX - MC not implemented */
58315852

5832-
if (ext_filter_mask & RTEXT_FILTER_SKIP_STATS)
5833-
return 0;
5834-
5835-
nla = nla_reserve(skb, IFLA_INET6_STATS, IPSTATS_MIB_MAX * sizeof(u64));
5836-
if (!nla)
5837-
goto nla_put_failure;
5838-
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_STATS, nla_len(nla));
5839-
5840-
nla = nla_reserve(skb, IFLA_INET6_ICMP6STATS, ICMP6_MIB_MAX * sizeof(u64));
5841-
if (!nla)
5842-
goto nla_put_failure;
5843-
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_ICMP6STATS, nla_len(nla));
5853+
if (!(ext_filter_mask & RTEXT_FILTER_SKIP_STATS)) {
5854+
if (inet6_fill_ifla6_stats_attrs(skb, idev) < 0)
5855+
goto nla_put_failure;
5856+
}
58445857

58455858
nla = nla_reserve(skb, IFLA_INET6_TOKEN, sizeof(struct in6_addr));
58465859
if (!nla)

0 commit comments

Comments
 (0)