2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS="v2reportleave_test"
7 TEST_GROUP="239.10.10.10"
8 TEST_GROUP_MAC="01:00:5e:0a:0a:0a"
13 simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
18 simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
23 simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/64
28 simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64
33 ip link add dev br0 type bridge mcast_snooping 1 mcast_querier 1
35 ip link set dev $swp1 master br0
36 ip link set dev $swp2 master br0
38 ip link set dev br0 up
39 ip link set dev $swp1 up
40 ip link set dev $swp2 up
45 ip link set dev $swp2 down
46 ip link set dev $swp1 down
73 # Always cleanup the mcast group
74 ip address del dev $h2 $TEST_GROUP/32 2>&1 1>/dev/null
82 # return 0 if the packet wasn't seen on host2_if or 1 if it was
92 # Add an ACL on `host2_if` which will tell us whether the packet
93 # was received by it or not.
94 tc qdisc add dev $host2_if ingress
95 tc filter add dev $host2_if ingress protocol ip pref 1 handle 101 \
96 flower ip_proto udp dst_mac $mac action drop
98 $MZ $host1_if -c 1 -p 64 -b $mac -A $src_ip -B $ip -t udp "dp=4096,sp=2048" -q
101 tc -j -s filter show dev $host2_if ingress \
102 | jq -e ".[] | select(.options.handle == 101) \
103 | select(.options.actions[0].stats.packets == 1)" &> /dev/null
104 if [[ $? -eq 0 ]]; then
108 tc filter del dev $host2_if ingress protocol ip pref 1 handle 101 flower
109 tc qdisc del dev $host2_if ingress
117 ip address add dev $h2 $TEST_GROUP/32 autojoin
118 check_err $? "Could not join $TEST_GROUP"
121 bridge mdb show dev br0 | grep $TEST_GROUP 1>/dev/null
122 check_err $? "IGMPv2 report didn't create mdb entry for $TEST_GROUP"
124 mcast_packet_test $TEST_GROUP_MAC 192.0.2.1 $TEST_GROUP $h1 $h2
125 check_fail $? "Traffic to $TEST_GROUP wasn't forwarded"
127 log_test "IGMPv2 report $TEST_GROUP"
130 bridge mdb show dev br0 | grep $TEST_GROUP 1>/dev/null
131 check_err $? "mdb entry for $TEST_GROUP is missing"
133 ip address del dev $h2 $TEST_GROUP/32
134 check_err $? "Could not leave $TEST_GROUP"
137 bridge mdb show dev br0 | grep $TEST_GROUP 1>/dev/null
138 check_fail $? "Leave didn't delete mdb entry for $TEST_GROUP"
140 mcast_packet_test $TEST_GROUP_MAC 192.0.2.1 $TEST_GROUP $h1 $h2
141 check_err $? "Traffic to $TEST_GROUP was forwarded without mdb entry"
143 log_test "IGMPv2 leave $TEST_GROUP"