brintos

brintos / linux-shallow public Read only

0
0
Text · 1.9 KiB · 89b55e9 Raw
130 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03#4# Test generic devlink-trap functionality over mlxsw. These tests are not5# specific to a single trap, but do not check the devlink-trap common6# infrastructure either.7 8lib_dir=$(dirname $0)/../../../net/forwarding9 10ALL_TESTS="11	dev_del_test12"13NUM_NETIFS=414source $lib_dir/tc_common.sh15source $lib_dir/lib.sh16source $lib_dir/devlink_lib.sh17 18h1_create()19{20	simple_if_init $h121}22 23h1_destroy()24{25	simple_if_fini $h126}27 28h2_create()29{30	simple_if_init $h231}32 33h2_destroy()34{35	simple_if_fini $h236}37 38switch_create()39{40	ip link add dev br0 type bridge vlan_filtering 1 mcast_snooping 041 42	ip link set dev $swp1 master br043	ip link set dev $swp2 master br044 45	ip link set dev br0 up46	ip link set dev $swp1 up47	ip link set dev $swp2 up48}49 50switch_destroy()51{52	ip link set dev $swp2 down53	ip link set dev $swp1 down54 55	ip link del dev br056}57 58setup_prepare()59{60	h1=${NETIFS[p1]}61	swp1=${NETIFS[p2]}62 63	swp2=${NETIFS[p3]}64	h2=${NETIFS[p4]}65 66	vrf_prepare67 68	h1_create69	h2_create70 71	switch_create72}73 74cleanup()75{76	pre_cleanup77 78	switch_destroy79 80	h2_destroy81	h1_destroy82 83	vrf_cleanup84}85 86dev_del_test()87{88	local trap_name="source_mac_is_multicast"89	local smac=01:02:03:04:05:0690	local num_iter=591	local mz_pid92	local i93 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 a98	# port while packets are trapped from it. This is done by reloading the99	# the driver while the 'ingress_smac_mc_drop' trap is triggered.100	RET=0101 102	for i in $(seq 1 $num_iter); do103		log_info "Iteration $i / $num_iter"104 105		devlink_trap_action_set $trap_name "trap"106		sleep 1107 108		devlink_reload109		# Allow netdevices to be re-created following the reload110		sleep 20111 112		cleanup113		setup_prepare114		setup_wait115	done116 117	log_test "Device delete"118 119	kill $mz_pid && wait $mz_pid &> /dev/null120}121 122trap cleanup EXIT123 124setup_prepare125setup_wait126 127tests_run128 129exit $EXIT_STATUS130