Article View: linux.kernel.netdev
Article #3503[PATCH net 2/2] selftests: net: check veth carrier after changing channel counts
From: Xia Yan
Date: Thu, 15 Oct 2026 08:58
Date: Thu, 15 Oct 2026 08:58
141 lines
10171 bytes
10171 bytes
Add a regression test for veth_set_channels() incorrectly enabling
carrier when the peer is administratively down.
Check all combinations of the two ends' administrative states with GRO
enabled and disabled. Resize the RX and TX channel counts in both
directions on each end and verify that carrier is on only when both ends
are up. Also verify that rejecting an out-of-range channel count leaves
carrier unchanged.
On an unpatched kernel the two mixed up/down cases fail with each GRO
setting. All eight cases pass with the carrier restoration fix.
Assisted-by: LLM
Signed-off-by: Xia Yan <yana06070@163.com>
---
Notes (validation):
Tested with iproute2 and ethtool in an isolated network namespace under
the unpatched and patched UML kernels. The mixed up/down states fail
before the driver fix with both GRO settings; all eight cases pass after
the fix. The script also passes bash -n.
The new file is covered by the existing MAINTAINERS entry for
tools/testing/selftests/; no MAINTAINERS update is needed.
tools/testing/selftests/net/Makefile | 1 +
.../selftests/net/veth_channels_carrier.sh | 89 +++++++++++++++++++
2 files changed, 90 insertions(+)
create mode 100755 tools/testing/selftests/net/veth_channels_carrier.sh
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 590b33e..4004014 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -128,6 +128,7 @@ TEST_PROGS := \
udpgso_bench.sh \
unicast_extensions.sh \
veth.sh \
+ veth_channels_carrier.sh \
vlan_bridge_binding.sh \
vlan_hw_filter.sh \
vrf-xfrm-tests.sh \
diff --git a/tools/testing/selftests/net/veth_channels_carrier.sh b/tools/testing/selftests/net/veth_channels_carrier.sh
new file mode 100755
index 0000000..c72a03b
--- /dev/null
+++ b/tools/testing/selftests/net/veth_channels_carrier.sh
@@ -0,0 +1,89 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
+
+require_command ip
+require_command ethtool
+
+if [ "$EUID" -ne 0 ]; then
+ echo "SKIP: root privileges are required"
+ exit "$ksft_skip"
+fi
+
+trap cleanup_all_ns EXIT
+setup_ns ns || exit $?
+
+check_carrier()
+{
+ local dev=$1
+ local expected=$2
+ local carrier=0
+ local link
+
+ link=$(ip -n "$ns" -o link show dev "$dev")
+ check_err $? "Failed to read $dev link state"
+ [[ $link == *LOWER_UP* ]] && carrier=1
+ [ "$carrier" -eq "$expected" ]
+ check_err $? "$dev carrier is $carrier, expected $expected"
+}
+
+check_state()
+{
+ local left=$1
+ local right=$2
+ local gro=$3
+ local expected=0
+ local count dev
+
+ RET=0
+ if ! ip -n "$ns" link add vca numtxqueues 2 numrxqueues 2 \
+ type veth peer name vcb numtxqueues 2 numrxqueues 2; then
+ RET=$ksft_skip
+ log_test "veth carrier: $left/$right, GRO $gro"
+ return
+ fi
+
+ ip -n "$ns" link set vca "$left"
+ check_err $? "Failed to configure vca"
+ ip -n "$ns" link set vcb "$right"
+ check_err $? "Failed to configure vcb"
+ ip netns exec "$ns" ethtool -K vca gro "$gro" >/dev/null
+ check_err $? "Failed to configure GRO"
+ ip netns exec "$ns" ethtool -K vcb gro "$gro" >/dev/null
+ check_err $? "Failed to configure peer GRO"
+
+ [ "$left" = up ] && [ "$right" = up ] && expected=1
+ check_carrier vca "$expected"
+ check_carrier vcb "$expected"
+
+ for dev in vca vcb; do
+ for count in 1 2; do
+ ip netns exec "$ns" ethtool -L "$dev" \
+ rx "$count" tx "$count"
+ check_err $? "Failed to resize $dev channels"
+ check_carrier vca "$expected"
+ check_carrier vcb "$expected"
+ done
+
+ ip netns exec "$ns" ethtool -L "$dev" rx 3 tx 3 \
+ >/dev/null 2>&1
+ check_fail $? "Out-of-range channel counts were accepted"
+ check_carrier vca "$expected"
+ check_carrier vcb "$expected"
+ done
+
+ ip -n "$ns" link del vca
+ check_err $? "Failed to delete the veth pair"
+ log_test "veth carrier: $left/$right, GRO $gro"
+}
+
+for gro in off on; do
+ for left in down up; do
+ for right in down up; do
+ check_state "$left" "$right" "$gro"
+ done
+ done
+done
+
+exit "$EXIT_STATUS"
--
2.33.0
Technical Details
Message-ID:
<20261015085821.12725-2-yana06070@163.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346625-linux-kernel-netdev=dewy.ruReferences:
<20261015085821.12725-1-yana06070@163.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346625-linux-kernel-netdev=dewy.ru From: yana06070@163.com (Xia Yan) Newsgroups: linux.kernel.netdev Subject: [PATCH net 2/2] selftests: net: check veth carrier after changing channel counts Date: Thu, 15 Oct 2026 16:58:21 +0800 Organization: Usenet Network Message-ID: <20261015085821.12725-2-yana06070@163.com> References: <20261015085821.12725-1-yana06070@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2491639"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Pd1Abfbp3bHfAjhHIir3a0arZFw= sha256:+71CVyyaspD/w+WmGW152aYrmqjWNAtYCWQsqDNnEOw= sha1:nBq5s46hMWBxT2DMW4ZdFT9XRI8= sha256:u1UNisqaWR7m5kS9rJuVYui9LNE56xtTIX3UIXSiTr8= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 7568D110290; Thu, 15 Oct 2026 12:05:26 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.146 X-Spam-Status: No, score=-3.146 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=163.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id raWY4w1wP212; Thu, 15 Oct 2026 12:05:24 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-346625-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id ACAD411027A; Thu, 15 Oct 2026 12:05:14 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id 86D6260F1CE; Thu, 15 Oct 2026 09:01:03 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 291CC4F85B7; Thu, 15 Oct 2026 08:59:14 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="ehb1dYls" X-Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBFB24EBAD2; Thu, 15 Oct 2026 08:59:05 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.2 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792054753; cv=none; b=MCovs3yBrbCnjftL2TJ2IAJNh+5mcxVJeyfsG7RPvCKcU8hZfOS4TeLmG6Joyoa84rM9kwQR1E1IU7RnAAGVYkahpoUCeNT9dYCS7TQL6+pOXgBRbMK2R1Oy7kH6pfJgTWJS5emtZnuAGucfVHJg45OFpKjWq0DU7X61YZsEsiM= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792054753; c=relaxed/simple; bh=Qyk4fzUIXwUnNk3bSw3qy/UwHIH1593oSmAaBN3Ti8k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nh25n+Iz9fuzjBCQRdGT56LLnvDV8QYko4bPdkSMKMI405vjedzGCvv6huh+8rqn4a0bQpvW3hlydf9GYClMq4hSFK1w/ZvSiLOdKoyx6WwxRuz9dY0Ew/1AF6WtW57Pk/CRI9r6ocjeWQFG2bl91onzKe53b7Dj6qGrpbTV+Ro= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=ehb1dYls; arc=none smtp.client-ip=117.135.210.2 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=/x y4dCAFiSOS7bJrEJtqhdCx4Cmu9Io/aYfxxfzJL5A=; b=ehb1dYlsxGIs/XyYln b5Q0ak/8ntDQrwMKmR4r5A2f79GWPwFKWAGK+ahz5iQnnVX4vei+LQgRLnsd76Ut /NdRLDqfR3jhRsoGfBvHF3qWZbRrpnHJEKUEL6eaO9oESBVdRJNc36nAfg01IVOv gABwWQ8CLAuxpv9cRGIrm8yPc= X-Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g0-3 (Coremail) with SMTP id _____wD3n4O5ldBq3yzkAA--.32772S3; Thu, 15 Oct 2026 16:58:35 +0800 (CST) X-Cc: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org X-Mailer: git-send-email 2.33.0 X-In-Reply-To: <20261015085821.12725-1-yana06070@163.com> X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-CM-TRANSID: _____wD3n4O5ldBq3yzkAA--.32772S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxAF4UtF13JFWUAryUur4xCrg_yoWrAr1fpF s3Gw1aqr1IqF13tw1xKrs8ZF48W3Wvqw4jq34ay34DZ3ZFkrnaqr13K347tFyUKrs0qa13 ZFyS9Fn2g3WUuaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jSrWrUUUUU= X-CM-SenderInfo: p1dqtiawqxiqqrwthudrp/xtbC-Bti6GrQlbtH6QAA3X