Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: forwarding: add ability to assemble NETIFS array by driver name

Allow driver tests to work without specifying the netdevice names.
Introduce a possibility to search for available netdevices according to
set driver name. Allow test to specify the name by setting
NETIF_FIND_DRIVER variable.

Note that user overrides this either by passing netdevice names on the
command line or by declaring NETIFS array in custom forwarding.config
configuration file.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Jiri Pirko and committed by
Paolo Abeni
41ad836e 96a8326d

+37
+37
tools/testing/selftests/net/forwarding/lib.sh
··· 84 84 # e.g. a low-power board. 85 85 : "${KSFT_MACHINE_SLOW:=no}" 86 86 87 + ############################################################################## 88 + # Find netifs by test-specified driver name 89 + 90 + driver_name_get() 91 + { 92 + local dev=$1; shift 93 + local driver_path="/sys/class/net/$dev/device/driver" 94 + 95 + if [[ -L $driver_path ]]; then 96 + basename `realpath $driver_path` 97 + fi 98 + } 99 + 100 + netif_find_driver() 101 + { 102 + local ifnames=`ip -j link show | jq -r ".[].ifname"` 103 + local count=0 104 + 105 + for ifname in $ifnames 106 + do 107 + local driver_name=`driver_name_get $ifname` 108 + if [[ ! -z $driver_name && $driver_name == $NETIF_FIND_DRIVER ]]; then 109 + count=$((count + 1)) 110 + NETIFS[p$count]="$ifname" 111 + fi 112 + done 113 + } 114 + 115 + # Whether to find netdevice according to the driver speficied by the importer 116 + : "${NETIF_FIND_DRIVER:=}" 117 + 118 + if [[ $NETIF_FIND_DRIVER ]]; then 119 + unset NETIFS 120 + declare -A NETIFS 121 + netif_find_driver 122 + fi 123 + 87 124 net_forwarding_dir=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")") 88 125 89 126 if [[ -f $net_forwarding_dir/forwarding.config ]]; then