WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / devlink_trap.sh
blob89b55e946eed11fab30f63c767efe828776b1fcf
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
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.
8 lib_dir=$(dirname $0)/../../../net/forwarding
10 ALL_TESTS="
11 dev_del_test
13 NUM_NETIFS=4
14 source $lib_dir/tc_common.sh
15 source $lib_dir/lib.sh
16 source $lib_dir/devlink_lib.sh
18 h1_create()
20 simple_if_init $h1
23 h1_destroy()
25 simple_if_fini $h1
28 h2_create()
30 simple_if_init $h2
33 h2_destroy()
35 simple_if_fini $h2
38 switch_create()
40 ip link add dev br0 type bridge vlan_filtering 1 mcast_snooping 0
42 ip link set dev $swp1 master br0
43 ip link set dev $swp2 master br0
45 ip link set dev br0 up
46 ip link set dev $swp1 up
47 ip link set dev $swp2 up
50 switch_destroy()
52 ip link set dev $swp2 down
53 ip link set dev $swp1 down
55 ip link del dev br0
58 setup_prepare()
60 h1=${NETIFS[p1]}
61 swp1=${NETIFS[p2]}
63 swp2=${NETIFS[p3]}
64 h2=${NETIFS[p4]}
66 vrf_prepare
68 h1_create
69 h2_create
71 switch_create
74 cleanup()
76 pre_cleanup
78 switch_destroy
80 h2_destroy
81 h1_destroy
83 vrf_cleanup
86 dev_del_test()
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
94 $MZ $h1 -c 0 -p 100 -a $smac -b bcast -t ip -q &
95 mz_pid=$!
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
102 for i in $(seq 1 $num_iter); do
103 log_info "Iteration $i / $num_iter"
105 devlink_trap_action_set $trap_name "trap"
106 sleep 1
108 devlink_reload
109 # Allow netdevices to be re-created following the reload
110 sleep 20
112 cleanup
113 setup_prepare
114 setup_wait
115 done
117 log_test "Device delete"
119 kill $mz_pid && wait $mz_pid &> /dev/null
122 trap cleanup EXIT
124 setup_prepare
125 setup_wait
127 tests_run
129 exit $EXIT_STATUS