From: Tianyi Gao <tianyi@cloudflare.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, toke@redhat.com,
lorenzo@kernel.org, horms@kernel.org, shuah@kernel.org,
ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org,
john.fastabend@gmail.com, sdf@fomichev.me, joe@dama.to,
linux-kselftest@vger.kernel.org, bpf@vger.kernel.org,
kernel-team@cloudflare.com, tianyi.gao@linux.dev,
Tianyi Gao <tianyi@cloudflare.com>
Subject: [PATCH net-next v3 5/5] selftests: net: veth: test that RX queues keep their NAPI IDs
Date: Sun, 15 Nov 2026 19:35:31 +0000 [thread overview]
Message-ID: <20261115193531.57679-6-tianyi@cloudflare.com> (raw)
In-Reply-To: <20261115193531.57679-1-tianyi@cloudflare.com>
Add a check that each RX queue keeps its NAPI ID when veth deletes its
NAPI instance and adds it again.
get_napi_ids() reads the NAPI ID of each RX queue with the ynl CLI. The
test saves the IDs once GRO is on. chk_napi_ids() compares them with
the saved IDs after ethtool -L raises the number of RX queues, after
XDP is attached with GRO off, and after link down/up. A failed read
fails the check.
Signed-off-by: Tianyi Gao <tianyi@cloudflare.com>
---
tools/testing/selftests/net/veth.sh | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tools/testing/selftests/net/veth.sh b/tools/testing/selftests/net/veth.sh
index 685209995485..9496b599d722 100755
--- a/tools/testing/selftests/net/veth.sh
+++ b/tools/testing/selftests/net/veth.sh
@@ -148,6 +148,30 @@ chk_queue_napi() {
fi
}
+get_napi_ids() {
+ local ns=$BASE$1
+ local ifindex
+
+ ifindex=`ip netns exec $ns cat /sys/class/net/veth$1/ifindex`
+ ip netns exec $ns "$YNL" --family netdev --dump queue-get \
+ --output-json --json "{\"ifindex\": $ifindex}" |
+ jq -c 'sort_by(.id) | map(select(.type == "rx") | ."napi-id")'
+}
+
+chk_napi_ids() {
+ local msg="$1"
+ local ids
+
+ ids=`get_napi_ids $2`
+ printf "%-60s" "$msg"
+ if [ -n "$ids" ] && [ "$ids" = "$NAPI_IDS" ]; then
+ echo " ok "
+ else
+ echo " fail - expected $NAPI_IDS found $ids"
+ ret=1
+ fi
+}
+
chk_channels() {
local msg="$1"
local target=$2
@@ -492,11 +516,13 @@ if [ -f "$YNL" ] && [ -x "$(command -v jq)" ]; then
chk_queue_napi "queue napi - default" $DST 0
ip netns exec $NS_DST ethtool -K veth$DST gro on
chk_queue_napi " - with gro on" $DST $RXQ
+ NAPI_IDS=`get_napi_ids $DST`
if [ $CPUS -gt 1 ]; then
ip netns exec $NS_DST ethtool -L veth$DST rx 1
chk_queue_napi " - fewer rx channels with gro" $DST 1
ip netns exec $NS_DST ethtool -L veth$DST rx 2
chk_queue_napi " - more rx channels with gro" $DST 2
+ chk_napi_ids " - same napi ids" $DST
fi
ip -n $NS_DST link set dev veth$DST xdp object ${BPF_FILE} section xdp
chk_queue_napi " - with gro and xdp on" $DST $RXQ
@@ -506,15 +532,18 @@ if [ -f "$YNL" ] && [ -x "$(command -v jq)" ]; then
chk_queue_napi " - after gro off" $DST 0
ip -n $NS_DST link set dev veth$DST xdp object ${BPF_FILE} section xdp
chk_queue_napi " - with xdp on" $DST $RXQ
+ chk_napi_ids " - same napi ids" $DST
if [ $CPUS -gt 1 ]; then
ip netns exec $NS_DST ethtool -L veth$DST rx 1
chk_queue_napi " - fewer rx channels with xdp" $DST 1
ip netns exec $NS_DST ethtool -L veth$DST rx 2
chk_queue_napi " - more rx channels with xdp" $DST 2
+ chk_napi_ids " - same napi ids" $DST
fi
ip -n $NS_DST link set dev veth$DST down
ip -n $NS_DST link set dev veth$DST up
chk_queue_napi " - after down and up" $DST $RXQ
+ chk_napi_ids " - same napi ids" $DST
ip -n $NS_DST link set dev veth$DST xdp off
chk_queue_napi " - after xdp off" $DST 0
cleanup
--
2.56.0
prev parent reply other threads:[~2026-11-15 19:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 19:35 [PATCH net-next v3 0/5] veth: link RX queues to their NAPI instances Tianyi Gao
2026-11-15 19:35 ` [PATCH net-next v3 1/5] veth: refactor NAPI enable paths Tianyi Gao
2026-11-15 19:35 ` [PATCH net-next v3 2/5] veth: link RX queues to their NAPI instances Tianyi Gao
2026-11-15 19:35 ` [PATCH net-next v3 3/5] selftests: net: veth: test RX queue NAPI links Tianyi Gao
2026-11-15 19:35 ` [PATCH net-next v3 4/5] veth: use persistent NAPI config Tianyi Gao
2026-11-15 19:35 ` Tianyi Gao [this message]
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=20261115193531.57679-6-tianyi@cloudflare.com \
--to=tianyi@cloudflare.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=joe@dama.to \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=tianyi.gao@linux.dev \
--cc=toke@redhat.com \
/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