Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / net / forwarding / bridge_mdb_host.sh
blobb1ba6876dd86509d8589c656e62d6b283bf5f648
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Verify that adding host mdb entries work as intended for all types of
5 # multicast filters: ipv4, ipv6, and mac
7 ALL_TESTS="mdb_add_del_test"
8 NUM_NETIFS=2
10 TEST_GROUP_IP4="225.1.2.3"
11 TEST_GROUP_IP6="ff02::42"
12 TEST_GROUP_MAC="01:00:01:c0:ff:ee"
14 source lib.sh
16 h1_create()
18 simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
21 h1_destroy()
23 simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
26 switch_create()
28 # Enable multicast filtering
29 ip link add dev br0 type bridge mcast_snooping 1
31 ip link set dev $swp1 master br0
33 ip link set dev br0 up
34 ip link set dev $swp1 up
37 switch_destroy()
39 ip link set dev $swp1 down
40 ip link del dev br0
43 setup_prepare()
45 h1=${NETIFS[p1]}
46 swp1=${NETIFS[p2]}
48 vrf_prepare
50 h1_create
51 switch_create
54 cleanup()
56 pre_cleanup
58 switch_destroy
59 h1_destroy
61 vrf_cleanup
64 do_mdb_add_del()
66 local group=$1
67 local flag=$2
69 RET=0
70 bridge mdb add dev br0 port br0 grp $group $flag 2>/dev/null
71 check_err $? "Failed adding $group to br0, port br0"
73 if [ -z "$flag" ]; then
74 flag="temp"
77 bridge mdb show dev br0 | grep $group | grep -q $flag 2>/dev/null
78 check_err $? "$group not added with $flag flag"
80 bridge mdb del dev br0 port br0 grp $group 2>/dev/null
81 check_err $? "Failed deleting $group from br0, port br0"
83 bridge mdb show dev br0 | grep -q $group >/dev/null
84 check_err_fail 1 $? "$group still in mdb after delete"
86 log_test "MDB add/del group $group to bridge port br0"
89 mdb_add_del_test()
91 do_mdb_add_del $TEST_GROUP_MAC permanent
92 do_mdb_add_del $TEST_GROUP_IP4
93 do_mdb_add_del $TEST_GROUP_IP6
96 trap cleanup EXIT
98 setup_prepare
99 setup_wait
101 tests_run
103 exit $EXIT_STATUS