From: Petr Machata <me@pmachata.org>
To: Alexander Zubkov <green@qrator.net>
Cc: netdev@vger.kernel.org,
Stephen Hemminger <stephen@networkplumber.org>,
Ido Schimmel <idosch@nvidia.com>
Subject: Re: [PATCH 2/2] ip: ipstats: Do not hide HW statistics when hw_stats_info is missing
Date: Tue, 01 Sep 2026 17:22:42 +0200 [thread overview]
Message-ID: <87a4q10zel.fsf@pmachata.org> (raw)
In-Reply-To: <20260830181949.1096-3-green@qrator.net> (Alexander Zubkov's message of "Sun, 30 Aug 2026 20:19:49 +0200")
Alexander Zubkov <green@qrator.net> writes:
> ipstats_show_hw_stats() returns as soon as the
> IFLA_OFFLOAD_XSTATS_HW_S_INFO attribute is absent, silently dropping the
> counters that the message does carry. __ipstats_show_hw_stats() already
> copes with a NULL info attribute, so let it, and skip the record only
> when neither attribute is present.
>
> There is no known way to reach this through "ip stats": the l3_stats
> descriptor always requests HW_S_INFO next to the counters, and since the
> previous patch the two are reassembled even when the kernel splits them
> across messages. This is a hardening measure so that a message carrying
> just the counters is displayed rather than silently discarded.
>
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Alexander Zubkov <green@qrator.net>
> ---
> ip/ipstats.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/ip/ipstats.c b/ip/ipstats.c
> index c531885f..54b8267d 100644
> --- a/ip/ipstats.c
> +++ b/ip/ipstats.c
> @@ -472,13 +472,16 @@ static int ipstats_show_hw_stats(struct ipstats_stat_show_attrs *attrs,
> int err = 0;
>
> at_hwsi = ipstats_stat_show_get_attr(attrs, group, hw_s_info, &err);
> - if (at_hwsi == NULL)
> + if (at_hwsi == NULL && err != 0)
> return err;
I am pretty sure this is deliberate. The logic is, if we do not even get
hw_s_info, then surely we will not get hw_stats either, because the
kernel is supposed to provide information about the statistics together
with the statistics themselves.
Now this did not take into account that messages might be split. But
with your patch, this is will not be an issue anymore either.
On second though, it is not the task of iproute2 to policy the kernel,
and when life gives you hw_stats but no hw_s_info, you make hw_stats'ade
or whatever. So I actually think the patch is OK.
So,
Reviewed-by: Petr Machata <me@pmachata.org>
>
> at_stats = ipstats_stat_show_get_attr(attrs, group, hw_stats, &err);
> if (at_stats == NULL && err != 0)
> return err;
>
> + if (at_hwsi == NULL && at_stats == NULL)
> + return 0;
> +
> return __ipstats_show_hw_stats(at_hwsi, at_stats, idx);
> }
next prev parent reply other threads:[~2026-09-01 15:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 18:19 [PATCH iproute2 0/2] ip: ipstats: Fix statistics split across netlink messages Alexander Zubkov
2026-08-30 18:19 ` [PATCH 1/2] ip: ipstats: Merge statistics split across several " Alexander Zubkov
2026-09-01 4:48 ` Stephen Hemminger
2026-09-01 15:10 ` Petr Machata
2026-09-02 19:20 ` 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 [this message]
2026-09-01 4:49 ` [PATCH iproute2 0/2] ip: ipstats: Fix statistics split across netlink messages Stephen Hemminger
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=87a4q10zel.fsf@pmachata.org \
--to=me@pmachata.org \
--cc=green@qrator.net \
--cc=idosch@nvidia.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox