selftests: net: veth: propagate check failures to exit status
Subsystems (4)
v5 cover selftests: net: veth: propagate check failures to exit status
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 earlier patches propagated test failures.
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.
---
v5:
- 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/[email protected]/
- 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/[email protected]/
- Add Tianyi Gao's Tested-by to patch 1.
- Add patch 2 fixing the remaining three checks.
v2: https://lore.kernel.org/all/[email protected]/
- Correct Fixes tag to 1ec2230fc721.
v1: https://lore.kernel.org/all/[email protected]/
- Initial posting.
Omokefe Emmanuel Onanaroghene (3):
selftests: net: veth: derive invalid-tx test value from kernel max
selftests: net: veth: propagate channel-check failures to exit status
selftests: net: veth: propagate bad-settings check failures to exit
status
tools/testing/selftests/net/veth.sh | 31 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-)
Signature · 1 line
2.43.0
PATCH v5 1/3 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 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.
--- tools/testing/selftests/net/veth.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/net/veth.sh +3 -1
@@ -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
Signature · 1 line
2.43.0
Re: [PATCH net-next v5 1/3] selftests: net: veth: derive invalid-tx test value from kernel max
Hi Omokefe,
tools/testing/selftests/net/veth.sh fi · line 469
Quoted 5 lines · On Sat, 21 Nov 2026 19:22:15 +0100 Omokefe Emmanuel Onanaroghene wrote:
tools/testing/selftests/net/veth.sh +3
-1-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
I ran veth.sh from net-next on an arm64 VM with 2 CPUs, under "taskset -c 0". Without this patch, this check reports "fail rx:1:1 tx:1:2". With it, the check passes.
Cheers,
Tianyi
PATCH v5 2/3 selftests: net: veth: propagate channel-check failures to exit status
In reply to Omokefe Emmanuel Onanaroghenechk_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.
--- tools/testing/selftests/net/veth.sh | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/net/veth.sh +1 -0
@@ -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 }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net-next v5 2/3] selftests: net: veth: propagate channel-check failures to exit status
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] selftests: net: veth: missing Fixes trailer for chk_channels() fix --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] selftests: net: veth: missing Fixes trailer for chk_channels() fix
--
commit 5d20ccb90ecdb7366b108efa1d9fec12aee9201e
Author: Omokefe Emmanuel Onanaroghene <[email protected]>
Quoted 10 lines
selftests: net: veth: propagate channel-check failures to exit status
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 allchk_channels()call sites expect the check to pass. Set ret=1 on mismatch.Tested-by Tianyi Gao <[email protected]>Signed-off-by Omokefe Emmanuel Onanaroghene <[email protected]>
[Severity: Low]
This fixes a bug in chk_channels() where channel count mismatches did not cause the script to fail. Should this include a Fixes tag?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v5 3/3 selftests: net: veth: propagate bad-settings check failures to exit status
In reply to Omokefe Emmanuel OnanarogheneThree 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.
--- tools/testing/selftests/net/veth.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
tools/testing/selftests/net/veth.sh +19 -7
@@ -474,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
@@ -484,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
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net-next v5 3/3] selftests: net: veth: propagate bad-settings check failures to exit status
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] selftests: net: veth: missing Fixes: trailer for bad-settings exit status fix --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] selftests: net: veth: missing Fixes: trailer for bad-settings exit status fix
--
commit 8ddb499da6652b523173fb5185c64f0e2151d257
Author: Omokefe Emmanuel Onanaroghene <[email protected]>
Quoted 9 lines
selftests: net: veth: propagate bad-settings check failures to exit status
Three more checks in
veth.shprint "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.
Quoted 3 lines
[Severity: Low]
This fixes the three negative channel checks added in 1ec2230fc721 ("selftests: net: veth: add tests for set_channel"). Should this include:
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH net-next v5 3/3] selftests: net: veth: propagate bad-settings check failures to exit status
In reply to Omokefe Emmanuel OnanarogheneHi Omokefe,
Quoted 67 lines · Omokefe Emmanuel Onanaroghene
Three more checks in
veth.shprint "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 <[email protected]>Link https://lore.kernel.org/all/CAG4wq-cd01i7YrcFPmma=BXUcwn_PK=wneKW=vyEBYzQ3Bn7QA@mail.gmail.com/ open hereSigned-off-by Omokefe Emmanuel Onanaroghene <[email protected]>--- tools/testing/selftests/net/veth.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)tools/testing/selftests/net/veth.sh +19
-7@@ -474,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@@ -484,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 fiSignature · 1 line
2.43.0
This one and patch 2 are fixing the same issue in the same test. Why bother with two patches?
Thanks
Hangbin
Re: [PATCH net-next v5 3/3] selftests: net: veth: propagate bad-settings check failures to exit status
Quoted 2 lines · On Mon, 23 Nov 2026 13:22:07 +0800 Hangbin Liu wrote:
This one and patch 2 are fixing the same issue in the same test. Why bother with two patches?
You're correct, squashed into one propagation patch in v7
https://lore.kernel.org/all/[email protected]/
Thanks,
Omokefe
Re: [PATCH net-next v5 3/3] selftests: net: veth: propagate bad-settings check failures to exit status
In reply to Omokefe Emmanuel OnanarogheneHi Omokefe,
Quoted 6 lines · On Sat, 21 Nov 2026 19:22:17 +0100 Omokefe Emmanuel Onanaroghene wrote:
Three more checks in
veth.shprint "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.
If you squash this patch with patch 2, feel free to keep my tag on the result.
Cheers,
Tianyi
Re: [PATCH net-next v5 3/3] selftests: net: veth: propagate bad-settings check failures to exit status
Quoted 2 lines · On Mon, 23 Nov 2026 14:09:47 +0000 Tianyi Gao wrote:
If you squash this patch with patch 2, feel free to keep my tag on the result.
Done in v7 https://lore.kernel.org/all/[email protected]/
Thanks for the review,
Omokefe