Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
8lib_dir=$(dirname $0)/../../../net/forwarding
9
10ALL_TESTS="
11 dev_del_test
12"
13NUM_NETIFS=4
14source $lib_dir/tc_common.sh
15source $lib_dir/lib.sh
16source $lib_dir/devlink_lib.sh
17
18h1_create()
19{
20 simple_if_init $h1
21}
22
23h1_destroy()
24{
25 simple_if_fini $h1
26}
27
28h2_create()
29{
30 simple_if_init $h2
31}
32
33h2_destroy()
34{
35 simple_if_fini $h2
36}
37
38switch_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
50switch_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
58setup_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
74cleanup()
75{
76 pre_cleanup
77
78 switch_destroy
79
80 h2_destroy
81 h1_destroy
82
83 vrf_cleanup
84}
85
86dev_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
122trap cleanup EXIT
123
124setup_prepare
125setup_wait
126
127tests_run
128
129exit $EXIT_STATUS