2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS
="mldv2include_test mldv2inc_allow_test mldv2inc_is_include_test mldv2inc_is_exclude_test \
5 mldv2inc_to_exclude_test mldv2exc_allow_test mldv2exc_is_include_test \
6 mldv2exc_is_exclude_test mldv2exc_to_exclude_test mldv2inc_block_test \
7 mldv2exc_block_test mldv2exc_timeout_test mldv2star_ex_auto_add_test"
11 TEST_GROUP_MAC
="33:33:00:00:00:cc"
13 # MLDv2 is_in report: grp ff02::cc is_include 2001:db8:1::1,2001:db8:1::2,2001:db8:1::3
14 MZPKT_IS_INC
="33:33:00:00:00:01:fe:54:00:04:5e:ba:86:dd:60:0a:2d:ae:00:54:00:01:fe:80:00:\
15 00:00:00:00:00:fc:54:00:ff:fe:04:5e:ba:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:01:3a:\
16 00:05:02:00:00:00:00:8f:00:8e:d9:00:00:00:01:01:00:00:03:ff:02:00:00:00:00:00:00:00:00:00:\
17 00:00:00:00:cc:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:01:20:01:0d:b8:00:01:00:00:00:\
18 00:00:00:00:00:00:02:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:03"
19 # MLDv2 is_in report: grp ff02::cc is_include 2001:db8:1::10,2001:db8:1::11,2001:db8:1::12
20 MZPKT_IS_INC2
="33:33:00:00:00:01:fe:54:00:04:5e:ba:86:dd:60:0a:2d:ae:00:54:00:01:fe:80:00:\
21 00:00:00:00:00:fc:54:00:ff:fe:04:5e:ba:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:01:3a:00:\
22 05:02:00:00:00:00:8f:00:8e:ac:00:00:00:01:01:00:00:03:ff:02:00:00:00:00:00:00:00:00:00:00:00:\
23 00:00:cc:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:10:20:01:0d:b8:00:01:00:00:00:00:00:00:\
24 00:00:00:11:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:12"
25 # MLDv2 is_in report: grp ff02::cc is_include 2001:db8:1::20,2001:db8:1::30
26 MZPKT_IS_INC3
="33:33:00:00:00:01:fe:54:00:04:5e:ba:86:dd:60:0a:2d:ae:00:44:00:01:fe:80:00:00:00:\
27 00:00:00:fc:54:00:ff:fe:04:5e:ba:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:01:3a:00:05:02:00:\
28 00:00:00:8f:00:bc:5a:00:00:00:01:01:00:00:02:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:cc:20:\
29 01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:20:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:30"
30 # MLDv2 allow report: grp ff02::cc allow 2001:db8:1::10,2001:db8:1::11,2001:db8:1::12
31 MZPKT_ALLOW
="33:33:00:00:00:01:fe:54:00:04:5e:ba:86:dd:60:0a:2d:ae:00:54:00:01:fe:80:00:00:\
32 00:00:00:00:fc:54:00:ff:fe:04:5e:ba:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:01:3a:00:05:\
33 02:00:00:00:00:8f:00:8a:ac:00:00:00:01:05:00:00:03:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:\
34 00:cc:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:10:20:01:0d:b8:00:01:00:00:00:00:00:00:00:\
35 00:00:11:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:12"
36 # MLDv2 allow report: grp ff02::cc allow 2001:db8:1::20,2001:db8:1::30
37 MZPKT_ALLOW2
="33:33:00:00:00:01:fe:54:00:04:5e:ba:86:dd:60:0a:2d:ae:00:44:00:01:fe:80:00:00:00:\
38 00:00:00:fc:54:00:ff:fe:04:5e:ba:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:01:3a:00:05:02:00:\
39 00:00:00:8f:00:b8:5a:00:00:00:01:05:00:00:02:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:cc:20:\
40 01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:20:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:30"
41 # MLDv2 is_ex report: grp ff02::cc is_exclude 2001:db8:1::1,2001:db8:1::2,2001:db8:1::20,2001:db8:1::21
42 MZPKT_IS_EXC
="33:33:00:00:00:01:fe:54:00:04:5e:ba:86:dd:60:0a:2d:ae:00:64:00:01:fe:80:00:00:00:\
43 00:00:00:fc:54:00:ff:fe:04:5e:ba:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:01:3a:00:05:02:00:\
44 00:00:00:8f:00:5f:d0:00:00:00:01:02:00:00:04:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:cc:20:\
45 01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:01:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:02:20:\
46 01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:20:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:21"
47 # MLDv2 is_ex report: grp ff02::cc is_exclude 2001:db8:1::20,2001:db8:1::30
48 MZPKT_IS_EXC2
="33:33:00:00:00:01:fe:54:00:04:5e:ba:86:dd:60:0a:2d:ae:00:44:00:01:fe:80:00:00:00:\
49 00:00:00:fc:54:00:ff:fe:04:5e:ba:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:01:3a:00:05:02:00:\
50 00:00:00:8f:00:bb:5a:00:00:00:01:02:00:00:02:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:cc:20:\
51 01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:20:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:30"
52 # MLDv2 to_ex report: grp ff02::cc to_exclude 2001:db8:1::1,2001:db8:1::20,2001:db8:1::30
53 MZPKT_TO_EXC
="33:33:00:00:00:01:fe:54:00:04:5e:ba:86:dd:60:0a:2d:ae:00:54:00:01:fe:80:00:00:00:\
54 00:00:00:fc:54:00:ff:fe:04:5e:ba:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:01:3a:00:05:02:00:\
55 00:00:00:8f:00:8b:8e:00:00:00:01:04:00:00:03:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:cc:20:\
56 01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:01:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:20:20:\
57 01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:30"
58 # MLDv2 block report: grp ff02::cc block 2001:db8:1::1,2001:db8:1::20,2001:db8:1::30
59 MZPKT_BLOCK
="33:33:00:00:00:01:fe:54:00:04:5e:ba:86:dd:60:0a:2d:ae:00:54:00:01:fe:80:00:00:00:00:\
60 00:00:fc:54:00:ff:fe:04:5e:ba:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:01:3a:00:05:02:00:00:\
61 00:00:8f:00:89:8e:00:00:00:01:06:00:00:03:ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:cc:20:01:\
62 0d:b8:00:01:00:00:00:00:00:00:00:00:00:01:20:01:0d:b8:00:01:00:00:00:00:00:00:00:00:00:20:20:01:\
63 0d:b8:00:01:00:00:00:00:00:00:00:00:00:30"
69 simple_if_init
$h1 2001:db8
:1::1/64
74 simple_if_fini
$h1 2001:db8
:1::1/64
79 simple_if_init
$h2 2001:db8
:1::2/64
84 simple_if_fini
$h2 2001:db8
:1::2/64
89 ip link add dev br0
type bridge mcast_snooping
1 mcast_query_response_interval
100 \
90 mcast_mld_version
2 mcast_startup_query_interval
300 \
93 ip link
set dev
$swp1 master br0
94 ip link
set dev
$swp2 master br0
96 ip link
set dev br0 up
97 ip link
set dev
$swp1 up
98 ip link
set dev
$swp2 up
100 # make sure a query has been generated
106 ip link
set dev
$swp2 down
107 ip link
set dev
$swp1 down
140 mldv2include_prepare
()
143 local X
=("2001:db8:1::1" "2001:db8:1::2" "2001:db8:1::3")
145 ip link
set dev br0
type bridge mcast_mld_version
2
146 check_err $?
"Could not change bridge MLD version to 2"
148 $MZ $host1_if $MZPKT_IS_INC -q
150 bridge
-j -d -s mdb show dev br0 \
151 | jq
-e ".[].mdb[] | \
152 select(.grp == \"$TEST_GROUP\" and .source_list != null)" &>/dev
/null
153 check_err $?
"Missing *,G entry with source list"
154 bridge
-j -d -s mdb show dev br0 \
155 | jq
-e ".[].mdb[] | \
156 select(.grp == \"$TEST_GROUP\" and \
157 .source_list != null and .filter_mode == \"include\")" &>/dev
/null
158 check_err $?
"Wrong *,G entry filter mode"
159 brmcast_check_sg_entries
"is_include" "${X[@]}"
162 mldv2exclude_prepare
()
168 local X
=("2001:db8:1::1" "2001:db8:1::2")
169 local Y
=("2001:db8:1::20" "2001:db8:1::21")
171 mldv2include_prepare
$h1
173 $MZ $host1_if -c 1 $MZPKT_IS_EXC -q
175 bridge
-j -d -s mdb show dev br0 \
176 | jq
-e ".[].mdb[] | \
177 select(.grp == \"$TEST_GROUP\" and \
178 .source_list != null and .filter_mode == \"exclude\")" &>/dev
/null
179 check_err $?
"Wrong *,G entry filter mode"
181 brmcast_check_sg_entries
"is_exclude" "${X[@]}" "${Y[@]}"
183 brmcast_check_sg_state
0 "${X[@]}"
184 brmcast_check_sg_state
1 "${Y[@]}"
186 bridge
-j -d -s mdb show dev br0 \
187 | jq
-e ".[].mdb[] | \
188 select(.grp == \"$TEST_GROUP\" and \
189 .source_list != null and
190 .source_list[].address == \"2001:db8:1::3\")" &>/dev
/null
191 check_fail $?
"Wrong *,G entry source list, 2001:db8:1::3 entry still exists"
198 bridge mdb del dev br0 port
$port grp
$TEST_GROUP
199 ip link
set dev br0
type bridge mcast_mld_version
1
205 local X
=("2001:db8:1::1" "2001:db8:1::2" "2001:db8:1::3")
207 mldv2include_prepare
$h1
209 brmcast_check_sg_state
0 "${X[@]}"
211 brmcast_check_sg_fwding
1 "${X[@]}"
212 brmcast_check_sg_fwding
0 "2001:db8:1::100"
214 log_test
"MLDv2 report $TEST_GROUP is_include"
219 mldv2inc_allow_test
()
222 local X
=("2001:db8:1::10" "2001:db8:1::11" "2001:db8:1::12")
224 mldv2include_prepare
$h1
226 $MZ $h1 -c 1 $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 "2001:db8:1::100"
235 log_test
"MLDv2 report $TEST_GROUP include -> allow"
240 mldv2inc_is_include_test
()
243 local X
=("2001:db8:1::10" "2001:db8:1::11" "2001:db8:1::12")
245 mldv2include_prepare
$h1
247 $MZ $h1 -c 1 $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 "2001:db8:1::100"
256 log_test
"MLDv2 report $TEST_GROUP include -> is_include"
261 mldv2inc_is_exclude_test
()
265 mldv2exclude_prepare
$h1
267 brmcast_check_sg_fwding
1 "${X[@]}" 2001:db8
:1::100
268 brmcast_check_sg_fwding
0 "${Y[@]}"
270 log_test
"MLDv2 report $TEST_GROUP include -> is_exclude"
275 mldv2inc_to_exclude_test
()
278 local X
=("2001:db8:1::1")
279 local Y
=("2001:db8:1::20" "2001:db8:1::30")
281 mldv2include_prepare
$h1
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 $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 == \"2001:db8:1::2\")" &>/dev
/null
304 check_fail $?
"Wrong *,G entry source list, 2001:db8:1::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 == \"2001:db8:1::21\")" &>/dev
/null
310 check_fail $?
"Wrong *,G entry source list, 2001:db8:1::21 entry still exists"
312 brmcast_check_sg_fwding
1 "${X[@]}" 2001:db8
:1::100
313 brmcast_check_sg_fwding
0 "${Y[@]}"
315 log_test
"MLDv2 report $TEST_GROUP include -> to_exclude"
317 ip link
set dev br0
type bridge mcast_last_member_interval
100
322 mldv2exc_allow_test
()
325 local X
=("2001:db8:1::1" "2001:db8:1::2" "2001:db8:1::20" "2001:db8:1::30")
326 local Y
=("2001:db8:1::21")
328 mldv2exclude_prepare
$h1
330 $MZ $h1 -c 1 $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[@]}" 2001:db8
:1::100
338 brmcast_check_sg_fwding
0 "${Y[@]}"
340 log_test
"MLDv2 report $TEST_GROUP exclude -> allow"
345 mldv2exc_is_include_test
()
348 local X
=("2001:db8:1::1" "2001:db8:1::2" "2001:db8:1::20" "2001:db8:1::30")
349 local Y
=("2001:db8:1::21")
351 mldv2exclude_prepare
$h1
353 $MZ $h1 -c 1 $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[@]}" 2001:db8
:1::100
361 brmcast_check_sg_fwding
0 "${Y[@]}"
363 log_test
"MLDv2 report $TEST_GROUP exclude -> is_include"
368 mldv2exc_is_exclude_test
()
371 local X
=("2001:db8:1::30")
372 local Y
=("2001:db8:1::20")
374 mldv2exclude_prepare
$h1
376 $MZ $h1 -c 1 $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[@]}" 2001:db8
:1::100
384 brmcast_check_sg_fwding
0 "${Y[@]}"
386 log_test
"MLDv2 report $TEST_GROUP exclude -> is_exclude"
391 mldv2exc_to_exclude_test
()
394 local X
=("2001:db8:1::1" "2001:db8:1::30")
395 local Y
=("2001:db8:1::20")
397 mldv2exclude_prepare
$h1
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 $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[@]}" 2001:db8
:1::100
410 brmcast_check_sg_fwding
0 "${Y[@]}"
412 log_test
"MLDv2 report $TEST_GROUP exclude -> to_exclude"
414 ip link
set dev br0
type bridge mcast_last_member_interval
100
419 mldv2inc_block_test
()
422 local X
=("2001:db8:1::2" "2001:db8:1::3")
424 mldv2include_prepare
$h1
426 $MZ $h1 -c 1 $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 == \"2001:db8:1::1\")" &>/dev
/null
438 check_fail $?
"Wrong *,G entry source list, 2001:db8:1::1 entry still exists"
440 brmcast_check_sg_fwding
1 "${X[@]}"
441 brmcast_check_sg_fwding
0 2001:db8
:1::100
443 log_test
"MLDv2 report $TEST_GROUP include -> block"
448 mldv2exc_block_test
()
451 local X
=("2001:db8:1::1" "2001:db8:1::2" "2001:db8:1::30")
452 local Y
=("2001:db8:1::20" "2001:db8:1::21")
454 mldv2exclude_prepare
$h1
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 $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[@]}" 2001:db8
:1::100
467 brmcast_check_sg_fwding
0 "${Y[@]}"
469 log_test
"MLDv2 report $TEST_GROUP exclude -> block"
471 ip link
set dev br0
type bridge mcast_last_member_interval
100
476 mldv2exc_timeout_test
()
479 local X
=("2001:db8:1::20" "2001:db8:1::30")
481 # GMI should be 3 seconds
482 ip link
set dev br0
type bridge mcast_query_interval
100 mcast_query_response_interval
100
484 mldv2exclude_prepare
$h1
485 ip link
set dev br0
type bridge mcast_query_interval
500 mcast_query_response_interval
500
486 $MZ $h1 -c 1 $MZPKT_ALLOW2 -q
488 bridge
-j -d -s mdb show dev br0 \
489 | jq
-e ".[].mdb[] | \
490 select(.grp == \"$TEST_GROUP\" and \
491 .source_list != null and .filter_mode == \"include\")" &>/dev
/null
492 check_err $?
"Wrong *,G entry filter mode"
494 bridge
-j -d -s mdb show dev br0 \
495 | jq
-e ".[].mdb[] | \
496 select(.grp == \"$TEST_GROUP\" and \
497 .source_list != null and
498 .source_list[].address == \"2001:db8:1::1\")" &>/dev
/null
499 check_fail $?
"Wrong *,G entry source list, 2001:db8:1::1 entry still exists"
500 bridge
-j -d -s mdb show dev br0 \
501 | jq
-e ".[].mdb[] | \
502 select(.grp == \"$TEST_GROUP\" and \
503 .source_list != null and
504 .source_list[].address == \"2001:db8:1::2\")" &>/dev
/null
505 check_fail $?
"Wrong *,G entry source list, 2001:db8:1::2 entry still exists"
507 brmcast_check_sg_entries
"allow" "${X[@]}"
509 brmcast_check_sg_state
0 "${X[@]}"
511 brmcast_check_sg_fwding
1 "${X[@]}"
512 brmcast_check_sg_fwding
0 2001:db8
:1::100
514 log_test
"MLDv2 group $TEST_GROUP exclude timeout"
516 ip link
set dev br0
type bridge mcast_query_interval
12500 \
517 mcast_query_response_interval
1000
522 mldv2star_ex_auto_add_test
()
526 mldv2exclude_prepare
$h1
528 $MZ $h2 -c 1 $MZPKT_IS_INC -q
530 bridge
-j -d -s mdb show dev br0 \
531 | jq
-e ".[].mdb[] | \
532 select(.grp == \"$TEST_GROUP\" and .src == \"2001:db8:1::3\" and \
533 .port == \"$swp1\")" &>/dev
/null
534 check_err $?
"S,G entry for *,G port doesn't exist"
536 bridge
-j -d -s mdb show dev br0 \
537 | jq
-e ".[].mdb[] | \
538 select(.grp == \"$TEST_GROUP\" and .src == \"2001:db8:1::3\" and \
539 .port == \"$swp1\" and \
540 .flags[] == \"added_by_star_ex\")" &>/dev
/null
541 check_err $?
"Auto-added S,G entry doesn't have added_by_star_ex flag"
543 brmcast_check_sg_fwding
1 2001:db8
:1::3
545 log_test
"MLDv2 S,G port entry automatic add to a *,G port"