2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS
="v2reportleave_test v3include_test v3inc_allow_test v3inc_is_include_test \
5 v3inc_is_exclude_test v3inc_to_exclude_test v3exc_allow_test v3exc_is_include_test \
6 v3exc_is_exclude_test v3exc_to_exclude_test v3inc_block_test v3exc_block_test \
7 v3exc_timeout_test v3star_ex_auto_add_test"
10 TEST_GROUP
="239.10.10.10"
11 TEST_GROUP_MAC
="01:00:5e:0a:0a:0a"
14 ALL_MAC
="01:00:5e:00:00:01"
16 # IGMPv3 is_in report: grp 239.10.10.10 is_include 192.0.2.1,192.0.2.2,192.0.2.3
17 MZPKT_IS_INC
="22:00:9d:de:00:00:00:01:01:00:00:03:ef:0a:0a:0a:c0:00:02:01:c0:00:02:02:c0:00:02:03"
18 # IGMPv3 is_in report: grp 239.10.10.10 is_include 192.0.2.10,192.0.2.11,192.0.2.12
19 MZPKT_IS_INC2
="22:00:9d:c3:00:00:00:01:01:00:00:03:ef:0a:0a:0a:c0:00:02:0a:c0:00:02:0b:c0:00:02:0c"
20 # IGMPv3 is_in report: grp 239.10.10.10 is_include 192.0.2.20,192.0.2.30
21 MZPKT_IS_INC3
="22:00:5f:b4:00:00:00:01:01:00:00:02:ef:0a:0a:0a:c0:00:02:14:c0:00:02:1e"
22 # IGMPv3 allow report: grp 239.10.10.10 allow 192.0.2.10,192.0.2.11,192.0.2.12
23 MZPKT_ALLOW
="22:00:99:c3:00:00:00:01:05:00:00:03:ef:0a:0a:0a:c0:00:02:0a:c0:00:02:0b:c0:00:02:0c"
24 # IGMPv3 allow report: grp 239.10.10.10 allow 192.0.2.20,192.0.2.30
25 MZPKT_ALLOW2
="22:00:5b:b4:00:00:00:01:05:00:00:02:ef:0a:0a:0a:c0:00:02:14:c0:00:02:1e"
26 # IGMPv3 is_ex report: grp 239.10.10.10 is_exclude 192.0.2.1,192.0.2.2,192.0.2.20,192.0.2.21
27 MZPKT_IS_EXC
="22:00:da:b6:00:00:00:01:02:00:00:04:ef:0a:0a:0a:c0:00:02:01:c0:00:02:02:c0:00:02:14:c0:00:02:15"
28 # IGMPv3 is_ex report: grp 239.10.10.10 is_exclude 192.0.2.20,192.0.2.30
29 MZPKT_IS_EXC2
="22:00:5e:b4:00:00:00:01:02:00:00:02:ef:0a:0a:0a:c0:00:02:14:c0:00:02:1e"
30 # IGMPv3 to_ex report: grp 239.10.10.10 to_exclude 192.0.2.1,192.0.2.20,192.0.2.30
31 MZPKT_TO_EXC
="22:00:9a:b1:00:00:00:01:04:00:00:03:ef:0a:0a:0a:c0:00:02:01:c0:00:02:14:c0:00:02:1e"
32 # IGMPv3 block report: grp 239.10.10.10 block 192.0.2.1,192.0.2.20,192.0.2.30
33 MZPKT_BLOCK
="22:00:98:b1:00:00:00:01:06:00:00:03:ef:0a:0a:0a:c0:00:02:01:c0:00:02:14:c0:00:02:1e"
39 simple_if_init
$h1 192.0.2.1/24 2001:db8
:1::1/64
44 simple_if_fini
$h1 192.0.2.1/24 2001:db8
:1::1/64
49 simple_if_init
$h2 192.0.2.2/24 2001:db8
:1::2/64
54 simple_if_fini
$h2 192.0.2.2/24 2001:db8
:1::2/64
59 ip link add dev br0
type bridge mcast_snooping
1 mcast_querier
1
61 ip link
set dev
$swp1 master br0
62 ip link
set dev
$swp2 master br0
64 ip link
set dev br0 up
65 ip link
set dev
$swp1 up
66 ip link
set dev
$swp2 up
71 ip link
set dev
$swp2 down
72 ip link
set dev
$swp1 down
108 ip address add dev
$h2 $TEST_GROUP/32 autojoin
109 check_err $?
"Could not join $TEST_GROUP"
112 bridge mdb show dev br0 |
grep $TEST_GROUP 1>/dev
/null
113 check_err $?
"IGMPv2 report didn't create mdb entry for $TEST_GROUP"
115 mcast_packet_test
$TEST_GROUP_MAC 192.0.2.1 $TEST_GROUP $h1 $h2
116 check_fail $?
"Traffic to $TEST_GROUP wasn't forwarded"
118 log_test
"IGMPv2 report $TEST_GROUP"
121 bridge mdb show dev br0 |
grep $TEST_GROUP 1>/dev
/null
122 check_err $?
"mdb entry for $TEST_GROUP is missing"
124 ip address del dev
$h2 $TEST_GROUP/32
125 check_err $?
"Could not leave $TEST_GROUP"
128 bridge mdb show dev br0 |
grep $TEST_GROUP 1>/dev
/null
129 check_fail $?
"Leave didn't delete mdb entry for $TEST_GROUP"
131 mcast_packet_test
$TEST_GROUP_MAC 192.0.2.1 $TEST_GROUP $h1 $h2
132 check_err $?
"Traffic to $TEST_GROUP was forwarded without mdb entry"
134 log_test
"IGMPv2 leave $TEST_GROUP"
142 local X
=("192.0.2.1" "192.0.2.2" "192.0.2.3")
144 ip link
set dev br0
type bridge mcast_igmp_version
3
145 check_err $?
"Could not change bridge IGMP version to 3"
147 $MZ $host1_if -b $mac -c 1 -B $group -t ip
"proto=2,p=$MZPKT_IS_INC" -q
149 bridge
-j -d -s mdb show dev br0 \
150 | jq
-e ".[].mdb[] | \
151 select(.grp == \"$TEST_GROUP\" and .source_list != null)" &>/dev
/null
152 check_err $?
"Missing *,G entry with source list"
153 bridge
-j -d -s mdb show dev br0 \
154 | jq
-e ".[].mdb[] | \
155 select(.grp == \"$TEST_GROUP\" and \
156 .source_list != null and .filter_mode == \"include\")" &>/dev
/null
157 check_err $?
"Wrong *,G entry filter mode"
158 brmcast_check_sg_entries
"is_include" "${X[@]}"
167 local X
=("192.0.2.1" "192.0.2.2")
168 local Y
=("192.0.2.20" "192.0.2.21")
170 v3include_prepare
$host1_if $mac $group
172 $MZ $host1_if -c 1 -b $mac -B $group -t ip
"proto=2,p=$MZPKT_IS_EXC" -q
174 bridge
-j -d -s mdb show dev br0 \
175 | jq
-e ".[].mdb[] | \
176 select(.grp == \"$TEST_GROUP\" and \
177 .source_list != null and .filter_mode == \"exclude\")" &>/dev
/null
178 check_err $?
"Wrong *,G entry filter mode"
180 brmcast_check_sg_entries
"is_exclude" "${X[@]}" "${Y[@]}"
182 brmcast_check_sg_state
0 "${X[@]}"
183 brmcast_check_sg_state
1 "${Y[@]}"
185 bridge
-j -d -s mdb show dev br0 \
186 | jq
-e ".[].mdb[] | \
187 select(.grp == \"$TEST_GROUP\" and \
188 .source_list != null and
189 .source_list[].address == \"192.0.2.3\")" &>/dev
/null
190 check_fail $?
"Wrong *,G entry source list, 192.0.2.3 entry still exists"
198 bridge mdb del dev br0 port
$port grp
$group
199 ip link
set dev br0
type bridge mcast_igmp_version
2
205 local X
=("192.0.2.1" "192.0.2.2" "192.0.2.3")
207 v3include_prepare
$h1 $ALL_MAC $ALL_GROUP
209 brmcast_check_sg_state
0 "${X[@]}"
211 brmcast_check_sg_fwding
1 "${X[@]}"
212 brmcast_check_sg_fwding
0 "192.0.2.100"
214 log_test
"IGMPv3 report $TEST_GROUP is_include"
216 v3cleanup
$swp1 $TEST_GROUP
222 local X
=("192.0.2.10" "192.0.2.11" "192.0.2.12")
224 v3include_prepare
$h1 $ALL_MAC $ALL_GROUP
226 $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_ALLOW" -q
228 brmcast_check_sg_entries
"allow" "${X[@]}"
230 brmcast_check_sg_state
0 "${X[@]}"
232 brmcast_check_sg_fwding
1 "${X[@]}"
233 brmcast_check_sg_fwding
0 "192.0.2.100"
235 log_test
"IGMPv3 report $TEST_GROUP include -> allow"
237 v3cleanup
$swp1 $TEST_GROUP
240 v3inc_is_include_test
()
243 local X
=("192.0.2.10" "192.0.2.11" "192.0.2.12")
245 v3include_prepare
$h1 $ALL_MAC $ALL_GROUP
247 $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_IS_INC2" -q
249 brmcast_check_sg_entries
"is_include" "${X[@]}"
251 brmcast_check_sg_state
0 "${X[@]}"
253 brmcast_check_sg_fwding
1 "${X[@]}"
254 brmcast_check_sg_fwding
0 "192.0.2.100"
256 log_test
"IGMPv3 report $TEST_GROUP include -> is_include"
258 v3cleanup
$swp1 $TEST_GROUP
261 v3inc_is_exclude_test
()
265 v3exclude_prepare
$h1 $ALL_MAC $ALL_GROUP
267 brmcast_check_sg_fwding
1 "${X[@]}" 192.0.2.100
268 brmcast_check_sg_fwding
0 "${Y[@]}"
270 log_test
"IGMPv3 report $TEST_GROUP include -> is_exclude"
272 v3cleanup
$swp1 $TEST_GROUP
275 v3inc_to_exclude_test
()
278 local X
=("192.0.2.1")
279 local Y
=("192.0.2.20" "192.0.2.30")
281 v3include_prepare
$h1 $ALL_MAC $ALL_GROUP
283 ip link
set dev br0
type bridge mcast_last_member_interval
500
284 check_err $?
"Could not change mcast_last_member_interval to 5s"
286 $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_TO_EXC" -q
288 bridge
-j -d -s mdb show dev br0 \
289 | jq
-e ".[].mdb[] | \
290 select(.grp == \"$TEST_GROUP\" and \
291 .source_list != null and .filter_mode == \"exclude\")" &>/dev
/null
292 check_err $?
"Wrong *,G entry filter mode"
294 brmcast_check_sg_entries
"to_exclude" "${X[@]}" "${Y[@]}"
296 brmcast_check_sg_state
0 "${X[@]}"
297 brmcast_check_sg_state
1 "${Y[@]}"
299 bridge
-j -d -s mdb show dev br0 \
300 | jq
-e ".[].mdb[] | \
301 select(.grp == \"$TEST_GROUP\" and \
302 .source_list != null and
303 .source_list[].address == \"192.0.2.2\")" &>/dev
/null
304 check_fail $?
"Wrong *,G entry source list, 192.0.2.2 entry still exists"
305 bridge
-j -d -s mdb show dev br0 \
306 | jq
-e ".[].mdb[] | \
307 select(.grp == \"$TEST_GROUP\" and \
308 .source_list != null and
309 .source_list[].address == \"192.0.2.21\")" &>/dev
/null
310 check_fail $?
"Wrong *,G entry source list, 192.0.2.21 entry still exists"
312 brmcast_check_sg_fwding
1 "${X[@]}" 192.0.2.100
313 brmcast_check_sg_fwding
0 "${Y[@]}"
315 log_test
"IGMPv3 report $TEST_GROUP include -> to_exclude"
317 ip link
set dev br0
type bridge mcast_last_member_interval
100
319 v3cleanup
$swp1 $TEST_GROUP
325 local X
=("192.0.2.1" "192.0.2.2" "192.0.2.20" "192.0.2.30")
326 local Y
=("192.0.2.21")
328 v3exclude_prepare
$h1 $ALL_MAC $ALL_GROUP
330 $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_ALLOW2" -q
332 brmcast_check_sg_entries
"allow" "${X[@]}" "${Y[@]}"
334 brmcast_check_sg_state
0 "${X[@]}"
335 brmcast_check_sg_state
1 "${Y[@]}"
337 brmcast_check_sg_fwding
1 "${X[@]}" 192.0.2.100
338 brmcast_check_sg_fwding
0 "${Y[@]}"
340 log_test
"IGMPv3 report $TEST_GROUP exclude -> allow"
342 v3cleanup
$swp1 $TEST_GROUP
345 v3exc_is_include_test
()
348 local X
=("192.0.2.1" "192.0.2.2" "192.0.2.20" "192.0.2.30")
349 local Y
=("192.0.2.21")
351 v3exclude_prepare
$h1 $ALL_MAC $ALL_GROUP
353 $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_IS_INC3" -q
355 brmcast_check_sg_entries
"is_include" "${X[@]}" "${Y[@]}"
357 brmcast_check_sg_state
0 "${X[@]}"
358 brmcast_check_sg_state
1 "${Y[@]}"
360 brmcast_check_sg_fwding
1 "${X[@]}" 192.0.2.100
361 brmcast_check_sg_fwding
0 "${Y[@]}"
363 log_test
"IGMPv3 report $TEST_GROUP exclude -> is_include"
365 v3cleanup
$swp1 $TEST_GROUP
368 v3exc_is_exclude_test
()
371 local X
=("192.0.2.30")
372 local Y
=("192.0.2.20")
374 v3exclude_prepare
$h1 $ALL_MAC $ALL_GROUP
376 $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_IS_EXC2" -q
378 brmcast_check_sg_entries
"is_exclude" "${X[@]}" "${Y[@]}"
380 brmcast_check_sg_state
0 "${X[@]}"
381 brmcast_check_sg_state
1 "${Y[@]}"
383 brmcast_check_sg_fwding
1 "${X[@]}" 192.0.2.100
384 brmcast_check_sg_fwding
0 "${Y[@]}"
386 log_test
"IGMPv3 report $TEST_GROUP exclude -> is_exclude"
388 v3cleanup
$swp1 $TEST_GROUP
391 v3exc_to_exclude_test
()
394 local X
=("192.0.2.1" "192.0.2.30")
395 local Y
=("192.0.2.20")
397 v3exclude_prepare
$h1 $ALL_MAC $ALL_GROUP
399 ip link
set dev br0
type bridge mcast_last_member_interval
500
400 check_err $?
"Could not change mcast_last_member_interval to 5s"
402 $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_TO_EXC" -q
404 brmcast_check_sg_entries
"to_exclude" "${X[@]}" "${Y[@]}"
406 brmcast_check_sg_state
0 "${X[@]}"
407 brmcast_check_sg_state
1 "${Y[@]}"
409 brmcast_check_sg_fwding
1 "${X[@]}" 192.0.2.100
410 brmcast_check_sg_fwding
0 "${Y[@]}"
412 log_test
"IGMPv3 report $TEST_GROUP exclude -> to_exclude"
414 ip link
set dev br0
type bridge mcast_last_member_interval
100
416 v3cleanup
$swp1 $TEST_GROUP
422 local X
=("192.0.2.2" "192.0.2.3")
424 v3include_prepare
$h1 $ALL_MAC $ALL_GROUP
426 $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_BLOCK" -q
427 # make sure the lowered timers have expired (by default 2 seconds)
429 brmcast_check_sg_entries
"block" "${X[@]}"
431 brmcast_check_sg_state
0 "${X[@]}"
433 bridge
-j -d -s mdb show dev br0 \
434 | jq
-e ".[].mdb[] | \
435 select(.grp == \"$TEST_GROUP\" and \
436 .source_list != null and
437 .source_list[].address == \"192.0.2.1\")" &>/dev
/null
438 check_fail $?
"Wrong *,G entry source list, 192.0.2.1 entry still exists"
440 brmcast_check_sg_fwding
1 "${X[@]}"
441 brmcast_check_sg_fwding
0 "192.0.2.100"
443 log_test
"IGMPv3 report $TEST_GROUP include -> block"
445 v3cleanup
$swp1 $TEST_GROUP
451 local X
=("192.0.2.1" "192.0.2.2" "192.0.2.30")
452 local Y
=("192.0.2.20" "192.0.2.21")
454 v3exclude_prepare
$h1 $ALL_MAC $ALL_GROUP
456 ip link
set dev br0
type bridge mcast_last_member_interval
500
457 check_err $?
"Could not change mcast_last_member_interval to 5s"
459 $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_BLOCK" -q
461 brmcast_check_sg_entries
"block" "${X[@]}" "${Y[@]}"
463 brmcast_check_sg_state
0 "${X[@]}"
464 brmcast_check_sg_state
1 "${Y[@]}"
466 brmcast_check_sg_fwding
1 "${X[@]}" 192.0.2.100
467 brmcast_check_sg_fwding
0 "${Y[@]}"
469 log_test
"IGMPv3 report $TEST_GROUP exclude -> block"
471 ip link
set dev br0
type bridge mcast_last_member_interval
100
473 v3cleanup
$swp1 $TEST_GROUP
479 local X
=("192.0.2.20" "192.0.2.30")
481 # GMI should be 5 seconds
482 ip link
set dev br0
type bridge mcast_query_interval
100 \
483 mcast_query_response_interval
100 \
484 mcast_membership_interval
500
486 v3exclude_prepare
$h1 $ALL_MAC $ALL_GROUP
487 ip link
set dev br0
type bridge mcast_query_interval
500 \
488 mcast_query_response_interval
500 \
489 mcast_membership_interval
1500
491 $MZ $h1 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_ALLOW2" -q
493 bridge
-j -d -s mdb show dev br0 \
494 | jq
-e ".[].mdb[] | \
495 select(.grp == \"$TEST_GROUP\" and \
496 .source_list != null and .filter_mode == \"include\")" &>/dev
/null
497 check_err $?
"Wrong *,G entry filter mode"
499 bridge
-j -d -s mdb show dev br0 \
500 | jq
-e ".[].mdb[] | \
501 select(.grp == \"$TEST_GROUP\" and \
502 .source_list != null and
503 .source_list[].address == \"192.0.2.1\")" &>/dev
/null
504 check_fail $?
"Wrong *,G entry source list, 192.0.2.1 entry still exists"
505 bridge
-j -d -s mdb show dev br0 \
506 | jq
-e ".[].mdb[] | \
507 select(.grp == \"$TEST_GROUP\" and \
508 .source_list != null and
509 .source_list[].address == \"192.0.2.2\")" &>/dev
/null
510 check_fail $?
"Wrong *,G entry source list, 192.0.2.2 entry still exists"
512 brmcast_check_sg_entries
"allow" "${X[@]}"
514 brmcast_check_sg_state
0 "${X[@]}"
516 brmcast_check_sg_fwding
1 "${X[@]}"
517 brmcast_check_sg_fwding
0 192.0.2.100
519 log_test
"IGMPv3 group $TEST_GROUP exclude timeout"
521 ip link
set dev br0
type bridge mcast_query_interval
12500 \
522 mcast_query_response_interval
1000 \
523 mcast_membership_interval
26000
525 v3cleanup
$swp1 $TEST_GROUP
528 v3star_ex_auto_add_test
()
532 v3exclude_prepare
$h1 $ALL_MAC $ALL_GROUP
534 $MZ $h2 -c 1 -b $ALL_MAC -B $ALL_GROUP -t ip
"proto=2,p=$MZPKT_IS_INC" -q
536 bridge
-j -d -s mdb show dev br0 \
537 | jq
-e ".[].mdb[] | \
538 select(.grp == \"$TEST_GROUP\" and .src == \"192.0.2.3\" and \
539 .port == \"$swp1\")" &>/dev
/null
540 check_err $?
"S,G entry for *,G port doesn't exist"
542 bridge
-j -d -s mdb show dev br0 \
543 | jq
-e ".[].mdb[] | \
544 select(.grp == \"$TEST_GROUP\" and .src == \"192.0.2.3\" and \
545 .port == \"$swp1\" and \
546 .flags[] == \"added_by_star_ex\")" &>/dev
/null
547 check_err $?
"Auto-added S,G entry doesn't have added_by_star_ex flag"
549 brmcast_check_sg_fwding
1 192.0.2.3
551 log_test
"IGMPv3 S,G port entry automatic add to a *,G port"
553 v3cleanup
$swp1 $TEST_GROUP
554 v3cleanup
$swp2 $TEST_GROUP