2 # SPDX-License-Identifier: GPL-2.0
4 # +-----------------------+ +------------------------+
5 # | H1 (vrf) | | H2 (vrf) |
6 # | + $h1.10 | | + $h2.10 |
7 # | | 192.0.2.1/28 | | | 192.0.2.2/28 |
8 # | | 2001:db8:1::1/64 | | | 2001:db8:1::2/64 |
10 # | | + $h1.20 | | | + $h2.20 |
11 # | \ | 198.51.100.1/24 | | \ | 198.51.100.2/24 |
12 # | \ | 2001:db8:2::1/64 | | \ | 2001:db8:2::2/64 |
15 # +----|------------------+ +----|-------------------+
17 # +----|--------------------------------------------------|-------------------+
19 # | +--|--------------------------------------------------|-----------------+ |
20 # | | + $swp1 BR0 (802.1q) + $swp2 | |
21 # | | vid 10 vid 10 | |
22 # | | vid 20 vid 20 | |
24 # | +-----------------------------------------------------------------------+ |
25 # +---------------------------------------------------------------------------+
40 vlan_create $h1 10 v$h1 192.0.2.1/28 2001:db8:1::1/64
41 vlan_create $h1 20 v$h1 198.51.100.1/24 2001:db8:2::1/64
54 vlan_create $h2 10 v$h2 192.0.2.2/28
55 vlan_create $h2 20 v$h2 198.51.100.2/24
67 log_info "802.1d tests"
69 ip link add name br0 type bridge vlan_filtering 0 \
71 mcast_igmp_version 3 mcast_mld_version 2
72 ip link set dev br0 up
74 ip link set dev $swp1 master br0
75 ip link set dev $swp1 up
76 bridge link set dev $swp1 fastleave on
78 ip link set dev $swp2 master br0
79 ip link set dev $swp2 up
84 local br_flags=$1; shift
86 log_info "802.1q $br_flags${br_flags:+ }tests"
88 ip link add name br0 type bridge vlan_filtering 1 vlan_default_pvid 0 \
89 mcast_snooping 1 $br_flags \
90 mcast_igmp_version 3 mcast_mld_version 2
91 bridge vlan add vid 10 dev br0 self
92 bridge vlan add vid 20 dev br0 self
93 ip link set dev br0 up
95 ip link set dev $swp1 master br0
96 ip link set dev $swp1 up
97 bridge link set dev $swp1 fastleave on
98 bridge vlan add vid 10 dev $swp1
99 bridge vlan add vid 20 dev $swp1
101 ip link set dev $swp2 master br0
102 ip link set dev $swp2 up
103 bridge vlan add vid 10 dev $swp2
104 bridge vlan add vid 20 dev $swp2
107 switch_create_8021qvs()
109 switch_create_8021q "mcast_vlan_snooping 1"
110 bridge vlan global set dev br0 vid 10 mcast_igmp_version 3
111 bridge vlan global set dev br0 vid 10 mcast_mld_version 2
112 bridge vlan global set dev br0 vid 20 mcast_igmp_version 3
113 bridge vlan global set dev br0 vid 20 mcast_mld_version 2
118 ip link set dev $swp2 down
119 ip link set dev $swp2 nomaster
121 ip link set dev $swp1 down
122 ip link set dev $swp1 nomaster
124 ip link set dev br0 down
147 switch_destroy 2>/dev/null
158 local IPstr=$(echo ${IPs[@]} | tr '[:space:]' , | sed 's/,$//')
160 echo ${IPstr:+source_list }${IPstr}
166 local locus=$1; shift
168 local state=$1; shift
171 local source_list=$(cfg_src_list ${IPs[@]})
173 # Everything besides `bridge mdb' uses the "dev X vid Y" syntax,
174 # so we use it here as well and convert.
175 local br_locus=$(echo "$locus" | sed 's/^dev /port /')
177 bridge mdb $op dev br0 $br_locus grp $GRP $state \
178 filter_mode include $source_list
184 local locus=$1; shift
185 local state=$1; shift
187 local grp=${1:-1}; shift
189 local GRP=239.1.1.${grp}
190 local IPs=$(seq -f 192.0.2.%g 1 $((n - 1)))
191 cfg_group_op "$op" "$locus" "$GRP" "$state" ${IPs[@]}
196 cfg4_entries_op add "$@"
201 cfg4_entries_op del "$@"
207 local locus=$1; shift
208 local state=$1; shift
210 local grp=${1:-1}; shift
212 local GRP=ff0e::${grp}
213 local IPs=$(printf "2001:db8:1::%x\n" $(seq 1 $((n - 1))))
214 cfg_group_op "$op" "$locus" "$GRP" "$state" ${IPs[@]}
219 cfg6_entries_op add "$@"
224 cfg6_entries_op del "$@"
229 local dev_kw=$1; shift
231 local vid_kw=$1; shift
234 echo "$h1.${vid:-10}"
239 local dev_kw=$1; shift
247 local locus=$1; shift
248 local state=$1; shift
250 local grp=${1:-1}; shift
252 local IPs=$(seq -f 192.0.2.%g 1 $((n - 1)))
253 local peer=$(locus_dev_peer $locus)
254 local GRP=239.1.1.${grp}
255 $MZ $peer -c 1 -A 192.0.2.1 -B $GRP \
256 -t ip proto=2,p=$(igmpv3_is_in_get $GRP $IPs) -q
259 local nn=$(bridge mdb show dev br0 | grep $GRP | wc -l)
261 echo mcast_max_groups > /dev/stderr
268 local locus=$1; shift
269 local state=$1; shift
271 local grp=${1:-1}; shift
273 local peer=$(locus_dev_peer $locus)
274 local GRP=239.1.1.${grp}
275 $MZ $peer -c 1 -A 192.0.2.1 -B 224.0.0.2 \
276 -t ip proto=2,p=$(igmpv2_leave_get $GRP) -q
278 ! bridge mdb show dev br0 | grep -q $GRP
283 local locus=$1; shift
284 local state=$1; shift
286 local grp=${1:-1}; shift
288 local IPs=$(printf "2001:db8:1::%x\n" $(seq 1 $((n - 1))))
289 local peer=$(locus_dev_peer $locus)
291 local GRP=ff0e::${grp}
292 local p=$(mldv2_is_in_get $SIP $GRP $IPs)
293 $MZ -6 $peer -c 1 -A $SIP -B $GRP -t ip hop=1,next=0,p="$p" -q
296 local nn=$(bridge mdb show dev br0 | grep $GRP | wc -l)
298 echo mcast_max_groups > /dev/stderr
305 local locus=$1; shift
306 local state=$1; shift
308 local grp=${1:-1}; shift
310 local peer=$(locus_dev_peer $locus)
312 local GRP=ff0e::${grp}
313 local p=$(mldv1_done_get $SIP $GRP)
314 $MZ -6 $peer -c 1 -A $SIP -B $GRP -t ip hop=1,next=0,p="$p" -q
316 ! bridge mdb show dev br0 | grep -q $GRP
319 bridge_maxgroups_errmsg_check_cfg()
322 local needle=$1; shift
324 echo "$msg" | grep -q mcast_max_groups
325 check_err $? "Adding MDB entries failed for the wrong reason: $msg"
328 bridge_maxgroups_errmsg_check_cfg4()
330 bridge_maxgroups_errmsg_check_cfg "$@"
333 bridge_maxgroups_errmsg_check_cfg6()
335 bridge_maxgroups_errmsg_check_cfg "$@"
338 bridge_maxgroups_errmsg_check_ctl4()
343 bridge_maxgroups_errmsg_check_ctl6()
348 bridge_port_ngroups_get()
350 local locus=$1; shift
352 bridge -j -d link show $locus |
353 jq '.[].mcast_n_groups'
356 bridge_port_maxgroups_get()
358 local locus=$1; shift
360 bridge -j -d link show $locus |
361 jq '.[].mcast_max_groups'
364 bridge_port_maxgroups_set()
366 local locus=$1; shift
369 bridge link set dev $(locus_dev $locus) mcast_max_groups $max
372 bridge_port_vlan_ngroups_get()
374 local locus=$1; shift
376 bridge -j -d vlan show $locus |
377 jq '.[].vlans[].mcast_n_groups'
380 bridge_port_vlan_maxgroups_get()
382 local locus=$1; shift
384 bridge -j -d vlan show $locus |
385 jq '.[].vlans[].mcast_max_groups'
388 bridge_port_vlan_maxgroups_set()
390 local locus=$1; shift
393 bridge vlan set $locus mcast_max_groups $max
396 test_ngroups_reporting()
399 local context=$1; shift
400 local locus=$1; shift
404 local n0=$(bridge_${context}_ngroups_get "$locus")
405 ${CFG}_entries_add "$locus" temp 5
406 check_err $? "Couldn't add MDB entries"
407 local n1=$(bridge_${context}_ngroups_get "$locus")
410 check_err $? "Number of groups was $n0, now is $n1, but $((n0 + 5)) expected"
412 ${CFG}_entries_del "$locus" temp 5
413 check_err $? "Couldn't delete MDB entries"
414 local n2=$(bridge_${context}_ngroups_get "$locus")
417 check_err $? "Number of groups was $n0, now is $n2, but should be back to $n0"
419 log_test "$CFG: $context: ngroups reporting"
422 test_8021d_ngroups_reporting_cfg4()
424 test_ngroups_reporting cfg4 port "dev $swp1"
427 test_8021d_ngroups_reporting_ctl4()
429 test_ngroups_reporting ctl4 port "dev $swp1"
432 test_8021d_ngroups_reporting_cfg6()
434 test_ngroups_reporting cfg6 port "dev $swp1"
437 test_8021d_ngroups_reporting_ctl6()
439 test_ngroups_reporting ctl6 port "dev $swp1"
442 test_8021q_ngroups_reporting_cfg4()
444 test_ngroups_reporting cfg4 port "dev $swp1 vid 10"
447 test_8021q_ngroups_reporting_ctl4()
449 test_ngroups_reporting ctl4 port "dev $swp1 vid 10"
452 test_8021q_ngroups_reporting_cfg6()
454 test_ngroups_reporting cfg6 port "dev $swp1 vid 10"
457 test_8021q_ngroups_reporting_ctl6()
459 test_ngroups_reporting ctl6 port "dev $swp1 vid 10"
462 test_8021qvs_ngroups_reporting_cfg4()
464 test_ngroups_reporting cfg4 port_vlan "dev $swp1 vid 10"
467 test_8021qvs_ngroups_reporting_ctl4()
469 test_ngroups_reporting ctl4 port_vlan "dev $swp1 vid 10"
472 test_8021qvs_ngroups_reporting_cfg6()
474 test_ngroups_reporting cfg6 port_vlan "dev $swp1 vid 10"
477 test_8021qvs_ngroups_reporting_ctl6()
479 test_ngroups_reporting ctl6 port_vlan "dev $swp1 vid 10"
482 test_ngroups_cross_vlan()
486 local locus1="dev $swp1 vid 10"
487 local locus2="dev $swp1 vid 20"
491 local n10=$(bridge_port_vlan_ngroups_get "$locus1")
492 local n20=$(bridge_port_vlan_ngroups_get "$locus2")
493 ${CFG}_entries_add "$locus1" temp 5 111
494 check_err $? "Couldn't add MDB entries to VLAN 10"
495 local n11=$(bridge_port_vlan_ngroups_get "$locus1")
496 local n21=$(bridge_port_vlan_ngroups_get "$locus2")
499 check_err $? "Number of groups at VLAN 10 was $n10, now is $n11, but 5 entries added on VLAN 10, $((n10 + 5)) expected"
502 check_err $? "Number of groups at VLAN 20 was $n20, now is $n21, but no change expected on VLAN 20"
504 ${CFG}_entries_add "$locus2" temp 5 112
505 check_err $? "Couldn't add MDB entries to VLAN 20"
506 local n12=$(bridge_port_vlan_ngroups_get "$locus1")
507 local n22=$(bridge_port_vlan_ngroups_get "$locus2")
510 check_err $? "Number of groups at VLAN 10 was $n11, now is $n12, but no change expected on VLAN 10"
513 check_err $? "Number of groups at VLAN 20 was $n21, now is $n22, but 5 entries added on VLAN 20, $((n21 + 5)) expected"
515 ${CFG}_entries_del "$locus1" temp 5 111
516 check_err $? "Couldn't delete MDB entries from VLAN 10"
517 ${CFG}_entries_del "$locus2" temp 5 112
518 check_err $? "Couldn't delete MDB entries from VLAN 20"
519 local n13=$(bridge_port_vlan_ngroups_get "$locus1")
520 local n23=$(bridge_port_vlan_ngroups_get "$locus2")
523 check_err $? "Number of groups at VLAN 10 was $n10, now is $n13, but should be back to $n10"
526 check_err $? "Number of groups at VLAN 20 was $n20, now is $n23, but should be back to $n20"
528 log_test "$CFG: port_vlan: isolation of port and per-VLAN ngroups"
531 test_8021qvs_ngroups_cross_vlan_cfg4()
533 test_ngroups_cross_vlan cfg4
536 test_8021qvs_ngroups_cross_vlan_ctl4()
538 test_ngroups_cross_vlan ctl4
541 test_8021qvs_ngroups_cross_vlan_cfg6()
543 test_ngroups_cross_vlan cfg6
546 test_8021qvs_ngroups_cross_vlan_ctl6()
548 test_ngroups_cross_vlan ctl6
551 test_maxgroups_zero()
554 local context=$1; shift
555 local locus=$1; shift
560 max=$(bridge_${context}_maxgroups_get "$locus")
562 check_err $? "Max groups on $locus should be 0, but $max reported"
564 bridge_${context}_maxgroups_set "$locus" 100
565 check_err $? "Failed to set max to 100"
566 max=$(bridge_${context}_maxgroups_get "$locus")
568 check_err $? "Max groups expected to be 100, but $max reported"
570 bridge_${context}_maxgroups_set "$locus" 0
571 check_err $? "Couldn't set maximum to 0"
573 # Test that setting 0 explicitly still serves as infinity.
574 ${CFG}_entries_add "$locus" temp 5
575 check_err $? "Adding 5 MDB entries failed but should have passed"
576 ${CFG}_entries_del "$locus" temp 5
577 check_err $? "Couldn't delete MDB entries"
579 log_test "$CFG: $context maxgroups: reporting and treatment of 0"
582 test_8021d_maxgroups_zero_cfg4()
584 test_maxgroups_zero cfg4 port "dev $swp1"
587 test_8021d_maxgroups_zero_ctl4()
589 test_maxgroups_zero ctl4 port "dev $swp1"
592 test_8021d_maxgroups_zero_cfg6()
594 test_maxgroups_zero cfg6 port "dev $swp1"
597 test_8021d_maxgroups_zero_ctl6()
599 test_maxgroups_zero ctl6 port "dev $swp1"
602 test_8021q_maxgroups_zero_cfg4()
604 test_maxgroups_zero cfg4 port "dev $swp1 vid 10"
607 test_8021q_maxgroups_zero_ctl4()
609 test_maxgroups_zero ctl4 port "dev $swp1 vid 10"
612 test_8021q_maxgroups_zero_cfg6()
614 test_maxgroups_zero cfg6 port "dev $swp1 vid 10"
617 test_8021q_maxgroups_zero_ctl6()
619 test_maxgroups_zero ctl6 port "dev $swp1 vid 10"
622 test_8021qvs_maxgroups_zero_cfg4()
624 test_maxgroups_zero cfg4 port_vlan "dev $swp1 vid 10"
627 test_8021qvs_maxgroups_zero_ctl4()
629 test_maxgroups_zero ctl4 port_vlan "dev $swp1 vid 10"
632 test_8021qvs_maxgroups_zero_cfg6()
634 test_maxgroups_zero cfg6 port_vlan "dev $swp1 vid 10"
637 test_8021qvs_maxgroups_zero_ctl6()
639 test_maxgroups_zero ctl6 port_vlan "dev $swp1 vid 10"
642 test_maxgroups_zero_cross_vlan()
646 local locus0="dev $swp1"
647 local locus1="dev $swp1 vid 10"
648 local locus2="dev $swp1 vid 20"
653 bridge_port_vlan_maxgroups_set "$locus1" 100
654 check_err $? "$locus1: Failed to set max to 100"
656 max=$(bridge_port_maxgroups_get "$locus0")
658 check_err $? "$locus0: Max groups expected to be 0, but $max reported"
660 max=$(bridge_port_vlan_maxgroups_get "$locus2")
662 check_err $? "$locus2: Max groups expected to be 0, but $max reported"
664 bridge_port_vlan_maxgroups_set "$locus2" 100
665 check_err $? "$locus2: Failed to set max to 100"
667 max=$(bridge_port_maxgroups_get "$locus0")
669 check_err $? "$locus0: Max groups expected to be 0, but $max reported"
671 max=$(bridge_port_vlan_maxgroups_get "$locus2")
673 check_err $? "$locus2: Max groups expected to be 100, but $max reported"
675 bridge_port_maxgroups_set "$locus0" 100
676 check_err $? "$locus0: Failed to set max to 100"
678 max=$(bridge_port_maxgroups_get "$locus0")
680 check_err $? "$locus0: Max groups expected to be 100, but $max reported"
682 max=$(bridge_port_vlan_maxgroups_get "$locus2")
684 check_err $? "$locus2: Max groups expected to be 100, but $max reported"
686 bridge_port_vlan_maxgroups_set "$locus1" 0
687 check_err $? "$locus1: Failed to set max to 0"
689 max=$(bridge_port_maxgroups_get "$locus0")
691 check_err $? "$locus0: Max groups expected to be 100, but $max reported"
693 max=$(bridge_port_vlan_maxgroups_get "$locus2")
695 check_err $? "$locus2: Max groups expected to be 100, but $max reported"
697 bridge_port_vlan_maxgroups_set "$locus2" 0
698 check_err $? "$locus2: Failed to set max to 0"
700 max=$(bridge_port_maxgroups_get "$locus0")
702 check_err $? "$locus0: Max groups expected to be 100, but $max reported"
704 max=$(bridge_port_vlan_maxgroups_get "$locus2")
706 check_err $? "$locus2: Max groups expected to be 0 but $max reported"
708 bridge_port_maxgroups_set "$locus0" 0
709 check_err $? "$locus0: Failed to set max to 0"
711 max=$(bridge_port_maxgroups_get "$locus0")
713 check_err $? "$locus0: Max groups expected to be 0, but $max reported"
715 max=$(bridge_port_vlan_maxgroups_get "$locus2")
717 check_err $? "$locus2: Max groups expected to be 0, but $max reported"
719 log_test "$CFG: port_vlan maxgroups: isolation of port and per-VLAN maximums"
722 test_8021qvs_maxgroups_zero_cross_vlan_cfg4()
724 test_maxgroups_zero_cross_vlan cfg4
727 test_8021qvs_maxgroups_zero_cross_vlan_ctl4()
729 test_maxgroups_zero_cross_vlan ctl4
732 test_8021qvs_maxgroups_zero_cross_vlan_cfg6()
734 test_maxgroups_zero_cross_vlan cfg6
737 test_8021qvs_maxgroups_zero_cross_vlan_ctl6()
739 test_maxgroups_zero_cross_vlan ctl6
742 test_maxgroups_too_low()
745 local context=$1; shift
746 local locus=$1; shift
750 local n=$(bridge_${context}_ngroups_get "$locus")
753 ${CFG}_entries_add "$locus" temp 5 111
754 check_err $? "$locus: Couldn't add MDB entries"
756 bridge_${context}_maxgroups_set "$locus" $((n+2))
757 check_err $? "$locus: Setting maxgroups to $((n+2)) failed"
759 msg=$(${CFG}_entries_add "$locus" temp 2 112 2>&1)
760 check_fail $? "$locus: Adding more entries passed when max<n"
761 bridge_maxgroups_errmsg_check_cfg "$msg"
763 ${CFG}_entries_del "$locus" temp 5 111
764 check_err $? "$locus: Couldn't delete MDB entries"
766 ${CFG}_entries_add "$locus" temp 2 112
767 check_err $? "$locus: Adding more entries failed"
769 ${CFG}_entries_del "$locus" temp 2 112
770 check_err $? "$locus: Deleting more entries failed"
772 bridge_${context}_maxgroups_set "$locus" 0
773 check_err $? "$locus: Couldn't set maximum to 0"
775 log_test "$CFG: $context maxgroups: configure below ngroups"
778 test_8021d_maxgroups_too_low_cfg4()
780 test_maxgroups_too_low cfg4 port "dev $swp1"
783 test_8021d_maxgroups_too_low_ctl4()
785 test_maxgroups_too_low ctl4 port "dev $swp1"
788 test_8021d_maxgroups_too_low_cfg6()
790 test_maxgroups_too_low cfg6 port "dev $swp1"
793 test_8021d_maxgroups_too_low_ctl6()
795 test_maxgroups_too_low ctl6 port "dev $swp1"
798 test_8021q_maxgroups_too_low_cfg4()
800 test_maxgroups_too_low cfg4 port "dev $swp1 vid 10"
803 test_8021q_maxgroups_too_low_ctl4()
805 test_maxgroups_too_low ctl4 port "dev $swp1 vid 10"
808 test_8021q_maxgroups_too_low_cfg6()
810 test_maxgroups_too_low cfg6 port "dev $swp1 vid 10"
813 test_8021q_maxgroups_too_low_ctl6()
815 test_maxgroups_too_low ctl6 port "dev $swp1 vid 10"
818 test_8021qvs_maxgroups_too_low_cfg4()
820 test_maxgroups_too_low cfg4 port_vlan "dev $swp1 vid 10"
823 test_8021qvs_maxgroups_too_low_ctl4()
825 test_maxgroups_too_low ctl4 port_vlan "dev $swp1 vid 10"
828 test_8021qvs_maxgroups_too_low_cfg6()
830 test_maxgroups_too_low cfg6 port_vlan "dev $swp1 vid 10"
833 test_8021qvs_maxgroups_too_low_ctl6()
835 test_maxgroups_too_low ctl6 port_vlan "dev $swp1 vid 10"
838 test_maxgroups_too_many_entries()
841 local context=$1; shift
842 local locus=$1; shift
846 local n=$(bridge_${context}_ngroups_get "$locus")
849 # Configure a low maximum
850 bridge_${context}_maxgroups_set "$locus" $((n+1))
851 check_err $? "$locus: Couldn't set maximum"
853 # Try to add more entries than the configured maximum
854 msg=$(${CFG}_entries_add "$locus" temp 5 2>&1)
855 check_fail $? "Adding 5 MDB entries passed, but should have failed"
856 bridge_maxgroups_errmsg_check_${CFG} "$msg"
858 # When adding entries through the control path, as many as possible
859 # get created. That's consistent with the mcast_hash_max behavior.
860 # So there, drop the entries explicitly.
861 if [[ ${CFG%[46]} == ctl ]]; then
862 ${CFG}_entries_del "$locus" temp 17 2>&1
865 local n2=$(bridge_${context}_ngroups_get "$locus")
867 check_err $? "Number of groups was $n, but after a failed attempt to add MDB entries it changed to $n2"
869 bridge_${context}_maxgroups_set "$locus" 0
870 check_err $? "$locus: Couldn't set maximum to 0"
872 log_test "$CFG: $context maxgroups: add too many MDB entries"
875 test_8021d_maxgroups_too_many_entries_cfg4()
877 test_maxgroups_too_many_entries cfg4 port "dev $swp1"
880 test_8021d_maxgroups_too_many_entries_ctl4()
882 test_maxgroups_too_many_entries ctl4 port "dev $swp1"
885 test_8021d_maxgroups_too_many_entries_cfg6()
887 test_maxgroups_too_many_entries cfg6 port "dev $swp1"
890 test_8021d_maxgroups_too_many_entries_ctl6()
892 test_maxgroups_too_many_entries ctl6 port "dev $swp1"
895 test_8021q_maxgroups_too_many_entries_cfg4()
897 test_maxgroups_too_many_entries cfg4 port "dev $swp1 vid 10"
900 test_8021q_maxgroups_too_many_entries_ctl4()
902 test_maxgroups_too_many_entries ctl4 port "dev $swp1 vid 10"
905 test_8021q_maxgroups_too_many_entries_cfg6()
907 test_maxgroups_too_many_entries cfg6 port "dev $swp1 vid 10"
910 test_8021q_maxgroups_too_many_entries_ctl6()
912 test_maxgroups_too_many_entries ctl6 port "dev $swp1 vid 10"
915 test_8021qvs_maxgroups_too_many_entries_cfg4()
917 test_maxgroups_too_many_entries cfg4 port_vlan "dev $swp1 vid 10"
920 test_8021qvs_maxgroups_too_many_entries_ctl4()
922 test_maxgroups_too_many_entries ctl4 port_vlan "dev $swp1 vid 10"
925 test_8021qvs_maxgroups_too_many_entries_cfg6()
927 test_maxgroups_too_many_entries cfg6 port_vlan "dev $swp1 vid 10"
930 test_8021qvs_maxgroups_too_many_entries_ctl6()
932 test_maxgroups_too_many_entries ctl6 port_vlan "dev $swp1 vid 10"
935 test_maxgroups_too_many_cross_vlan()
941 local locus0="dev $swp1"
942 local locus1="dev $swp1 vid 10"
943 local locus2="dev $swp1 vid 20"
944 local n1=$(bridge_port_vlan_ngroups_get "$locus1")
945 local n2=$(bridge_port_vlan_ngroups_get "$locus2")
959 ${CFG}_entries_add "$locus2" temp 5 112
960 check_err $? "Couldn't add 5 entries"
962 n2=$(bridge_port_vlan_ngroups_get "$locus2")
963 # Now 0 <= n1 < n2-1.
965 # Setting locus1'maxgroups to n2-1 should pass. The number is
966 # smaller than both the absolute number of MDB entries, and in
967 # particular than number of locus2's number of entries, but it is
968 # large enough to cover locus1's entries. Thus we check that
969 # individual VLAN's ngroups are independent.
970 bridge_port_vlan_maxgroups_set "$locus1" $((n2-1))
971 check_err $? "Setting ${locus1}'s maxgroups to $((n2-1)) failed"
973 msg=$(${CFG}_entries_add "$locus1" temp $n2 111 2>&1)
974 check_fail $? "$locus1: Adding $n2 MDB entries passed, but should have failed"
975 bridge_maxgroups_errmsg_check_${CFG} "$msg"
977 bridge_port_maxgroups_set "$locus0" $((n1 + n2 + 2))
978 check_err $? "$locus0: Couldn't set maximum"
980 msg=$(${CFG}_entries_add "$locus1" temp 5 111 2>&1)
981 check_fail $? "$locus1: Adding 5 MDB entries passed, but should have failed"
982 bridge_maxgroups_errmsg_check_${CFG} "$msg"
984 # IGMP/MLD packets can cause several entries to be added, before
985 # the maximum is hit and the rest is then bounced. Remove what was
986 # committed, if anything.
987 ${CFG}_entries_del "$locus1" temp 5 111 2>/dev/null
989 ${CFG}_entries_add "$locus1" temp 2 111
990 check_err $? "$locus1: Adding 2 MDB entries failed, but should have passed"
992 ${CFG}_entries_del "$locus1" temp 2 111
993 check_err $? "Couldn't delete MDB entries"
995 ${CFG}_entries_del "$locus2" temp 5 112
996 check_err $? "Couldn't delete MDB entries"
998 bridge_port_vlan_maxgroups_set "$locus1" 0
999 check_err $? "$locus1: Couldn't set maximum to 0"
1001 bridge_port_maxgroups_set "$locus0" 0
1002 check_err $? "$locus0: Couldn't set maximum to 0"
1004 log_test "$CFG: port_vlan maxgroups: isolation of port and per-VLAN ngroups"
1007 test_8021qvs_maxgroups_too_many_cross_vlan_cfg4()
1009 test_maxgroups_too_many_cross_vlan cfg4
1012 test_8021qvs_maxgroups_too_many_cross_vlan_ctl4()
1014 test_maxgroups_too_many_cross_vlan ctl4
1017 test_8021qvs_maxgroups_too_many_cross_vlan_cfg6()
1019 test_maxgroups_too_many_cross_vlan cfg6
1022 test_8021qvs_maxgroups_too_many_cross_vlan_ctl6()
1024 test_maxgroups_too_many_cross_vlan ctl6
1027 test_vlan_attributes()
1029 local locus=$1; shift
1030 local expect=$1; shift
1034 local max=$(bridge_port_vlan_maxgroups_get "$locus")
1035 local n=$(bridge_port_vlan_ngroups_get "$locus")
1037 eval "[[ $max $expect ]]"
1038 check_err $? "$locus: maxgroups attribute expected to be $expect, but was $max"
1040 eval "[[ $n $expect ]]"
1041 check_err $? "$locus: ngroups attribute expected to be $expect, but was $n"
1043 log_test "port_vlan: presence of ngroups and maxgroups attributes"
1046 test_8021q_vlan_attributes()
1048 test_vlan_attributes "dev $swp1 vid 10" "== null"
1051 test_8021qvs_vlan_attributes()
1053 test_vlan_attributes "dev $swp1 vid 10" "-ge 0"
1056 test_toggle_vlan_snooping()
1058 local mode=$1; shift
1063 local context=port_vlan
1064 local locus="dev $swp1 vid 10"
1066 ${CFG}_entries_add "$locus" $mode 5
1067 check_err $? "Couldn't add MDB entries"
1069 bridge_${context}_maxgroups_set "$locus" 100
1070 check_err $? "Failed to set max to 100"
1072 ip link set dev br0 type bridge mcast_vlan_snooping 0
1074 ip link set dev br0 type bridge mcast_vlan_snooping 1
1076 local n=$(bridge_${context}_ngroups_get "$locus")
1077 local nn=$(bridge mdb show dev br0 | grep $swp1 | wc -l)
1079 check_err $? "mcast_n_groups expected to be $nn, but $n reported"
1081 local max=$(bridge_${context}_maxgroups_get "$locus")
1083 check_err $? "Max groups expected to be 100 but $max reported"
1085 bridge_${context}_maxgroups_set "$locus" 0
1086 check_err $? "Failed to set max to 0"
1088 log_test "$CFG: $context: $mode: mcast_vlan_snooping toggle"
1091 test_toggle_vlan_snooping_temp()
1093 test_toggle_vlan_snooping temp
1096 test_toggle_vlan_snooping_permanent()
1098 test_toggle_vlan_snooping permanent
1101 # ngroup test suites
1103 test_8021d_ngroups_cfg4()
1105 test_8021d_ngroups_reporting_cfg4
1108 test_8021d_ngroups_ctl4()
1110 test_8021d_ngroups_reporting_ctl4
1113 test_8021d_ngroups_cfg6()
1115 test_8021d_ngroups_reporting_cfg6
1118 test_8021d_ngroups_ctl6()
1120 test_8021d_ngroups_reporting_ctl6
1123 test_8021q_ngroups_cfg4()
1125 test_8021q_ngroups_reporting_cfg4
1128 test_8021q_ngroups_ctl4()
1130 test_8021q_ngroups_reporting_ctl4
1133 test_8021q_ngroups_cfg6()
1135 test_8021q_ngroups_reporting_cfg6
1138 test_8021q_ngroups_ctl6()
1140 test_8021q_ngroups_reporting_ctl6
1143 test_8021qvs_ngroups_cfg4()
1145 test_8021qvs_ngroups_reporting_cfg4
1146 test_8021qvs_ngroups_cross_vlan_cfg4
1149 test_8021qvs_ngroups_ctl4()
1151 test_8021qvs_ngroups_reporting_ctl4
1152 test_8021qvs_ngroups_cross_vlan_ctl4
1155 test_8021qvs_ngroups_cfg6()
1157 test_8021qvs_ngroups_reporting_cfg6
1158 test_8021qvs_ngroups_cross_vlan_cfg6
1161 test_8021qvs_ngroups_ctl6()
1163 test_8021qvs_ngroups_reporting_ctl6
1164 test_8021qvs_ngroups_cross_vlan_ctl6
1167 # maxgroups test suites
1169 test_8021d_maxgroups_cfg4()
1171 test_8021d_maxgroups_zero_cfg4
1172 test_8021d_maxgroups_too_low_cfg4
1173 test_8021d_maxgroups_too_many_entries_cfg4
1176 test_8021d_maxgroups_ctl4()
1178 test_8021d_maxgroups_zero_ctl4
1179 test_8021d_maxgroups_too_low_ctl4
1180 test_8021d_maxgroups_too_many_entries_ctl4
1183 test_8021d_maxgroups_cfg6()
1185 test_8021d_maxgroups_zero_cfg6
1186 test_8021d_maxgroups_too_low_cfg6
1187 test_8021d_maxgroups_too_many_entries_cfg6
1190 test_8021d_maxgroups_ctl6()
1192 test_8021d_maxgroups_zero_ctl6
1193 test_8021d_maxgroups_too_low_ctl6
1194 test_8021d_maxgroups_too_many_entries_ctl6
1197 test_8021q_maxgroups_cfg4()
1199 test_8021q_maxgroups_zero_cfg4
1200 test_8021q_maxgroups_too_low_cfg4
1201 test_8021q_maxgroups_too_many_entries_cfg4
1204 test_8021q_maxgroups_ctl4()
1206 test_8021q_maxgroups_zero_ctl4
1207 test_8021q_maxgroups_too_low_ctl4
1208 test_8021q_maxgroups_too_many_entries_ctl4
1211 test_8021q_maxgroups_cfg6()
1213 test_8021q_maxgroups_zero_cfg6
1214 test_8021q_maxgroups_too_low_cfg6
1215 test_8021q_maxgroups_too_many_entries_cfg6
1218 test_8021q_maxgroups_ctl6()
1220 test_8021q_maxgroups_zero_ctl6
1221 test_8021q_maxgroups_too_low_ctl6
1222 test_8021q_maxgroups_too_many_entries_ctl6
1225 test_8021qvs_maxgroups_cfg4()
1227 test_8021qvs_maxgroups_zero_cfg4
1228 test_8021qvs_maxgroups_zero_cross_vlan_cfg4
1229 test_8021qvs_maxgroups_too_low_cfg4
1230 test_8021qvs_maxgroups_too_many_entries_cfg4
1231 test_8021qvs_maxgroups_too_many_cross_vlan_cfg4
1234 test_8021qvs_maxgroups_ctl4()
1236 test_8021qvs_maxgroups_zero_ctl4
1237 test_8021qvs_maxgroups_zero_cross_vlan_ctl4
1238 test_8021qvs_maxgroups_too_low_ctl4
1239 test_8021qvs_maxgroups_too_many_entries_ctl4
1240 test_8021qvs_maxgroups_too_many_cross_vlan_ctl4
1243 test_8021qvs_maxgroups_cfg6()
1245 test_8021qvs_maxgroups_zero_cfg6
1246 test_8021qvs_maxgroups_zero_cross_vlan_cfg6
1247 test_8021qvs_maxgroups_too_low_cfg6
1248 test_8021qvs_maxgroups_too_many_entries_cfg6
1249 test_8021qvs_maxgroups_too_many_cross_vlan_cfg6
1252 test_8021qvs_maxgroups_ctl6()
1254 test_8021qvs_maxgroups_zero_ctl6
1255 test_8021qvs_maxgroups_zero_cross_vlan_ctl6
1256 test_8021qvs_maxgroups_too_low_ctl6
1257 test_8021qvs_maxgroups_too_many_entries_ctl6
1258 test_8021qvs_maxgroups_too_many_cross_vlan_ctl6
1263 test_8021qvs_toggle_vlan_snooping()
1265 test_toggle_vlan_snooping_temp
1266 test_toggle_vlan_snooping_permanent
1273 # Tests for vlan_filtering 0 mcast_vlan_snooping 0.
1278 test_8021d_ngroups_cfg4
1279 test_8021d_ngroups_ctl4
1280 test_8021d_ngroups_cfg6
1281 test_8021d_ngroups_ctl6
1282 test_8021d_maxgroups_cfg4
1283 test_8021d_maxgroups_ctl4
1284 test_8021d_maxgroups_cfg6
1285 test_8021d_maxgroups_ctl6
1292 # Tests for vlan_filtering 1 mcast_vlan_snooping 0.
1297 test_8021q_vlan_attributes
1298 test_8021q_ngroups_cfg4
1299 test_8021q_ngroups_ctl4
1300 test_8021q_ngroups_cfg6
1301 test_8021q_ngroups_ctl6
1302 test_8021q_maxgroups_cfg4
1303 test_8021q_maxgroups_ctl4
1304 test_8021q_maxgroups_cfg6
1305 test_8021q_maxgroups_ctl6
1312 # Tests for vlan_filtering 1 mcast_vlan_snooping 1.
1314 switch_create_8021qvs
1317 test_8021qvs_vlan_attributes
1318 test_8021qvs_ngroups_cfg4
1319 test_8021qvs_ngroups_ctl4
1320 test_8021qvs_ngroups_cfg6
1321 test_8021qvs_ngroups_ctl6
1322 test_8021qvs_maxgroups_cfg4
1323 test_8021qvs_maxgroups_ctl4
1324 test_8021qvs_maxgroups_cfg6
1325 test_8021qvs_maxgroups_ctl6
1326 test_8021qvs_toggle_vlan_snooping