Path: blob/master/tools/testing/selftests/drivers/net/mlxsw/devlink_trap.sh
26292 views
#!/bin/bash1# SPDX-License-Identifier: GPL-2.02#3# Test generic devlink-trap functionality over mlxsw. These tests are not4# specific to a single trap, but do not check the devlink-trap common5# infrastructure either.67lib_dir=$(dirname $0)/../../../net/forwarding89ALL_TESTS="10dev_del_test11"12NUM_NETIFS=413source $lib_dir/tc_common.sh14source $lib_dir/lib.sh15source $lib_dir/devlink_lib.sh1617h1_create()18{19simple_if_init $h120}2122h1_destroy()23{24simple_if_fini $h125}2627h2_create()28{29simple_if_init $h230}3132h2_destroy()33{34simple_if_fini $h235}3637switch_create()38{39ip link add dev br0 type bridge vlan_filtering 1 mcast_snooping 04041ip link set dev $swp1 master br042ip link set dev $swp2 master br04344ip link set dev br0 up45ip link set dev $swp1 up46ip link set dev $swp2 up47}4849switch_destroy()50{51ip link set dev $swp2 down52ip link set dev $swp1 down5354ip link del dev br055}5657setup_prepare()58{59h1=${NETIFS[p1]}60swp1=${NETIFS[p2]}6162swp2=${NETIFS[p3]}63h2=${NETIFS[p4]}6465vrf_prepare6667h1_create68h2_create6970switch_create71}7273cleanup()74{75pre_cleanup7677switch_destroy7879h2_destroy80h1_destroy8182vrf_cleanup83}8485dev_del_test()86{87local trap_name="source_mac_is_multicast"88local smac=01:02:03:04:05:0689local num_iter=590local mz_pid91local i9293$MZ $h1 -c 0 -p 100 -a $smac -b bcast -t ip -q &94mz_pid=$!9596# The purpose of this test is to make sure we correctly dismantle a97# port while packets are trapped from it. This is done by reloading the98# the driver while the 'ingress_smac_mc_drop' trap is triggered.99RET=0100101for i in $(seq 1 $num_iter); do102log_info "Iteration $i / $num_iter"103104devlink_trap_action_set $trap_name "trap"105sleep 1106107devlink_reload108# Allow netdevices to be re-created following the reload109sleep 20110111cleanup112setup_prepare113setup_wait114done115116log_test "Device delete"117118kill_process $mz_pid119}120121trap cleanup EXIT122123setup_prepare124setup_wait125126tests_run127128exit $EXIT_STATUS129130131