~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/netdevsim/devlink_in_netns.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 lib_dir=$(dirname $0)/../../../net/forwarding
  5 
  6 ALL_TESTS="check_devlink_test check_ports_test"
  7 NUM_NETIFS=0
  8 source $lib_dir/lib.sh
  9 
 10 BUS_ADDR=10
 11 PORT_COUNT=4
 12 DEV_NAME=netdevsim$BUS_ADDR
 13 SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV_NAME/net/
 14 DL_HANDLE=netdevsim/$DEV_NAME
 15 NETNS_NAME=testns1
 16 
 17 port_netdev_get()
 18 {
 19         local port_index=$1
 20 
 21         cmd_jq "devlink -N $NETNS_NAME port show -j" \
 22                ".[][\"$DL_HANDLE/$port_index\"].netdev" "-e"
 23 }
 24 
 25 check_ports_test()
 26 {
 27         RET=0
 28 
 29         for i in $(seq 0 $(expr $PORT_COUNT - 1)); do
 30                 netdev_name=$(port_netdev_get $i)
 31                 check_err $? "Failed to get netdev name for port $DL_HANDLE/$i"
 32                 ip -n $NETNS_NAME link show $netdev_name &> /dev/null
 33                 check_err $? "Failed to find netdev $netdev_name"
 34         done
 35 
 36         log_test "check ports test"
 37 }
 38 
 39 check_devlink_test()
 40 {
 41         RET=0
 42 
 43         devlink -N $NETNS_NAME dev show $DL_HANDLE &> /dev/null
 44         check_err $? "Failed to show devlink instance"
 45 
 46         log_test "check devlink test"
 47 }
 48 
 49 setup_prepare()
 50 {
 51         modprobe netdevsim
 52         ip netns add $NETNS_NAME
 53         ip netns exec $NETNS_NAME \
 54                 echo "$BUS_ADDR $PORT_COUNT" > /sys/bus/netdevsim/new_device
 55         while [ ! -d $SYSFS_NET_DIR ] ; do :; done
 56 }
 57 
 58 cleanup()
 59 {
 60         pre_cleanup
 61         echo "$BUS_ADDR" > /sys/bus/netdevsim/del_device
 62         ip netns del $NETNS_NAME
 63         modprobe -r netdevsim
 64 }
 65 
 66 trap cleanup EXIT
 67 
 68 setup_prepare
 69 
 70 tests_run
 71 
 72 exit $EXIT_STATUS

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php