All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 v5 0/1] selftests: drv-net-hw: skip the tests that need a real interface
@ 2026-10-23 19:20 Eva Kurchatova
  2026-10-23 19:20 ` [Devel] [PATCH hci-8.1 v5 1/1] " Eva Kurchatova
  2026-10-27 12:00 ` [Devel] [PATCH hci-8.1 v5 0/1] " Konstantin Khorenko
  0 siblings, 2 replies; 5+ messages in thread
From: Eva Kurchatova @ 2026-10-23 19:20 UTC (permalink / raw)
  To: khorenko; +Cc: devel

Changes in v5:
- Follow lib.sh's order: command line, forwarding.config, then the
  driver: a NETIF_FIND_DRIVER set in forwarding.config skipped a run on
  hardware, and veths named in forwarding.config ran under
  NETIF_FIND_DRIVER.
- skip_on_veth() returns 0 when the test goes on, not 1.
- Rebased.

Link to v4: http://lore.virtuozzo.com/kernel/20261007145044.2647274-1-eva.kurchatova@virtuozzo.com/T/#t

Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-139651

Changes in v4:
- Runs that pick their interfaces by driver (NETIF_FIND_DRIVER) were
  skipped; pass them to lib.sh untouched, allowing to run now.
- Unchanged: only the first interface is judged, lib.sh builds its pair
  from that one and skips by itself when a later one is missing. Only
  a veth is detected. Everything else is configuration choice.
- Rebased.

Link to v3: http://lore.virtuozzo.com/kernel/20261006222651.2510417-1-eva.kurchatova@virtuozzo.com/T/#t
    
Changes in v3:
- Check the kind of the first interface instead of NETIF_CREATE and
  NETIF_TYPE, which stay at their defaults when forwarding.config
  names real NICs; those ran through lib.sh and were skipped here.
- Take the interfaces from the command line too, as lib.sh does.
- Rebased.

Link to v2: http://lore.virtuozzo.com/kernel/20260928194332.551992-1-eva.kurchatova@virtuozzo.com/T/#t

Changes in v2:
- Read forwarding.config before deciding, the way lib.sh does.
- One helper, skip_on_veth.sh, instead of a copy in each test.
- Add ethtool_rmon.sh, it fails on veth the same way.
- One-line comments, fix the Feature tag.
- Sent alone, 1/4 to 3/4 are merged.

Link to v1: http://lore.virtuozzo.com/kernel/20260831225137.1642608-4-eva.kurchatova@virtuozzo.com/

Eva Kurchatova (1):
  selftests: drv-net-hw: skip the tests that need a real interface

 .../testing/selftests/drivers/net/hw/Makefile |  1 +
 .../selftests/drivers/net/hw/ethtool.sh       |  5 +++
 .../drivers/net/hw/ethtool_extended_state.sh  |  5 +++
 .../selftests/drivers/net/hw/ethtool_rmon.sh  |  5 +++
 .../selftests/drivers/net/hw/hw_stats_l3.sh   |  5 +++
 .../drivers/net/hw/hw_stats_l3_gre.sh         |  5 +++
 .../selftests/drivers/net/hw/skip_on_veth.sh  | 38 +++++++++++++++++++
 7 files changed, 64 insertions(+)
 create mode 100644 tools/testing/selftests/drivers/net/hw/skip_on_veth.sh

-- 
2.56.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Devel] [PATCH hci-8.1 v5 1/1] selftests: drv-net-hw: skip the tests that need a real interface
  2026-10-23 19:20 [Devel] [PATCH hci-8.1 v5 0/1] selftests: drv-net-hw: skip the tests that need a real interface Eva Kurchatova
