* [PATCH net-next v6 0/2] selftests: net: veth: propagate check failures to exit status
@ 2026-11-24 21:16 Omokefe Emmanuel Onanaroghene
2026-11-24 21:16 ` [PATCH net-next v6] selftests: net: veth: derive invalid-tx test value from kernel max Omokefe Emmanuel Onanaroghene
2026-11-24 21:16 ` [PATCH net-next v6 2/2] selftests: net: veth: propagate check failures to exit status Omokefe Emmanuel Onanaroghene
0 siblings, 2 replies; 4+ messages in thread
From: Omokefe Emmanuel Onanaroghene @ 2026-11-24 21:16 UTC (permalink / raw)
To: tianyi, hangbin.liu
Cc: kuba, netdev, linux-kselftest, linux-kernel, bpf, davem,
edumazet, pabeni, horms, shuah, ast, daniel, hawk,
john.fastabend, sdf, skhan, kernel-team, tianyi.gao,
Omokefe Emmanuel Onanaroghene
Four checks in tools/testing/selftests/net/veth.sh report failures
without setting ret, allowing the script to exit 0 even when a check
fails. Set ret=1 in chk_channels() and the three "bad setting"
negative tests identified by Tianyi during review of v2.
Patch 1 fixes the invalid TX channel test, which used nproc + 1
to determine an out-of-range value. However, nproc can be lower
than num_possible_cpus() when CPU affinity or cpusets restrict
a process, meaning the kernel may accept the requested queue count.
This could cause false failures on a correctly functioning
kernel once the propagation patch makes failures honest.
Use the kernel-reported max_tx + 1 instead, ensuring the
attempted value always exceeds the device's supported maximum.
Spotted by Sashiko AI review of v2.
---
v6:
- Squash the two propagation patches into one and add
Tianyi's tags.
v5: https://lore.kernel.org/all/20261121182217.4609-1-emmaonana18@gmail.com/
- Retarget to net-next and drop the Fixes tags
- Move the invalid-tx fix first, so no commit in the series can
report a false failure on a correct kernel.
- Fix the subject prefix on the invalid-tx patch, lost in v4's
send.
v4: https://lore.kernel.org/all/20261119003003.40482-1-emmaonana18@gmail.com/
- Patch 2: use if/else instead of "&& { ...; } ||" chains, keep
lines within 80 columns (thanks Tianyi for the review).
- Add patch 3 deriving the invalid tx value from the kernel maximum.
v3: https://lore.kernel.org/all/20261116084107.6675-1-emmaonana18@gmail.com/
- Add Tianyi Gao's Tested-by to patch 1 (thanks!).
- Add patch 2 fixing the remaining three checks.
v2: https://lore.kernel.org/all/20261115214702.50817-1-emmaonana18@gmail.com/
- Correct Fixes tag to 1ec2230fc721.
v1: https://lore.kernel.org/all/20261115212117.48496-1-emmaonana18@gmail.com/
- Initial posting.
Omokefe Emmanuel Onanaroghene (2):
selftests: net: veth: derive invalid-tx test value from kernel max
selftests: net: veth: propagate check failures to exit status
tools/testing/selftests/net/veth.sh | 31 +++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v6] selftests: net: veth: derive invalid-tx test value from kernel max
2026-11-24 21:16 [PATCH net-next v6 0/2] selftests: net: veth: propagate check failures to exit status Omokefe Emmanuel Onanaroghene
@ 2026-11-24 21:16 ` Omokefe Emmanuel Onanaroghene
2026-11-26 9:19 ` netdev-bot+sashiko
2026-11-24 21:16 ` [PATCH net-next v6 2/2] selftests: net: veth: propagate check failures to exit status Omokefe Emmanuel Onanaroghene
1 sibling, 1 reply; 4+ messages in thread
From: Omokefe Emmanuel Onanaroghene @ 2026-11-24 21:16 UTC (permalink / raw)
To: tianyi, hangbin.liu
Cc: kuba, netdev, linux-kselftest, linux-kernel, bpf, davem,
edumazet, pabeni, horms, shuah, ast, daniel, hawk,
john.fastabend, sdf, skhan, kernel-team, tianyi.gao,
Omokefe Emmanuel Onanaroghene
The "setting invalid channels nr" check treats CPUS+1 (CPUS=nproc)
as an invalid tx count, but the kernel allows up to max_tx, for veth
that is num_possible_cpus(). On hosts where nproc < num_possible_cpus
(taskset/cpuset confinement, QEMU maxcpus slots, hotplug firmware),
the ethtool -L call succeeds and chk_channels() reports a false
failure. With failure propagation fixed, this fails the whole script.
Query the kernel-reported maximum with ethtool -l (the same parsing
idiom chk_channels() uses, first match) and attempt max+1, which is
invalid on every host.
Reviewed-by: Tianyi Gao <tianyi@cloudflare.com>
Tested-by: Tianyi Gao <tianyi@cloudflare.com>
Signed-off-by: Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>
---
tools/testing/selftests/net/veth.sh | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/veth.sh b/tools/testing/selftests/net/veth.sh
index 64c2a5a59821d..22246278e6049 100755
--- a/tools/testing/selftests/net/veth.sh
+++ b/tools/testing/selftests/net/veth.sh
@@ -463,7 +463,9 @@ fi
ip netns exec $NS_DST ethtool -L veth$DST combined 2 2>/dev/null
chk_channels "bad setting: combined channels" $DST $CUR_RX $CUR_TX
-ip netns exec $NS_DST ethtool -L veth$DST tx $((CPUS + 1)) 2>/dev/null
+MAX_TX=`ip netns exec $NS_DST ethtool -l veth$DST |\
+ grep TX: | head -n 1 | awk '{print $2}'`
+ip netns exec $NS_DST ethtool -L veth$DST tx $((MAX_TX + 1)) 2>/dev/null
chk_channels "setting invalid channels nr" $DST $CUR_RX $CUR_TX
if [ $CPUS -gt 1 ]; then
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v6 2/2] selftests: net: veth: propagate check failures to exit status
2026-11-24 21:16 [PATCH net-next v6 0/2] selftests: net: veth: propagate check failures to exit status Omokefe Emmanuel Onanaroghene
2026-11-24 21:16 ` [PATCH net-next v6] selftests: net: veth: derive invalid-tx test value from kernel max Omokefe Emmanuel Onanaroghene
@ 2026-11-24 21:16 ` Omokefe Emmanuel Onanaroghene
1 sibling, 0 replies; 4+ messages in thread
From: Omokefe Emmanuel Onanaroghene @ 2026-11-24 21:16 UTC (permalink / raw)
To: tianyi, hangbin.liu
Cc: kuba, netdev, linux-kselftest, linux-kernel, bpf, davem,
edumazet, pabeni, horms, shuah, ast, daniel, hawk,
john.fastabend, sdf, skhan, kernel-team, tianyi.gao,
Omokefe Emmanuel Onanaroghene
chk_channels() reports mismatches with a "fail" line but never sets
ret, so the script exits 0 even when channel counts are wrong. Every
other check helper in the file (__chk_flag, chk_xdp_feature, chk_gro)
sets ret=1 on failure, and all chk_channels() call sites expect the
check to pass. Set ret=1 on mismatch.
Three more checks in veth.sh print "fail - set operation successful
?!?" without setting ret: "bad setting: XDP with RX nr less than TX",
"bad setting: reducing RX nr below peer TX with XDP set", and "bad
setting: increasing peer TX nr above RX with XDP set". A kernel that
wrongly accepts any of these invalid operations would be reported yet
the script would still exit 0. Wrap each fail branch so it sets ret=1.
Reported-by: Tianyi Gao <tianyi@cloudflare.com>
Link: https://lore.kernel.org/all/CAG4wq-cd01i7YrcFPmma=BXUcwn_PK=wneKW=vyEBYzQ3Bn7QA@mail.gmail.com/
Tested-by: Tianyi Gao <tianyi@cloudflare.com>
Reviewed-by: Tianyi Gao <tianyi@cloudflare.com>
Signed-off-by: Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>
---
tools/testing/selftests/net/veth.sh | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/net/veth.sh b/tools/testing/selftests/net/veth.sh
index 22246278e6049..6eeb123aaf885 100755
--- a/tools/testing/selftests/net/veth.sh
+++ b/tools/testing/selftests/net/veth.sh
@@ -130,6 +130,7 @@ chk_channels() {
echo " ok "
else
echo " fail rx:$rx:$cur_rx tx:$tx:$cur_tx combined:n/a:$cur_combined"
+ ret=1
fi
}
@@ -473,9 +474,13 @@ if [ $CPUS -gt 1 ]; then
ip netns exec $NS_DST ethtool -L veth$DST rx 1 tx 2 2>/dev/null
ip netns exec $NS_SRC ethtool -L veth$SRC rx 1 tx 2 2>/dev/null
printf "%-60s" "bad setting: XDP with RX nr less than TX"
- ip -n $NS_DST link set dev veth$DST xdp object ${BPF_FILE} \
- section xdp 2>/dev/null &&\
- echo "fail - set operation successful ?!?" || echo " ok "
+ if ip -n $NS_DST link set dev veth$DST xdp object ${BPF_FILE} \
+ section xdp 2>/dev/null; then
+ echo "fail - set operation successful ?!?"
+ ret=1
+ else
+ echo " ok "
+ fi
# the following tests will run with multiple channels active
ip netns exec $NS_SRC ethtool -L veth$SRC rx 2
@@ -483,16 +488,24 @@ if [ $CPUS -gt 1 ]; then
ip -n $NS_DST link set dev veth$DST xdp object ${BPF_FILE} \
section xdp 2>/dev/null
printf "%-60s" "bad setting: reducing RX nr below peer TX with XDP set"
- ip netns exec $NS_DST ethtool -L veth$DST rx 1 2>/dev/null &&\
- echo "fail - set operation successful ?!?" || echo " ok "
+ if ip netns exec $NS_DST ethtool -L veth$DST rx 1 2>/dev/null; then
+ echo "fail - set operation successful ?!?"
+ ret=1
+ else
+ echo " ok "
+ fi
CUR_RX=2
CUR_TX=2
fi
if [ $CPUS -gt 2 ]; then
printf "%-60s" "bad setting: increasing peer TX nr above RX with XDP set"
- ip netns exec $NS_SRC ethtool -L veth$SRC tx 3 2>/dev/null &&\
- echo "fail - set operation successful ?!?" || echo " ok "
+ if ip netns exec $NS_SRC ethtool -L veth$SRC tx 3 2>/dev/null; then
+ echo "fail - set operation successful ?!?"
+ ret=1
+ else
+ echo " ok "
+ fi
chk_channels "setting invalid channels nr" $DST 2 2
fi
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v6] selftests: net: veth: derive invalid-tx test value from kernel max
2026-11-24 21:16 ` [PATCH net-next v6] selftests: net: veth: derive invalid-tx test value from kernel max Omokefe Emmanuel Onanaroghene
@ 2026-11-26 9:19 ` netdev-bot+sashiko
0 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-11-26 9:19 UTC (permalink / raw)
To: emmaonana18
Cc: tianyi, hangbin.liu, kuba, netdev, linux-kselftest, linux-kernel,
bpf, davem, edumazet, pabeni, horms, shuah, ast, daniel, hawk,
john.fastabend, sdf, skhan, kernel-team, tianyi.gao
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] chk_channels() in tools/testing/selftests/net/veth.sh (lines
175-196) prints " fail ..." on a mismatch but never sets `ret=1`.
- [Low] The commit message says that once "failure propagation" is fixed,
the false failure "fails the whole script".
--
selftests: net: veth: derive invalid-tx test value from kernel max
The "setting invalid channels nr" check in veth.sh used to try nproc+1
TX channels. It now reads the TX maximum the kernel reports through
ethtool -l and tries max+1. The old value can be valid on hosts where
nproc is less than num_possible_cpus().
> selftests: net: veth: derive invalid-tx test value from kernel max
>
> The "setting invalid channels nr" check treats CPUS+1 (CPUS=nproc)
> as an invalid tx count, but the kernel allows up to max_tx, for veth
[ ... ]
> the ethtool -L call succeeds and chk_channels() reports a false
> failure. With failure propagation fixed, this fails the whole script.
[Severity: Low]
Which patch provides the failure propagation fix mentioned here? In this
tree, chk_channels() only echoes on a mismatch and never sets ret=1:
tools/testing/selftests/net/veth.sh:chk_channels() {
...
if [ "$cur_rx" = "$rx" -a "$cur_tx" = "$tx" -a "$cur_combined" = "n/a" ]; then
echo " ok "
else
echo " fail rx:$rx:$cur_rx tx:$tx:$cur_tx combined:n/a:$cur_combined"
fi
}
So before this patch, the CPUS+1 false positive printed a misleading
"fail" line, but veth.sh still exited with 0.
Suppose the failure propagation change is applied or backported to
stable without this patch. Then veth.sh would fail on hosts where nproc
is less than num_possible_cpus(). veth_get_channels() reports max_tx as
dev->num_tx_queues, and ethnl_set_channels() only rejects
tx_count > max_tx.
Could the two changes go in the same series, or could this one name the
dependency? Could it also carry a Fixes tag for the commit that added
the CPUS + 1 value?
Fixes: 1ec2230fc721 ("selftests: net: veth: add tests for set_channel")
> diff --git a/tools/testing/selftests/net/veth.sh b/tools/testing/selftests/net/veth.sh
> index 9496b599d722c..bd0d19c49b7cd 100755
> --- a/tools/testing/selftests/net/veth.sh
> +++ b/tools/testing/selftests/net/veth.sh
> @@ -569,7 +569,9 @@ fi
> ip netns exec $NS_DST ethtool -L veth$DST combined 2 2>/dev/null
> chk_channels "bad setting: combined channels" $DST $CUR_RX $CUR_TX
>
> -ip netns exec $NS_DST ethtool -L veth$DST tx $((CPUS + 1)) 2>/dev/null
> +MAX_TX=`ip netns exec $NS_DST ethtool -l veth$DST |\
> + grep TX: | head -n 1 | awk '{print $2}'`
> +ip netns exec $NS_DST ethtool -L veth$DST tx $((MAX_TX + 1)) 2>/dev/null
> chk_channels "setting invalid channels nr" $DST $CUR_RX $CUR_TX
[Severity: Medium]
Can this check ever change the test result? The other checkers in
veth.sh set ret=1 on failure, for example chk_napi_ids(), and
chk_channels_carrier is called with "|| ret=1". chk_channels() does
not set ret at all.
The script ends with exit $ret. Suppose the tx_count > max_tx check in
ethnl_set_channels() or ethtool_set_channels() regressed, and
ethtool -L tx $((MAX_TX + 1)) were accepted. veth.sh would print "fail"
and still report success to kselftest.
The same applies to the other chk_channels() checks: "setting tx
channels", "setting both rx and tx channels" and "bad setting: combined
channels".
The commit message relies on failure propagation being fixed. Should
that change be part of this submission, so the updated check actually
affects the exit status?
>
> if [ $CPUS -gt 1 ]; then
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124211645.5751-2-emmaonana18%40gmail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-26 9:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 21:16 [PATCH net-next v6 0/2] selftests: net: veth: propagate check failures to exit status Omokefe Emmanuel Onanaroghene
2026-11-24 21:16 ` [PATCH net-next v6] selftests: net: veth: derive invalid-tx test value from kernel max Omokefe Emmanuel Onanaroghene
2026-11-26 9:19 ` netdev-bot+sashiko
2026-11-24 21:16 ` [PATCH net-next v6 2/2] selftests: net: veth: propagate check failures to exit status Omokefe Emmanuel Onanaroghene
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®