lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1573229926-30040-10-git-send-email-yuvalav@mellanox.com>
Date:   Fri,  8 Nov 2019 18:18:45 +0200
From:   Yuval Avnery <yuvalav@...lanox.com>
To:     netdev@...r.kernel.org
Cc:     jiri@...lanox.com, saeedm@...lanox.com, leon@...nel.org,
        davem@...emloft.net, jakub.kicinski@...ronome.com,
        shuah@...nel.org, danielj@...lanox.com, parav@...lanox.com,
        andrew.gospodarek@...adcom.com, michael.chan@...adcom.com,
        Yuval Avnery <yuvalav@...lanox.com>
Subject: [PATCH net-next v2 09/10] netdevsim: Add devlink subdev sefltest for netdevsim

Test will assign hw_addr to all registered subdevs and query it.

Signed-off-by: Yuval Avnery <yuvalav@...lanox.com>
Acked-by: Jiri Pirko <jiri@...lanox.com>
---
 .../drivers/net/netdevsim/devlink.sh          | 55 ++++++++++++++++++-
 1 file changed, 53 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
index ee89cd2f5bee..15e0911df871 100755
--- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
+++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
@@ -5,12 +5,13 @@ lib_dir=$(dirname $0)/../../../net/forwarding
 
 ALL_TESTS="fw_flash_test params_test regions_test reload_test \
 	   netns_reload_test resource_test dev_info_test \
-	   empty_reporter_test dummy_reporter_test"
+	   empty_reporter_test dummy_reporter_test subdev_test"
 NUM_NETIFS=0
 source $lib_dir/lib.sh
 
 BUS_ADDR=10
 PORT_COUNT=4
+VF_COUNT=4
 DEV_NAME=netdevsim$BUS_ADDR
 SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV_NAME/net/
 DEBUGFS_DIR=/sys/kernel/debug/netdevsim/$DEV_NAME/
@@ -428,10 +429,60 @@ dummy_reporter_test()
 	log_test "dummy reporter test"
 }
 
+subdev_attr_get()
+{
+	local handle=$1
+	local name=$2
+
+	cmd_jq "devlink subdev show $handle -j" '.[][].'$name
+}
+
+subdev_objects_get()
+{
+	local handle=$1
+
+	cmd_jq "devlink subdev show -j" \
+	       '.[] | keys[] | select(contains("'$handle'"))'
+}
+
+subdev_attr_set()
+{
+	local handle=$1
+	local name=$2
+	local value=$3
+
+	devlink subdev set $handle $name $value
+}
+
+subdev_test()
+{
+	RET=0
+
+	local subdevs=`subdev_objects_get $DL_HANDLE`
+	local num_subdevs=`echo $subdevs | wc -w`
+	[ $num_subdevs == $VF_COUNT ]
+	check_err $? "Expected $VF_COUNT subdevs but got $num_subdevs"
+
+	i=1
+	for subdev in $subdevs
+	do
+		local hw_addr=`printf "10:22:33:44:55:%02x" $i`
+
+		subdev_attr_set "$subdev" hw_addr $hw_addr
+		check_err $? "Failed to set hw_addr value"
+		value=$(subdev_attr_get $subdev hw_addr)
+		check_err $? "Failed to get hw_addr attr value"
+		[ "$value" == "$hw_addr" ]
+		check_err $? "Unexpected hw_addr attr value $value != $hw_addr"
+		i=$(($i+1))
+	done
+	log_test "subdev test"
+}
+
 setup_prepare()
 {
 	modprobe netdevsim
-	echo "$BUS_ADDR $PORT_COUNT" > /sys/bus/netdevsim/new_device
+	echo "$BUS_ADDR $PORT_COUNT $VF_COUNT" > /sys/bus/netdevsim/new_device
 	while [ ! -d $SYSFS_NET_DIR ] ; do :; done
 }
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