@ 2026-10-23 19:20 ` Eva Kurchatova
  2026-10-23 19:25   ` no-reply
  2026-10-27 12:00 ` [Devel] [PATCH hci-8.1 v5 0/1] " Konstantin Khorenko
  1 sibling, 1 reply; 5+ messages in thread
From: Eva Kurchatova @ 2026-10-23 19:20 UTC (permalink / raw)
  To: khorenko; +Cc: devel

ethtool, ethtool_extended_state, ethtool_rmon, hw_stats_l3 and
hw_stats_l3_gre need hardware: link speed, extended link state, rmon
counters, L3 statistics offload. With no interfaces configured lib.sh
substitutes a veth pair, and every case fails on what veth does not
have.

Upstream runs these tests on real hardware only and dropped the veth
check in commit 0c499a351777 ("selftests: forwarding: Ditch
skip_on_veth()"), so this patch is not for upstream.

Skip when the first interface the test would use is a veth, or does
not exist and lib.sh would create one. Real interfaces, named in
forwarding.config or on the command line, run as before, and so does a
run that picks its interfaces by driver with NETIF_FIND_DRIVER. The
check runs before lib.sh is sourced, since lib.sh creates the pair as
it is sourced and would leave it behind.

https://virtuozzo.atlassian.net/browse/VSTOR-139651
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 .../testing/selftests/drivers/net/hw/Makefile |  1 +
 .../selftests/drivers/net/hw/ethtool.sh       |  5 +++
 .../drivers/net/hw/ethtool_extended_state.sh  |  5 +++
 .../selftests/drivers/net/hw/ethtool_rmon.sh  |  5 +++
 .../selftests/drivers/net/hw/hw_stats_l3.sh   |  5 +++
 .../drivers/net/hw/hw_stats_l3_gre.sh         |  5 +++
 .../selftests/drivers/net/hw/skip_on_veth.sh  | 38 +++++++++++++++++++
 7 files changed, 64 insertions(+)
 create mode 100644 tools/testing/selftests/drivers/net/hw/skip_on_veth.sh

diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile
index e556b5150a51..39aece5e2776 100644
--- a/tools/testing/selftests/drivers/net/hw/Makefile
+++ b/tools/testing/selftests/drivers/net/hw/Makefile
@@ -19,6 +19,7 @@ TEST_PROGS = \
 
 TEST_FILES := \
 	ethtool_lib.sh \
+	skip_on_veth.sh \
 	#
 
 TEST_INCLUDES := \
diff --git a/tools/testing/selftests/drivers/net/hw/ethtool.sh b/tools/testing/selftests/drivers/net/hw/ethtool.sh
index fa6953de6b6d..e1fbe37a71fc 100755
--- a/tools/testing/selftests/drivers/net/hw/ethtool.sh
+++ b/tools/testing/selftests/drivers/net/hw/ethtool.sh
@@ -11,6 +11,11 @@ ALL_TESTS="
 "
 NUM_NETIFS=2
 lib_dir=$(dirname "$0")
+
+# Needs a device that can set link speed and autonegotiation
+source "$lib_dir"/skip_on_veth.sh
+skip_on_veth "$@"
+
 source "$lib_dir"/../../../net/forwarding/lib.sh
 source ethtool_lib.sh
 
diff --git a/tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh b/tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh
index a7584448416e..1201130cae67 100755
--- a/tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh
+++ b/tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh
@@ -9,6 +9,11 @@ ALL_TESTS="
 
 NUM_NETIFS=2
 lib_dir=$(dirname "$0")
+
+# Needs a device that reports an extended link state
+source "$lib_dir"/skip_on_veth.sh
+skip_on_veth "$@"
+
 source "$lib_dir"/../../../net/forwarding/lib.sh
 source ethtool_lib.sh
 
diff --git a/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh b/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh
index 8f60c1685ad4..1745afe671d4 100755
--- a/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh
+++ b/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh
@@ -8,6 +8,11 @@ ALL_TESTS="
 
 NUM_NETIFS=2
 lib_dir=$(dirname "$0")
+
+# Needs a device with rmon histogram counters
+source "$lib_dir"/skip_on_veth.sh
+skip_on_veth "$@"
+
 source "$lib_dir"/../../../net/forwarding/lib.sh
 
 ETH_FCS_LEN=4
diff --git a/tools/testing/selftests/drivers/net/hw/hw_stats_l3.sh b/tools/testing/selftests/drivers/net/hw/hw_stats_l3.sh
index 67fafefc80be..460633f27f40 100755
--- a/tools/testing/selftests/drivers/net/hw/hw_stats_l3.sh
+++ b/tools/testing/selftests/drivers/net/hw/hw_stats_l3.sh
@@ -49,6 +49,11 @@ ALL_TESTS="
 "
 NUM_NETIFS=4
 lib_dir=$(dirname "$0")
+
+# Needs a device that offloads L3 statistics
+source "$lib_dir"/skip_on_veth.sh
+skip_on_veth "$@"
+
 source "$lib_dir"/../../../net/forwarding/lib.sh
 source "$lib_dir"/../../../net/forwarding/tc_common.sh
 
diff --git a/tools/testing/selftests/drivers/net/hw/hw_stats_l3_gre.sh b/tools/testing/selftests/drivers/net/hw/hw_stats_l3_gre.sh
index a94d92e1abce..abe8c09700b4 100755
--- a/tools/testing/selftests/drivers/net/hw/hw_stats_l3_gre.sh
+++ b/tools/testing/selftests/drivers/net/hw/hw_stats_l3_gre.sh
@@ -13,6 +13,11 @@ ALL_TESTS="
 "
 NUM_NETIFS=6
 lib_dir=$(dirname "$0")
+
+# Needs a device that offloads L3 statistics
+source "$lib_dir"/skip_on_veth.sh
+skip_on_veth "$@"
+
 source "$lib_dir"/../../../net/forwarding/lib.sh
 source "$lib_dir"/../../../net/forwarding/ipip_lib.sh
 source "$lib_dir"/../../../net/forwarding/tc_common.sh
diff --git a/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh b/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh
new file mode 100644
index 000000000000..b65d474ac7b2
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+# Source with lib_dir set, ahead of lib.sh, which creates the interfaces.
+
+forwarding_dir="$lib_dir"/../../../net/forwarding
+
+# forwarding.config assigns by name into the array lib.sh declares
+declare -A NETIFS
+
+if [[ -f $forwarding_dir/forwarding.config ]]; then
+	source "$forwarding_dir/forwarding.config"
+fi
+
+: "${NETIF_CREATE:=yes}"
+: "${NETIF_TYPE:=veth}"
+
+# Call before sourcing lib.sh, exiting after it leaves the veth pair behind.
+# Judges by the first interface, the one lib.sh creates the pair from,
+# found the way lib.sh finds it: keep in step with lib.sh.
+skip_on_veth()
+{
+	# lib.sh takes the command line, then forwarding.config, then the driver
+	local p1=${1:-${NETIFS[p1]-}}
+	local kind
+
+	# lib.sh skips by itself when the driver has no interfaces
+	[[ -z $p1 && -n $NETIF_FIND_DRIVER ]] && return
+	p1=${p1:-veth0}
+	if ip link show dev "$p1" &> /dev/null; then
+		kind=$(ip -j -d link show dev "$p1" | jq -r '.[].linkinfo.info_kind')
+	elif [[ $NETIF_CREATE == yes && $NETIF_TYPE == veth ]]; then
+		kind=veth # what lib.sh creates when the interface is missing
+	fi
+	[[ $kind == veth ]] || return 0
+	echo "SKIP: needs a real interface, set NETIFS in forwarding.config"
+	exit 4 # ksft_skip, lib.sh is not sourced yet
+}
-- 
2.56.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Devel] [PATCH hci-8.1 v5 1/1] selftests: drv-net-hw: skip the tests that need a real interface
  2026-10-23 19:20 ` [Devel] [PATCH hci-8.1 v5 1/1] " Eva Kurchatova
@ 2026-10-23 19:25   ` no-reply
  2026-10-26 12:19     ` Eva Kurchatova (Virtuozzo)
  0 siblings, 1 reply; 5+ messages in thread
From: no-reply @ 2026-10-23 19:25 UTC (permalink / raw)
  To: Eva Kurchatova, khorenko; +Cc: devel

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] selftests: skip_on_veth() skips explicit veth setups with misleading advice
- [Low] selftests: skip_on_veth() honours NETIF_FIND_DRIVER set only in forwarding.config
--

commit 8d2d6696991f9f7d35e072ffc95cdbdbfc7bbe48
Author: Eva Kurchatova <eva.kurchatova@virtuozzo.com>

selftests: drv-net-hw: skip the tests that need a real interface

This adds a skip_on_veth() helper. The ethtool, ethtool_extended_state,
ethtool_rmon, hw_stats_l3 and hw_stats_l3_gre tests call it before sourcing
lib.sh. The helper skips the test when the first interface is a veth, or
when lib.sh would create a veth pair.

> diff --git a/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh b/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh
> new file mode 100644
> index 0000000000000..b65d474ac7b24
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh

[ ... ]

> +skip_on_veth()
> +{
> +	# lib.sh takes the command line, then forwarding.config, then the driver
> +	local p1=${1:-${NETIFS[p1]-}}
> +	local kind
> +
> +	# lib.sh skips by itself when the driver has no interfaces
> +	[[ -z $p1 && -n $NETIF_FIND_DRIVER ]] && return

[Severity: Low]
Can this early return run the test on a veth pair that lib.sh creates?

skip_on_veth.sh sources forwarding.config at file scope, so
NETIF_FIND_DRIVER is non-empty here when only forwarding.config sets it,
and NETIFS[p1] is empty. The helper then returns without skipping.

lib.sh checks NETIF_FIND_DRIVER before it sources forwarding.config:

    : "${NETIF_FIND_DRIVER:=}"

    if [[ $NETIF_FIND_DRIVER ]]; then
        unset NETIFS
        declare -A NETIFS
        netif_find_driver
    fi

At that point the variable is empty unless it was exported in the
environment, so discovery is skipped. NETIFS keeps the default veth0..veth9.
forwarding.config is only sourced after that check, and nothing repeats it.

Then lib.sh reaches:

    if [[ "$NETIF_CREATE" = "yes" ]]; then
        create_netif
    fi

and the test runs on the auto-created veth pair and fails, which is the
failure this patch is meant to remove. The helper's comment says it should
keep in step with lib.sh, but it doesn't here. The environment and command
line cases look correct, so only the config-file-only case differs.

Should the early return only apply when NETIF_FIND_DRIVER is set the way
lib.sh will see it?

[ ... ]

> +	[[ $kind == veth ]] || return 0
> +	echo "SKIP: needs a real interface, set NETIFS in forwarding.config"
> +	exit 4 # ksft_skip, lib.sh is not sourced yet
> +}

[Severity: Low]
This isn't a functional bug, but is the SKIP message accurate in all cases
where it is printed?

The same message is printed when NETIFS[p1] or $1 already names an existing
veth. In that case the advice to set NETIFS in forwarding.config doesn't
apply, because it is already set.

Also, only p1 is checked. If p1 is a real interface and p2 or p3 is a veth,
skip_on_veth() returns 0 and the test still fails the way the patch tries to
avoid.

Could the message distinguish an explicitly named veth from the default
case, and could the other interfaces be checked as well?

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261023192121.356062-1-eva.kurchatova@virtuozzo.com?part=1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Devel] [PATCH hci-8.1 v5 1/1] selftests: drv-net-hw: skip the tests that need a real interface
  2026-10-23 19:25   ` no-reply
@ 2026-10-26 12:19     ` Eva Kurchatova (Virtuozzo)
  0 siblings, 0 replies; 5+ messages in thread
From: Eva Kurchatova (Virtuozzo) @ 2026-10-26 12:19 UTC (permalink / raw)
  To: no-reply, khorenko; +Cc: devel


On 10/23/26 22:25, no-reply@sashiko.virtuozzo.com wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Low] selftests: skip_on_veth() skips explicit veth setups with misleading advice
> - [Low] selftests: skip_on_veth() honours NETIF_FIND_DRIVER set only in forwarding.config
> --
>
> commit 8d2d6696991f9f7d35e072ffc95cdbdbfc7bbe48
> Author: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
>
> selftests: drv-net-hw: skip the tests that need a real interface
>
> This adds a skip_on_veth() helper. The ethtool, ethtool_extended_state,
> ethtool_rmon, hw_stats_l3 and hw_stats_l3_gre tests call it before sourcing
> lib.sh. The helper skips the test when the first interface is a veth, or
> when lib.sh would create a veth pair.
>
>> diff --git a/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh b/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh
>> new file mode 100644
>> index 0000000000000..b65d474ac7b24
>> --- /dev/null
>> +++ b/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh
> [ ... ]
>
>> +skip_on_veth()
>> +{
>> +	# lib.sh takes the command line, then forwarding.config, then the driver
>> +	local p1=${1:-${NETIFS[p1]-}}
>> +	local kind
>> +
>> +	# lib.sh skips by itself when the driver has no interfaces
>> +	[[ -z $p1 && -n $NETIF_FIND_DRIVER ]] && return
> [Severity: Low]
> Can this early return run the test on a veth pair that lib.sh creates?
>
> skip_on_veth.sh sources forwarding.config at file scope, so
> NETIF_FIND_DRIVER is non-empty here when only forwarding.config sets it,
> and NETIFS[p1] is empty. The helper then returns without skipping.
>
> lib.sh checks NETIF_FIND_DRIVER before it sources forwarding.config:
>
>      : "${NETIF_FIND_DRIVER:=}"
>
>      if [[ $NETIF_FIND_DRIVER ]]; then
>          unset NETIFS
>          declare -A NETIFS
>          netif_find_driver
>      fi
>
> At that point the variable is empty unless it was exported in the
> environment, so discovery is skipped. NETIFS keeps the default veth0..veth9.
> forwarding.config is only sourced after that check, and nothing repeats it.
>
> Then lib.sh reaches:
>
>      if [[ "$NETIF_CREATE" = "yes" ]]; then
>          create_netif
>      fi
>
> and the test runs on the auto-created veth pair and fails, which is the
> failure this patch is meant to remove. The helper's comment says it should
> keep in step with lib.sh, but it doesn't here. The environment and command
> line cases look correct, so only the config-file-only case differs.
>
> Should the early return only apply when NETIF_FIND_DRIVER is set the way
> lib.sh will see it?
>
> [ ... ]
>
>> +	[[ $kind == veth ]] || return 0
>> +	echo "SKIP: needs a real interface, set NETIFS in forwarding.config"
>> +	exit 4 # ksft_skip, lib.sh is not sourced yet
>> +}

It is not empty. skip_on_veth.sh sources forwarding.config into the same 
shell that sources lib.sh afterwards, so a NETIF_FIND_DRIVER set there 
is a shell variable lib.sh sees, no export needed. lib.sh then picks the 
interfaces by driver. Checked on a VM with NETIF_FIND_DRIVER=virtio_net 
only in forwarding.config: lib.sh took the virtio NIC, and the helper 
stepped aside as it should.


> [Severity: Low]
> This isn't a functional bug, but is the SKIP message accurate in all cases
> where it is printed?
>
> The same message is printed when NETIFS[p1] or $1 already names an existing
> veth. In that case the advice to set NETIFS in forwarding.config doesn't
> apply, because it is already set.

It still applies: NETIFS has to name a real interface, and here it names 
a veth. A veth named on purpose is skipped by intent, these tests cannot 
pass on one.


> Also, only p1 is checked. If p1 is a real interface and p2 or p3 is a veth,
> skip_on_veth() returns 0 and the test still fails the way the patch tries to
> avoid.


Same as in v4: lib.sh builds its pair from p1, and a real p1 with a veth 
p2 is a configuration someone wrote that way. I can change this, but 
this seems out of scope.


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Devel] [PATCH hci-8.1 v5 0/1] selftests: drv-net-hw: skip the tests that need a real interface
  2026-10-23 19:20 [Devel] [PATCH hci-8.1 v5 0/1] selftests: drv-net-hw: skip the tests that need a real interface Eva Kurchatova
  2026-10-23 19:20 ` [Devel] [PATCH hci-8.1 v5 1/1] " Eva Kurchatova
@ 2026-10-27 12:00 ` Konstantin Khorenko
  1 sibling, 0 replies; 5+ messages in thread
From: Konstantin Khorenko @ 2026-10-27 12:00 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

On Fri, 23 Oct 2026 22:20:09 +0300, Eva Kurchatova wrote:
> selftests: drv-net-hw: skip the tests that need a real interface
> 
> Changes in v5:
> - Follow lib.sh's order: command line, forwarding.config, then the
>   driver: a NETIF_FIND_DRIVER set in forwarding.config skipped a run on
>   hardware, and veths named in forwarding.config ran under
>   NETIF_FIND_DRIVER.
> - skip_on_veth() returns 0 when the test goes on, not 1.
> - Rebased.
> 
> [...]

Applied to branch-rh10-6.12.0-211.52.1.22.x.vz10-ovz, will be released in rh10-6.12.0-211.52.1.22.10.vz10, thanks!

[1/1] selftests: drv-net-hw: skip the tests that need a real interface
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/5be369a6c2b3

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-27 12:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-23 19:20 [Devel] [PATCH hci-8.1 v5 0/1] selftests: drv-net-hw: skip the tests that need a real interface Eva Kurchatova
2026-10-23 19:20 ` [Devel] [PATCH hci-8.1 v5 1/1] " Eva Kurchatova
2026-10-23 19:25   ` no-reply
2026-10-26 12:19     ` Eva Kurchatova (Virtuozzo)
2026-10-27 12:00 ` [Devel] [PATCH hci-8.1 v5 0/1] " Konstantin Khorenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.