* [PATCH net v3 1/2] veth: keep carrier off when resizing channels with a down peer
@ 2026-10-22 8:58 Xia Yan
2026-10-22 8:58 ` [PATCH net v3 2/2] selftests: net: check veth carrier after changing channel counts Xia Yan
2026-10-23 1:56 ` [PATCH net v3 1/2] veth: keep carrier off when resizing channels with a down peer Hangbin Liu
0 siblings, 2 replies; 7+ messages in thread
From: Xia Yan @ 2026-10-22 8:58 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, horms, kuba, linux-kernel,
linux-kselftest, pabeni, shuah, yana06070, stable
veth_set_channels() temporarily turns carrier off while reconfiguring a
running interface. It then turns carrier on for both ends without
checking whether the peer is administratively up. If only one end is up,
changing its channel counts therefore reports LOWER_UP even though the
peer remains down.
For example, after creating a pair with two RX and TX queues per end:
ip link set vca up
ethtool -L vca rx 1 tx 1
vca incorrectly reports LOWER_UP while vcb is still down.
Only restore carrier when the peer has IFF_UP, matching veth_open().
The local interface is already known to be running at this point.
Found during LLM-assisted source review and reproduced with a veth pair
in network namespaces, without kernel instrumentation or error injection.
With the complete default veth.sh on x86_64 QEMU/KVM (three vCPUs), the
four mixed up/down cases fail before the fix and all six carrier cases
pass after it. All 55 existing checks pass on both kernels.
Fixes: 4752eeb3d891 ("veth: implement support for set_channel ethtool op")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Xia Yan <yana06070@163.com>
---
Notes:
Changes in v3:
- Driver code is unchanged from v2.
- The companion selftest is now part of veth.sh.
v2: https://lore.kernel.org/netdev/20261020135544.24441-1-yana06070@163.com/
Testing on the v2 baseline 513444cc62e2:
- Complete default veth.sh on x86_64 QEMU/KVM, three vCPUs:
before: 57 checks pass, four mixed up/down carrier checks fail;
after: all 61 checks pass. The 55 existing checks pass on both.
- bash -n and git diff --check pass.
- If creating the veth pair fails, the case is skipped without
masking failures from earlier test cases.
Both patches also apply to net/main ffdf678dd166
(application check only, checked on 2026-10-22).
The QEMU guests failed to power off cleanly (initramfs issue) after
the tests completed; the exit codes above are the veth.sh results.
drivers/net/veth.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 643b97d..4e75830 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1372,9 +1372,10 @@ static int veth_set_channels(struct net_device *dev,
* to identify the range we have to disable
*/
veth_disable_range_safe(dev, new_rx_count, old_rx_count);
- netif_carrier_on(dev);
- if (peer)
+ if (peer && (peer->flags & IFF_UP)) {
+ netif_carrier_on(dev);
netif_carrier_on(peer);
+ }
}
/* update XDP supported features */
base-commit: 513444cc62e231a11c9b15ea88de0890da9b2b4f
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net v3 2/2] selftests: net: check veth carrier after changing channel counts
2026-10-22 8:58 [PATCH net v3 1/2] veth: keep carrier off when resizing channels with a down peer Xia Yan
@ 2026-10-22 8:58 ` Xia Yan
2026-10-23 1:47 ` Hangbin Liu
2026-10-23 1:56 ` [PATCH net v3 1/2] veth: keep carrier off when resizing channels with a down peer Hangbin Liu
1 sibling, 1 reply; 7+ messages in thread
From: Xia Yan @ 2026-10-22 8:58 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, horms, kuba, linux-kernel,
linux-kselftest, pabeni, shuah, yana06070
Extend veth.sh to check carrier state after changing channel counts.
A running interface must keep carrier off while its peer is down.
Cover up/up and both mixed up/down combinations with GRO on and off.
Resize RX and TX queues in both directions on each endpoint, and check
that rejecting an out-of-range request also preserves carrier state.
Use two queues explicitly so these cases also run on single-CPU systems.
Keep these cases with the existing veth tests and reuse their namespace
setup, cleanup and aggregate failure status. Only check LOWER_UP on
running interfaces, where that flag exposes carrier state.
The four mixed up/down cases fail with the unfixed driver. All six
carrier cases and the existing checks pass with the fix.
Assisted-by: LLM
Signed-off-by: Xia Yan <yana06070@163.com>
---
Notes:
Changes in v3:
- Move the six carrier cases into veth.sh following review of v2.
- Reuse namespace setup, cleanup and error reporting.
- Allow explicit queue counts in create_ns().
v2: https://lore.kernel.org/netdev/20261020135544.24441-1-yana06070@163.com/
Testing on the v2 baseline 513444cc62e2:
- Complete default veth.sh on x86_64 QEMU/KVM, three vCPUs:
before: 57 checks pass, four mixed up/down carrier checks fail;
after: all 61 checks pass. The 55 existing checks pass on both.
- bash -n and git diff --check pass.
- If creating the veth pair fails, the case is skipped without
masking failures from earlier test cases.
Both patches also apply to net/main ffdf678dd166
(application check only, checked on 2026-10-22).
The QEMU guests failed to power off cleanly (initramfs issue) after
the tests completed; the exit codes above are the veth.sh results.
tools/testing/selftests/net/veth.sh | 84 ++++++++++++++++++++++++++++-
1 file changed, 83 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/veth.sh b/tools/testing/selftests/net/veth.sh
index 8b867e0..901ba51 100755
--- a/tools/testing/selftests/net/veth.sh
+++ b/tools/testing/selftests/net/veth.sh
@@ -41,13 +41,15 @@ create_ns() {
ip -n $ns link set dev lo up
done
- ip link add name veth$SRC type veth peer name veth$DST
+ ip link add name veth$SRC "$@" type veth peer name veth$DST "$@" || return 1
for ns in $SRC $DST; do
ip link set dev veth$ns netns $BASE$ns up
ip -n $BASE$ns addr add dev veth$ns $BM_NET_V4$ns/24
ip -n $BASE$ns addr add dev veth$ns $BM_NET_V6$ns/64 nodad
done
+
+ return 0
}
__chk_flag() {
@@ -130,6 +132,80 @@ chk_channels() {
fi
}
+chk_carrier() {
+ local target=$1
+ local state=$2
+ local expected=$3
+ local carrier=0
+ local link
+
+ # IFF_LOWER_UP is reported only for running interfaces.
+ [ "$state" = up ] || return 0
+
+ if ! link=$(ip -n $BASE$target -o link show dev veth$target); then
+ echo " fail - cannot read veth$target link state"
+ return 1
+ fi
+ case "$link" in
+ *LOWER_UP*) carrier=1 ;;
+ esac
+ if [ "$carrier" -ne "$expected" ]; then
+ echo " fail - veth$target carrier is $carrier, expected $expected"
+ return 1
+ fi
+}
+
+chk_channels_carrier() {
+ local src_state=$1
+ local dst_state=$2
+ local gro=$3
+ local expected=0
+ local err=0
+ local target count
+ local msg="carrier after channel change ($src_state/$dst_state, GRO $gro)"
+
+ if ! create_ns numtxqueues 2 numrxqueues 2; then
+ printf "%-60s" "$msg"
+ echo " skip - cannot create veth pair"
+ cleanup
+ return
+ fi
+
+ ip -n $NS_SRC link set dev veth$SRC "$src_state" || err=1
+ ip -n $NS_DST link set dev veth$DST "$dst_state" || err=1
+ ip netns exec $NS_SRC ethtool -K veth$SRC gro "$gro" >/dev/null || err=1
+ ip netns exec $NS_DST ethtool -K veth$DST gro "$gro" >/dev/null || err=1
+ [ "$src_state" = up ] && [ "$dst_state" = up ] && expected=1
+ chk_carrier $SRC "$src_state" "$expected" || err=1
+ chk_carrier $DST "$dst_state" "$expected" || err=1
+
+ for target in $SRC $DST; do
+ for count in 1 2; do
+ ip netns exec $BASE$target ethtool -L veth$target \
+ rx "$count" tx "$count" || err=1
+ chk_carrier $SRC "$src_state" "$expected" || err=1
+ chk_carrier $DST "$dst_state" "$expected" || err=1
+ done
+
+ if ip netns exec $BASE$target ethtool -L veth$target rx 3 tx 3 \
+ >/dev/null 2>&1; then
+ echo " fail - out-of-range channel counts were accepted"
+ err=1
+ fi
+ chk_carrier $SRC "$src_state" "$expected" || err=1
+ chk_carrier $DST "$dst_state" "$expected" || err=1
+ done
+
+ cleanup
+ printf "%-60s" "$msg"
+ if [ "$err" -eq 0 ]; then
+ echo " ok "
+ else
+ echo " fail "
+ ret=1
+ fi
+}
+
chk_gro() {
local msg="$1"
local expected=$2
@@ -257,6 +333,12 @@ fi
[ $STRESS -gt 0 -a $CPUS -lt 3 ] && echo " stress test will be skipped, too"
[ ! -f "$YNL" ] && echo "ynl cli not found, ndo-xmit tests will be skipped"
+for gro in off on; do
+ chk_channels_carrier up up "$gro"
+ chk_channels_carrier up down "$gro"
+ chk_channels_carrier down up "$gro"
+done
+
create_ns
chk_gro_flag "default - gro flag" $SRC off
chk_gro_flag " - peer gro flag" $DST off
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 2/2] selftests: net: check veth carrier after changing channel counts
2026-10-22 8:58 ` [PATCH net v3 2/2] selftests: net: check veth carrier after changing channel counts Xia Yan
@ 2026-10-23 1:47 ` Hangbin Liu
2026-10-23 2:33 ` Xia Yan
0 siblings, 1 reply; 7+ messages in thread
From: Hangbin Liu @ 2026-10-23 1:47 UTC (permalink / raw)
To: Xia Yan
Cc: netdev, andrew+netdev, davem, edumazet, horms, kuba,
linux-kernel, linux-kselftest, pabeni, shuah
Hi Yan Xia,
On Thu, Oct 22, 2026 at 04:58:42PM +0800, Xia Yan wrote:
> Extend veth.sh to check carrier state after changing channel counts.
> A running interface must keep carrier off while its peer is down.
>
> Cover up/up and both mixed up/down combinations with GRO on and off.
> Resize RX and TX queues in both directions on each endpoint, and check
> that rejecting an out-of-range request also preserves carrier state.
> Use two queues explicitly so these cases also run on single-CPU systems.
>
> Keep these cases with the existing veth tests and reuse their namespace
> setup, cleanup and aggregate failure status. Only check LOWER_UP on
> running interfaces, where that flag exposes carrier state.
>
> The four mixed up/down cases fail with the unfixed driver. All six
> carrier cases and the existing checks pass with the fix.
>
> Assisted-by: LLM
> Signed-off-by: Xia Yan <yana06070@163.com>
> ---
>
> Notes:
> Changes in v3:
> - Move the six carrier cases into veth.sh following review of v2.
> - Reuse namespace setup, cleanup and error reporting.
> - Allow explicit queue counts in create_ns().
>
> v2: https://lore.kernel.org/netdev/20261020135544.24441-1-yana06070@163.com/
>
> Testing on the v2 baseline 513444cc62e2:
> - Complete default veth.sh on x86_64 QEMU/KVM, three vCPUs:
> before: 57 checks pass, four mixed up/down carrier checks fail;
> after: all 61 checks pass. The 55 existing checks pass on both.
> - bash -n and git diff --check pass.
> - If creating the veth pair fails, the case is skipped without
> masking failures from earlier test cases.
>
> Both patches also apply to net/main ffdf678dd166
> (application check only, checked on 2026-10-22).
>
> The QEMU guests failed to power off cleanly (initramfs issue) after
> the tests completed; the exit codes above are the veth.sh results.
>
>
> tools/testing/selftests/net/veth.sh | 84 ++++++++++++++++++++++++++++-
> 1 file changed, 83 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/veth.sh b/tools/testing/selftests/net/veth.sh
> index 8b867e0..901ba51 100755
> --- a/tools/testing/selftests/net/veth.sh
> +++ b/tools/testing/selftests/net/veth.sh
> @@ -41,13 +41,15 @@ create_ns() {
> ip -n $ns link set dev lo up
> done
>
> - ip link add name veth$SRC type veth peer name veth$DST
> + ip link add name veth$SRC "$@" type veth peer name veth$DST "$@" || return 1
>
> for ns in $SRC $DST; do
> ip link set dev veth$ns netns $BASE$ns up
> ip -n $BASE$ns addr add dev veth$ns $BM_NET_V4$ns/24
> ip -n $BASE$ns addr add dev veth$ns $BM_NET_V6$ns/64 nodad
> done
> +
> + return 0
> }
>
> __chk_flag() {
> @@ -130,6 +132,80 @@ chk_channels() {
> fi
> }
>
> +chk_carrier() {
> + local target=$1
> + local state=$2
> + local expected=$3
> + local carrier=0
> + local link
> +
> + # IFF_LOWER_UP is reported only for running interfaces.
> + [ "$state" = up ] || return 0
> +
> + if ! link=$(ip -n $BASE$target -o link show dev veth$target); then
> + echo " fail - cannot read veth$target link state"
> + return 1
> + fi
> + case "$link" in
> + *LOWER_UP*) carrier=1 ;;
> + esac
> + if [ "$carrier" -ne "$expected" ]; then
> + echo " fail - veth$target carrier is $carrier, expected $expected"
> + return 1
> + fi
> +}
> +
> +chk_channels_carrier() {
> + local src_state=$1
> + local dst_state=$2
> + local gro=$3
> + local expected=0
> + local err=0
> + local target count
> + local msg="carrier after channel change ($src_state/$dst_state, GRO $gro)"
> +
> + if ! create_ns numtxqueues 2 numrxqueues 2; then
> + printf "%-60s" "$msg"
> + echo " skip - cannot create veth pair"
> + cleanup
> + return
> + fi
> +
> + ip -n $NS_SRC link set dev veth$SRC "$src_state" || err=1
> + ip -n $NS_DST link set dev veth$DST "$dst_state" || err=1
> + ip netns exec $NS_SRC ethtool -K veth$SRC gro "$gro" >/dev/null || err=1
> + ip netns exec $NS_DST ethtool -K veth$DST gro "$gro" >/dev/null || err=1
Why do you do gro setting in rx/tx set ups?
Thanks
Hangbin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 1/2] veth: keep carrier off when resizing channels with a down peer
2026-10-22 8:58 [PATCH net v3 1/2] veth: keep carrier off when resizing channels with a down peer Xia Yan
2026-10-22 8:58 ` [PATCH net v3 2/2] selftests: net: check veth carrier after changing channel counts Xia Yan
@ 2026-10-23 1:56 ` Hangbin Liu
1 sibling, 0 replies; 7+ messages in thread
From: Hangbin Liu @ 2026-10-23 1:56 UTC (permalink / raw)
To: Xia Yan
Cc: netdev, andrew+netdev, davem, edumazet, horms, kuba,
linux-kernel, linux-kselftest, pabeni, shuah, stable
On Thu, Oct 22, 2026 at 04:58:41PM +0800, Xia Yan wrote:
> veth_set_channels() temporarily turns carrier off while reconfiguring a
> running interface. It then turns carrier on for both ends without
> checking whether the peer is administratively up. If only one end is up,
> changing its channel counts therefore reports LOWER_UP even though the
> peer remains down.
>
> For example, after creating a pair with two RX and TX queues per end:
>
> ip link set vca up
> ethtool -L vca rx 1 tx 1
>
> vca incorrectly reports LOWER_UP while vcb is still down.
>
> Only restore carrier when the peer has IFF_UP, matching veth_open().
> The local interface is already known to be running at this point.
>
> Found during LLM-assisted source review and reproduced with a veth pair
> in network namespaces, without kernel instrumentation or error injection.
> With the complete default veth.sh on x86_64 QEMU/KVM (three vCPUs), the
> four mixed up/down cases fail before the fix and all six carrier cases
> pass after it. All 55 existing checks pass on both kernels.
>
> Fixes: 4752eeb3d891 ("veth: implement support for set_channel ethtool op")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Xia Yan <yana06070@163.com>
> ---
>
> Notes:
> Changes in v3:
> - Driver code is unchanged from v2.
> - The companion selftest is now part of veth.sh.
>
> v2: https://lore.kernel.org/netdev/20261020135544.24441-1-yana06070@163.com/
>
> Testing on the v2 baseline 513444cc62e2:
> - Complete default veth.sh on x86_64 QEMU/KVM, three vCPUs:
> before: 57 checks pass, four mixed up/down carrier checks fail;
> after: all 61 checks pass. The 55 existing checks pass on both.
> - bash -n and git diff --check pass.
> - If creating the veth pair fails, the case is skipped without
> masking failures from earlier test cases.
>
> Both patches also apply to net/main ffdf678dd166
> (application check only, checked on 2026-10-22).
>
> The QEMU guests failed to power off cleanly (initramfs issue) after
> the tests completed; the exit codes above are the veth.sh results.
>
>
> drivers/net/veth.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index 643b97d..4e75830 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -1372,9 +1372,10 @@ static int veth_set_channels(struct net_device *dev,
> * to identify the range we have to disable
> */
> veth_disable_range_safe(dev, new_rx_count, old_rx_count);
> - netif_carrier_on(dev);
> - if (peer)
> + if (peer && (peer->flags & IFF_UP)) {
> + netif_carrier_on(dev);
> netif_carrier_on(peer);
> + }
> }
>
> /* update XDP supported features */
>
> base-commit: 513444cc62e231a11c9b15ea88de0890da9b2b4f
> --
> 2.43.0
>
This one looks good to me. I can reproduce the report issue.
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 2/2] selftests: net: check veth carrier after changing channel counts
2026-10-23 1:47 ` Hangbin Liu
@ 2026-10-23 2:33 ` Xia Yan
2026-10-23 3:15 ` Hangbin Liu
0 siblings, 1 reply; 7+ messages in thread
From: Xia Yan @ 2026-10-23 2:33 UTC (permalink / raw)
To: hangbin.liu
Cc: netdev, andrew+netdev, davem, edumazet, horms, kuba,
linux-kernel, linux-kselftest, pabeni, shuah, yana06070
Hi Hangbin,
Thanks for reproducing the issue and reviewing the driver fix.
> Why do you do gro setting in rx/tx set ups?
I included GRO off/on to cover both queue reconfiguration paths.
No XDP program is attached in these cases. With GRO on,
veth_enable_range_safe() and veth_disable_range_safe() set up or tear
down per-RX-queue NAPI instances as the RX queue count changes. With
GRO off, those helpers do not need to reconfigure NAPI.
The carrier bug reproduces in both configurations, so the test checks
the same carrier state with and without the NAPI resource changes.
Best regards,
Xia Yan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 2/2] selftests: net: check veth carrier after changing channel counts
2026-10-23 2:33 ` Xia Yan
@ 2026-10-23 3:15 ` Hangbin Liu
2026-10-23 3:35 ` Xia Yan
0 siblings, 1 reply; 7+ messages in thread
From: Hangbin Liu @ 2026-10-23 3:15 UTC (permalink / raw)
To: Xia Yan
Cc: netdev, andrew+netdev, davem, edumazet, horms, kuba,
linux-kernel, linux-kselftest, pabeni, shuah
On Fri, Oct 23, 2026 at 10:33:50AM +0800, Xia Yan wrote:
> Hi Hangbin,
>
> Thanks for reproducing the issue and reviewing the driver fix.
>
> > Why do you do gro setting in rx/tx set ups?
>
> I included GRO off/on to cover both queue reconfiguration paths.
> No XDP program is attached in these cases. With GRO on,
> veth_enable_range_safe() and veth_disable_range_safe() set up or tear
> down per-RX-queue NAPI instances as the RX queue count changes. With
> GRO off, those helpers do not need to reconfigure NAPI.
>
> The carrier bug reproduces in both configurations, so the test checks
> the same carrier state with and without the NAPI resource changes.
I mean this doesn't seem related to the carrier on/off (LOWER_UP) issue.
Or did I miss something?
Thanks
Hangbin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 2/2] selftests: net: check veth carrier after changing channel counts
2026-10-23 3:15 ` Hangbin Liu
@ 2026-10-23 3:35 ` Xia Yan
0 siblings, 0 replies; 7+ messages in thread
From: Xia Yan @ 2026-10-23 3:35 UTC (permalink / raw)
To: hangbin.liu
Cc: andrew+netdev, davem, edumazet, horms, kuba, linux-kernel,
linux-kselftest, netdev, pabeni, shuah, yana06070
Hi Hangbin,
You're right. The GRO on/off coverage isn't needed for this carrier
regression test. I'll drop it in the next revision and keep the
up/up, up/down and down/up cases, checking carrier after each
channel change.
Thanks,
Xia Yan
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-10-23 3:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 8:58 [PATCH net v3 1/2] veth: keep carrier off when resizing channels with a down peer Xia Yan
2026-10-22 8:58 ` [PATCH net v3 2/2] selftests: net: check veth carrier after changing channel counts Xia Yan
2026-10-23 1:47 ` Hangbin Liu
2026-10-23 2:33 ` Xia Yan
2026-10-23 3:15 ` Hangbin Liu
2026-10-23 3:35 ` Xia Yan
2026-10-23 1:56 ` [PATCH net v3 1/2] veth: keep carrier off when resizing channels with a down peer Hangbin Liu
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®