Subject: Re: [PATCH net-next 4/5] selftests: forwarding: extend ethtool_std_stats_get with pause statistics

From: Petr Machata <[email-masked]>
Date: Tue, 3 Mar 2026 14:06:29 +0100

Ioana Ciornei <[email-masked]> writes:

> On Fri, Feb 27, 2026 at 05:38:40PM +0100, Petr Machata wrote:
>> 
>> Ioana Ciornei <[email-masked]> writes:
>> 
>> > Even though pause frame statistics are not exported through the same
>> > ethtool command, there is no point in adding another helper just for
>> > them. Extent the ethtool_std_stats_get() function so that we are able to
>> > interrogate using the same helper all the standard statistics.
>> >
>> > Signed-off-by: Ioana Ciornei <[email-masked]>
>> > ---
>> >  tools/testing/selftests/net/forwarding/lib.sh | 8 ++++++--
>> >  1 file changed, 6 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
>> > index a9034f0bb58b..efd236ae1c28 100644
>> > --- a/tools/testing/selftests/net/forwarding/lib.sh
>> > +++ b/tools/testing/selftests/net/forwarding/lib.sh
>> > @@ -831,8 +831,12 @@ ethtool_std_stats_get()
>> >  	local name=$1; shift
>> >  	local src=$1; shift
>> >  
>> > -	ethtool --json -S $dev --groups $grp -- --src $src | \
>> > -		jq '.[]."'"$grp"'"."'$name'"'
>> > +	if [[ "$grp" == "pause" ]]; then
>> > +		ethtool -I --json -a $dev | jq '.[].statistics.'$name
>> 
>> I think name needs to be quoted here? In fact, unless the pause group is
>> highly unlikely to ever get a key that contains a dash,
>
> I would expect that the pause group is pretty much set and will not get
> new counters but, sure, I can add the quotes just to be on the safe
> side.

Oh, don't get me wrong, I don't believe $name will contain whitespace.
But I would expect shellcheck to complain about the missing quotes.

>> it should either
>> be quoted in the horrible way the else branch does it, or do this much
>> more readable thing instead:
>> 
>>         jq --arg name "$name" '.[].statistics[$name]'
>> 
>
> Thanks! Wasn't aware of this type of jq variable usage but indeed it
> looks better.
>
>> > +	else
>> > +		ethtool --json -S $dev --groups $grp -- --src $src | \
>> 
>> Since you are touching this line -- can you fix the missing quoting,
>> please?
>
> Sure, I will add them.
>
>> 
>> > +			jq '.[]."'"$grp"'"."'$name'"'
>
> And I think $name above needs double quoting as well.

Oh yeah. That's just going to be an absolute confusion of quotes though.
Can you convert to the --arg form as well? I think it should be:

			jq --arg grp "$grp" --arg name "$name" \
				'.[][$grp][$name]'