Skip to content

Commit 7ac6ea4

Browse files
ffmancerakuba-moo
authored andcommitted
ipv6: fix omitted netlink attributes when using RTEXT_FILTER_SKIP_STATS
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 <ffmancera@riseup.net> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250402121751.3108-1-ffmancera@riseup.net Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent e4546c6 commit 7ac6ea4

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
@@ -5784,6 +5784,27 @@ static void snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int attrtype,
57845784
}
57855785
}
57865786

5787+
static int inet6_fill_ifla6_stats_attrs(struct sk_buff *skb,
5788+
struct inet6_dev *idev)
5789+
{
5790+
struct nlattr *nla;
5791+
5792+
nla = nla_reserve(skb, IFLA_INET6_STATS, IPSTATS_MIB_MAX * sizeof(u64));
5793+
if (!nla)
5794+
goto nla_put_failure;
5795+
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_STATS, nla_len(nla));
5796+
5797+
nla = nla_reserve(skb, IFLA_INET6_ICMP6STATS, ICMP6_MIB_MAX * sizeof(u64));
5798+
if (!nla)
5799+
goto nla_put_failure;
5800+
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_ICMP6STATS, nla_len(nla));
5801+
5802+
return 0;
5803+
5804+
nla_put_failure:
5805+
return -EMSGSIZE;
5806+
}
5807+
57875808
static int inet6_fill_ifla6_attrs(struct sk_buff *skb, struct inet6_dev *idev,
57885809
u32 ext_filter_mask)
57895810
{
@@ -5806,18 +5827,10 @@ static int inet6_fill_ifla6_attrs(struct sk_buff *skb, struct inet6_dev *idev,
58065827

58075828
/* XXX - MC not implemented */
58085829

5809-
if (ext_filter_mask & RTEXT_FILTER_SKIP_STATS)
5810-
return 0;
5811-
5812-
nla = nla_reserve(skb, IFLA_INET6_STATS, IPSTATS_MIB_MAX * sizeof(u64));
5813-
if (!nla)
5814-
goto nla_put_failure;
5815-
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_STATS, nla_len(nla));
5816-
5817-
nla = nla_reserve(skb, IFLA_INET6_ICMP6STATS, ICMP6_MIB_MAX * sizeof(u64));
5818-
if (!nla)
5819-
goto nla_put_failure;
5820-
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_ICMP6STATS, nla_len(nla));
5830+
if (!(ext_filter_mask & RTEXT_FILTER_SKIP_STATS)) {
5831+
if (inet6_fill_ifla6_stats_attrs(skb, idev) < 0)
5832+
goto nla_put_failure;
5833+
}
58215834

58225835
nla = nla_reserve(skb, IFLA_INET6_TOKEN, sizeof(struct in6_addr));
58235836
if (!nla)

0 commit comments

Comments
 (0)