Skip to content

Commit

Permalink
ipv6: fix omitted netlink attributes when using RTEXT_FILTER_SKIP_STATS
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Fernando Fernandez Mancera authored and Jakub Kicinski committed Apr 3, 2025
1 parent e4546c6 commit 7ac6ea4
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5784,6 +5784,27 @@ static void snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int attrtype,
}
}

static int inet6_fill_ifla6_stats_attrs(struct sk_buff *skb,
struct inet6_dev *idev)
{
struct nlattr *nla;

nla = nla_reserve(skb, IFLA_INET6_STATS, IPSTATS_MIB_MAX * sizeof(u64));
if (!nla)
goto nla_put_failure;
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_STATS, nla_len(nla));

nla = nla_reserve(skb, IFLA_INET6_ICMP6STATS, ICMP6_MIB_MAX * sizeof(u64));
if (!nla)
goto nla_put_failure;
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_ICMP6STATS, nla_len(nla));

return 0;

nla_put_failure:
return -EMSGSIZE;
}

static int inet6_fill_ifla6_attrs(struct sk_buff *skb, struct inet6_dev *idev,
u32 ext_filter_mask)
{
Expand All @@ -5806,18 +5827,10 @@ static int inet6_fill_ifla6_attrs(struct sk_buff *skb, struct inet6_dev *idev,

/* XXX - MC not implemented */

if (ext_filter_mask & RTEXT_FILTER_SKIP_STATS)
return 0;

nla = nla_reserve(skb, IFLA_INET6_STATS, IPSTATS_MIB_MAX * sizeof(u64));
if (!nla)
goto nla_put_failure;
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_STATS, nla_len(nla));

nla = nla_reserve(skb, IFLA_INET6_ICMP6STATS, ICMP6_MIB_MAX * sizeof(u64));
if (!nla)
goto nla_put_failure;
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_ICMP6STATS, nla_len(nla));
if (!(ext_filter_mask & RTEXT_FILTER_SKIP_STATS)) {
if (inet6_fill_ifla6_stats_attrs(skb, idev) < 0)
goto nla_put_failure;
}

nla = nla_reserve(skb, IFLA_INET6_TOKEN, sizeof(struct in6_addr));
if (!nla)
Expand Down

0 comments on commit 7ac6ea4

Please sign in to comment.