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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/mlxsw/devlink_trap.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 # Test generic devlink-trap functionality over mlxsw. These tests are not
  5 # specific to a single trap, but do not check the devlink-trap common
  6 # infrastructure either.
  7 
  8 lib_dir=$(dirname $0)/../../../net/forwarding
  9 
 10 ALL_TESTS="
 11         dev_del_test
 12 "
 13 NUM_NETIFS=4
 14 source $lib_dir/tc_common.sh
 15 source $lib_dir/lib.sh
 16 source $lib_dir/devlink_lib.sh
 17 
 18 h1_create()
 19 {
 20         simple_if_init $h1
 21 }
 22 
 23 h1_destroy()
 24 {
 25         simple_if_fini $h1
 26 }
 27 
 28 h2_create()
 29 {
 30         simple_if_init $h2
 31 }
 32 
 33 h2_destroy()
 34 {
 35         simple_if_fini $h2
 36 }
 37 
 38 switch_create()
 39 {
 40         ip link add dev br0 type bridge vlan_filtering 1 mcast_snooping 0
 41 
 42         ip link set dev $swp1 master br0
 43         ip link set dev $swp2 master br0
 44 
 45         ip link set dev br0 up
 46         ip link set dev $swp1 up
 47         ip link set dev $swp2 up
 48 }
 49 
 50 switch_destroy()
 51 {
 52         ip link set dev $swp2 down
 53         ip link set dev $swp1 down
 54 
 55         ip link del dev br0
 56 }
 57 
 58 setup_prepare()
 59 {
 60         h1=${NETIFS[p1]}
 61         swp1=${NETIFS[p2]}
 62 
 63         swp2=${NETIFS[p3]}
 64         h2=${NETIFS[p4]}
 65 
 66         vrf_prepare
 67 
 68         h1_create
 69         h2_create
 70 
 71         switch_create
 72 }
 73 
 74 cleanup()
 75 {
 76         pre_cleanup
 77 
 78         switch_destroy
 79 
 80         h2_destroy
 81         h1_destroy
 82 
 83         vrf_cleanup
 84 }
 85 
 86 dev_del_test()
 87 {
 88         local trap_name="source_mac_is_multicast"
 89         local smac=01:02:03:04:05:06
 90         local num_iter=5
 91         local mz_pid
 92         local i
 93 
 94         $MZ $h1 -c 0 -p 100 -a $smac -b bcast -t ip -q &
 95         mz_pid=$!
 96 
 97         # The purpose of this test is to make sure we correctly dismantle a
 98         # port while packets are trapped from it. This is done by reloading the
 99         # the driver while the 'ingress_smac_mc_drop' trap is triggered.
100         RET=0
101 
102         for i in $(seq 1 $num_iter); do
103                 log_info "Iteration $i / $num_iter"
104 
105                 devlink_trap_action_set $trap_name "trap"
106                 sleep 1
107 
108                 devlink_reload
109                 # Allow netdevices to be re-created following the reload
110                 sleep 20
111 
112                 cleanup
113                 setup_prepare
114                 setup_wait
115         done
116 
117         log_test "Device delete"
118 
119         kill $mz_pid && wait $mz_pid &> /dev/null
120 }
121 
122 trap cleanup EXIT
123 
124 setup_prepare
125 setup_wait
126 
127 tests_run
128 
129 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