From: Alexander Zubkov <green@qrator.net>
To: netdev@vger.kernel.org, Stephen Hemminger <stephen@networkplumber.org>
Cc: Petr Machata <me@pmachata.org>, Ido Schimmel <idosch@nvidia.com>,
Alexander Zubkov <green@qrator.net>
Subject: [PATCH iproute2 0/2] ip: ipstats: Fix statistics split across netlink messages
Date: Sun, 30 Aug 2026 20:19:47 +0200 [thread overview]
Message-ID: <20260830181949.1096-1-green@qrator.net> (raw)
When dumping statistics, the kernel may split the statistics of a single
interface across several netlink messages: if an attribute does not fit
into the current skb, rtnl_fill_statsinfo() keeps the partial message and
the dump is resumed at the same ifindex. "ip stats" formats every message
on its own, so such an interface is reported twice and part of its
statistics is lost. With "group offload subgroup l3_stats", which requests
two attributes that the kernel emits one by one, this is easy to hit on a
box with many netdevices:
109: vlan859: group offload subgroup l3_stats on used on
109: vlan859: group offload subgroup l3_stats
The first record holds IFLA_OFFLOAD_XSTATS_HW_S_INFO, the second one
holds IFLA_OFFLOAD_XSTATS_L3_STATS, and the counters are never shown.
Patch 1 reassembles such messages before formatting them. Patch 2 is an
unrelated hardening cleanup and can be dropped.
The merge itself was also exercised out of tree against the two message
shapes the kernel can split, offload xstats cut between HW_S_INFO and
L3_STATS, and bridge per-VLAN xstats cut between two BRIDGE_XSTATS_VLAN
entries, plus a layout that must be refused rather than merged.
I faced the issue on kernel 7.1.5 / iproute2-7.0.0, mlxsw switch, with
~120 netdevices. The split was visible in an strace as two RTM_NEWSTATS
messages with the same ifindex, carrying IFLA_OFFLOAD_XSTATS_HW_S_INFO
and IFLA_OFFLOAD_XSTATS_L3_STATS respectively. The further research,
patches and supporting texts was prepared with the help of an AI
assistant. I reviewed and tested the patches against iproute2-7.1.0, with
the proposed patches the interface is correctly reported once, with its
counters. Although the patches makes sense to me, I have little
experience with netlink handling.
Alexander Zubkov (2):
ip: ipstats: Merge statistics split across several netlink messages
ip: ipstats: Do not hide HW statistics when hw_stats_info is missing
ip/ipstats.c | 285 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 280 insertions(+), 5 deletions(-)
--
2.55.0
next reply other threads:[~2026-08-30 18:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 18:19 Alexander Zubkov [this message]
2026-08-30 18:19 ` [PATCH 1/2] ip: ipstats: Merge statistics split across several netlink messages Alexander Zubkov
2026-09-01 4:48 ` Stephen Hemminger
2026-09-01 15:10 ` Petr Machata
2026-09-02 19:20 ` Alexander Zubkov
2026-09-08 18:32 ` Alexander Zubkov
2026-08-30 18:19 ` [PATCH 2/2] ip: ipstats: Do not hide HW statistics when hw_stats_info is missing Alexander Zubkov
2026-09-01 15:22 ` Petr Machata
2026-09-01 4:49 ` [PATCH iproute2 0/2] ip: ipstats: Fix statistics split across netlink messages Stephen Hemminger
2026-09-08 18:12 ` [PATCH iproute2 v2 " Alexander Zubkov
2026-09-08 18:31 ` Stephen Hemminger
2026-09-10 9:20 ` Alexander Zubkov
2026-09-08 18:12 ` [PATCH iproute2 v2 1/2] ip: ipstats: Merge statistics split across several " Alexander Zubkov
2026-09-08 18:12 ` [PATCH iproute2 v2 2/2] ip: ipstats: Do not hide HW statistics when hw_stats_info is missing Alexander Zubkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260830181949.1096-1-green@qrator.net \
--to=green@qrator.net \
--cc=idosch@nvidia.com \
--cc=me@pmachata.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.