🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Omokefe Emmanuel Onanaroghene Sun, 15 Nov 2026 21:47
[PATCH net v2] selftests: net: veth: propagate channel-check failures to exit status
#16788
Author: Omokefe Emmanuel Onanaroghene
Date: Sun, 15 Nov 2026 21:47
29 lines
11741 bytes
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.

Fixes: 1ec2230fc721 ("selftests: net: veth: add tests for set_channel")
Signed-off-by: Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>
---
v2: correct Fixes tag (was c017800af5c71, now 1ec2230fc721)

 tools/testing/selftests/net/veth.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/net/veth.sh b/tools/testing/selftests/net/veth.sh
index 64c2a5a59821d..5c1dbe1516bb4 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
 }
 
-- 
2.43.0
Re: [PATCH net v2] selftests: net: veth: propagate channel-check failures to exit status
#16881
Author: Hangbin Liu
Date: Mon, 16 Nov 2026 00:56
21 lines
9106 bytes
On Mon, Nov 16, 2026 at 12:45:48AM +0000, Tianyi Gao wrote:
> On Sun, 15 Nov 2026 22:47:02 +0100 Omokefe Emmanuel Onanaroghene wrote:
> > chk_channels() reports mismatches with a "fail" line but never sets
> > ret, so the script exits 0 even when channel counts are wrong.
> 
> I found three more checks in the same file with the same problem:
> 
>   bad setting: XDP with RX nr less than TX
>   bad setting: reducing RX nr below peer TX with XDP set
>   bad setting: increasing peer TX nr above RX with XDP set
> 
> Maybe it is worth fixing them all at once?

+1

> 
> Tested-by: Tianyi Gao <tianyi@cloudflare.com>
> 

Hangbin
Re: [PATCH net v2] selftests: net: veth: propagate channel-check failures to exit status
#17465
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 21:50
127 lines
12529 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 0

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).

- [High] The fix is incomplete.
- [Medium] Because chk_channels() now sets ret=1, the "setting invalid
  channels nr" check at tools/testing/selftests/net/veth.sh:467-468…

--

selftests: net: veth: propagate channel-check failures to exit status

This patch changes chk_channels() in tools/testing/selftests/net/veth.sh
so that it sets ret=1 when the channel counts reported by ethtool do not
match the expected values. A channel mismatch now gives the script a
non-zero exit status.

> diff --git a/tools/testing/selftests/net/veth.sh b/tools/testing/selftests/net/veth.sh
> index 64c2a5a59821d..5c1dbe1516bb4 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
>  }

[Severity: High]
Is this fix complete?

The commit in the Fixes: tag, 1ec2230fc721 ("selftests: net: veth: add
tests for set_channel"), also added three inline channel/XDP checks to
veth.sh. Each of them prints a fail line but never sets ret:

	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 "

	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 "

	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 "

These checks test the queue count limits in drivers/net/veth.c:

veth_xdp_set():
	if (dev->real_num_rx_queues < peer->real_num_tx_queues) {
		...
		err = -ENOSPC;

veth_set_channels():
	if (priv->_xdp_prog && peer && ch->rx_count < peer->real_num_tx_queues)
		return -EINVAL;

	if (peer && peer_priv && peer_priv->_xdp_prog && ch->tx_count > peer->real_num_rx_queues)
		return -EINVAL;

Suppose a kernel change lets one of these invalid configurations
through. The script prints "fail - set operation successful ?!?", but it
still reaches exit $ret with ret=0.

The subject says channel-check failures now reach the exit status.
Should these three sites set ret=1 too?

[Severity: Medium]
Now that this sets ret=1, can the "setting invalid channels nr" check
fail the whole script on hosts where nproc is lower than
num_possible_cpus()?

The test gets its CPU count from nproc and treats CPUS + 1 as an invalid
tx count:

readonly CPUS=`nproc`
[ ... ]
ip netns exec $NS_DST ethtool -L veth$DST tx $((CPUS + 1)) 2>/dev/null
chk_channels "setting invalid channels nr" $DST $CUR_RX $CUR_TX

The kernel limit comes from num_possible_cpus() instead:

drivers/net/veth.c:veth_get_num_queues() {
	int queues = num_possible_cpus();
	...
}

drivers/net/veth.c:veth_get_channels() {
	...
	channels->max_tx = dev->num_tx_queues;
	channels->max_rx = dev->num_rx_queues;
}

ethnl_set_channels() in net/ethtool/channels.c rejects only
tx_count > max_tx, and the ioctl path does the same.
veth_set_channels() has no upper bound check of its own.

On some hosts nproc is lower than num_possible_cpus(). Examples are QEMU
with -smp N,maxcpus=M, firmware that lists hotpluggable CPU slots, or a
process limited by taskset or cpuset. There the ethtool -L call
succeeds, ethtool -l reports tx = CPUS + 1, and chk_channels() takes the
else branch.

Before this patch, that only printed a fail line. With ret=1, the
selftest now fails even though the kernel behaved correctly.

The commit message says:

    all chk_channels() call sites expect the check to pass

That doesn't hold for this call site on such hosts. Should the test pick
its out-of-range tx value from the kernel's reported maximum instead of
from nproc?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115214702.50817-1-emmaonana18%40gmail.com
Re: [PATCH net v2] selftests: net: veth: propagate channel-check failures to exit status
#18875
Author: Omokefe Emmanuel Onanaroghene
Date: Thu, 19 Nov 2026 00:40
17 lines
11727 bytes
On Mon, 16 Nov 2026 21:50:01 +0000 netdev-bot+sashiko wrote:
> - [High] The fix is incomplete.

Legitimate, and already addressed: the three bad-setting checks
gained ret=1 in v3 [2/2] (also spotted by Tianyi during review),
restyled to if/else in v4 [2/2].

> - [Medium] Because chk_channels() now sets ret=1, the "setting
>   invalid channels nr" check at
>   tools/testing/selftests/net/veth.sh:467-468…

Good catch. Fixed by [3/3] in v4,
which attempts max_tx + 1 from the kernel-reported maximum
instead of nproc + 1.

pw-bot: cr
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads