[PATCH net-next 2/3] selftests: ethtool: Drop the unused old_netdevs variable

Maxime Chevallier posted 3 patches 3 months, 1 week ago
There is a newer version of this series
[PATCH net-next 2/3] selftests: ethtool: Drop the unused old_netdevs variable
Posted by Maxime Chevallier 3 months, 1 week ago
old_netdevs is unused in ethtool-common.sh. Only the UDP tunnels test
uses that variable, but it maintains it locally.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 .../testing/selftests/drivers/net/netdevsim/ethtool-common.sh | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh b/tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh
index 80160579e0cc..d9c7a3d397a9 100644
--- a/tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh
+++ b/tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh
@@ -43,13 +43,11 @@ function check {
 }
 
 function make_netdev {
-    # Make a netdevsim
-    old_netdevs=$(ls /sys/class/net)
-
     if ! $(lsmod | grep -q netdevsim); then
 	modprobe netdevsim
     fi
 
+    # Make a netdevsim
     echo $NSIM_ID $@ > /sys/bus/netdevsim/new_device
     udevadm settle
     # get new device name
-- 
2.49.0
Re: [PATCH net-next 2/3] selftests: ethtool: Drop the unused old_netdevs variable
Posted by Vladimir Oltean 3 months ago
On Wed, Jul 02, 2025 at 10:28:04AM +0200, Maxime Chevallier wrote:
> old_netdevs is unused in ethtool-common.sh. Only the UDP tunnels test
> uses that variable, but it maintains it locally.
> 
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> ---

The story seems to be told by commits
fbb8531e58bd ("selftests: extract common functions in ethtool-common.sh") and
9e48ee80ac4e ("selftests: refactor get_netdev_name function").

make_netdev() returns the name of the newly created netdevsim interface.
It used to be implemented by comparing the "before" and "after" of
"ls /sys/class/net". But the name can instead be retrieved from /sys/bus/netdevsim,
and "ls /sys/class/net" is a left-over that was never fully cleaned up.

Meanwhile, udp_tunnel_nic.sh still uses the old and racy method of
finding the netdevsim name, based on the before/after comparison.
It seems like a case of not converging the entire netdevsim test suite
towards the same solution: ethtool-common.sh modified the logic in Nov
2020, udp_tunnel_nic.sh had the logic since Jul 2020.