Skip to content

Commit bd2dcb9

Browse files
idoschdavem330
authored andcommitted
selftests: bridge_mdb: Add MDB bulk deletion test
Add test cases to verify the behavior of the MDB bulk deletion functionality in the bridge driver. Signed-off-by: Ido Schimmel <[email protected]> Acked-by: Petr Machata <[email protected]> Reviewed-by: Hangbin Liu <[email protected]> Acked-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2601e9c commit bd2dcb9

File tree

1 file changed

+189
-2
lines changed

1 file changed

+189
-2
lines changed

tools/testing/selftests/net/forwarding/bridge_mdb.sh

Lines changed: 189 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,11 +803,198 @@ cfg_test_dump()
803803
cfg_test_dump_common "L2" l2_grps_get
804804
}
805805

806+
# Check flush functionality with different parameters.
807+
cfg_test_flush()
808+
{
809+
local num_entries
810+
811+
# Add entries with different attributes and check that they are all
812+
# flushed when the flush command is given with no parameters.
813+
814+
# Different port.
815+
bridge mdb add dev br0 port $swp1 grp 239.1.1.1 vid 10
816+
bridge mdb add dev br0 port $swp2 grp 239.1.1.2 vid 10
817+
818+
# Different VLAN ID.
819+
bridge mdb add dev br0 port $swp1 grp 239.1.1.3 vid 10
820+
bridge mdb add dev br0 port $swp1 grp 239.1.1.4 vid 20
821+
822+
# Different routing protocol.
823+
bridge mdb add dev br0 port $swp1 grp 239.1.1.5 vid 10 proto bgp
824+
bridge mdb add dev br0 port $swp1 grp 239.1.1.6 vid 10 proto zebra
825+
826+
# Different state.
827+
bridge mdb add dev br0 port $swp1 grp 239.1.1.7 vid 10 permanent
828+
bridge mdb add dev br0 port $swp1 grp 239.1.1.8 vid 10 temp
829+
830+
bridge mdb flush dev br0
831+
num_entries=$(bridge mdb show dev br0 | wc -l)
832+
[[ $num_entries -eq 0 ]]
833+
check_err $? 0 "Not all entries flushed after flush all"
834+
835+
# Check that when flushing by port only entries programmed with the
836+
# specified port are flushed and the rest are not.
837+
838+
bridge mdb add dev br0 port $swp1 grp 239.1.1.1 vid 10
839+
bridge mdb add dev br0 port $swp2 grp 239.1.1.1 vid 10
840+
bridge mdb add dev br0 port br0 grp 239.1.1.1 vid 10
841+
842+
bridge mdb flush dev br0 port $swp1
843+
844+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port $swp1"
845+
check_fail $? "Entry not flushed by specified port"
846+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port $swp2"
847+
check_err $? "Entry flushed by wrong port"
848+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port br0"
849+
check_err $? "Host entry flushed by wrong port"
850+
851+
bridge mdb flush dev br0 port br0
852+
853+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port br0"
854+
check_fail $? "Host entry not flushed by specified port"
855+
856+
bridge mdb flush dev br0
857+
858+
# Check that when flushing by VLAN ID only entries programmed with the
859+
# specified VLAN ID are flushed and the rest are not.
860+
861+
bridge mdb add dev br0 port $swp1 grp 239.1.1.1 vid 10
862+
bridge mdb add dev br0 port $swp2 grp 239.1.1.1 vid 10
863+
bridge mdb add dev br0 port $swp1 grp 239.1.1.1 vid 20
864+
bridge mdb add dev br0 port $swp2 grp 239.1.1.1 vid 20
865+
866+
bridge mdb flush dev br0 vid 10
867+
868+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 &> /dev/null
869+
check_fail $? "Entry not flushed by specified VLAN ID"
870+
bridge mdb get dev br0 grp 239.1.1.1 vid 20 &> /dev/null
871+
check_err $? "Entry flushed by wrong VLAN ID"
872+
873+
bridge mdb flush dev br0
874+
875+
# Check that all permanent entries are flushed when "permanent" is
876+
# specified and that temporary entries are not.
877+
878+
bridge mdb add dev br0 port $swp1 grp 239.1.1.1 permanent vid 10
879+
bridge mdb add dev br0 port $swp2 grp 239.1.1.1 temp vid 10
880+
881+
bridge mdb flush dev br0 permanent
882+
883+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port $swp1"
884+
check_fail $? "Entry not flushed by \"permanent\" state"
885+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port $swp2"
886+
check_err $? "Entry flushed by wrong state (\"permanent\")"
887+
888+
bridge mdb flush dev br0
889+
890+
# Check that all temporary entries are flushed when "nopermanent" is
891+
# specified and that permanent entries are not.
892+
893+
bridge mdb add dev br0 port $swp1 grp 239.1.1.1 permanent vid 10
894+
bridge mdb add dev br0 port $swp2 grp 239.1.1.1 temp vid 10
895+
896+
bridge mdb flush dev br0 nopermanent
897+
898+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port $swp1"
899+
check_err $? "Entry flushed by wrong state (\"nopermanent\")"
900+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port $swp2"
901+
check_fail $? "Entry not flushed by \"nopermanent\" state"
902+
903+
bridge mdb flush dev br0
904+
905+
# Check that L2 host entries are not flushed when "nopermanent" is
906+
# specified, but flushed when "permanent" is specified.
907+
908+
bridge mdb add dev br0 port br0 grp 01:02:03:04:05:06 permanent vid 10
909+
910+
bridge mdb flush dev br0 nopermanent
911+
912+
bridge mdb get dev br0 grp 01:02:03:04:05:06 vid 10 &> /dev/null
913+
check_err $? "L2 host entry flushed by wrong state (\"nopermanent\")"
914+
915+
bridge mdb flush dev br0 permanent
916+
917+
bridge mdb get dev br0 grp 01:02:03:04:05:06 vid 10 &> /dev/null
918+
check_fail $? "L2 host entry not flushed by \"permanent\" state"
919+
920+
bridge mdb flush dev br0
921+
922+
# Check that IPv4 host entries are not flushed when "permanent" is
923+
# specified, but flushed when "nopermanent" is specified.
924+
925+
bridge mdb add dev br0 port br0 grp 239.1.1.1 temp vid 10
926+
927+
bridge mdb flush dev br0 permanent
928+
929+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 &> /dev/null
930+
check_err $? "IPv4 host entry flushed by wrong state (\"permanent\")"
931+
932+
bridge mdb flush dev br0 nopermanent
933+
934+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 &> /dev/null
935+
check_fail $? "IPv4 host entry not flushed by \"nopermanent\" state"
936+
937+
bridge mdb flush dev br0
938+
939+
# Check that IPv6 host entries are not flushed when "permanent" is
940+
# specified, but flushed when "nopermanent" is specified.
941+
942+
bridge mdb add dev br0 port br0 grp ff0e::1 temp vid 10
943+
944+
bridge mdb flush dev br0 permanent
945+
946+
bridge mdb get dev br0 grp ff0e::1 vid 10 &> /dev/null
947+
check_err $? "IPv6 host entry flushed by wrong state (\"permanent\")"
948+
949+
bridge mdb flush dev br0 nopermanent
950+
951+
bridge mdb get dev br0 grp ff0e::1 vid 10 &> /dev/null
952+
check_fail $? "IPv6 host entry not flushed by \"nopermanent\" state"
953+
954+
bridge mdb flush dev br0
955+
956+
# Check that when flushing by routing protocol only entries programmed
957+
# with the specified routing protocol are flushed and the rest are not.
958+
959+
bridge mdb add dev br0 port $swp1 grp 239.1.1.1 vid 10 proto bgp
960+
bridge mdb add dev br0 port $swp2 grp 239.1.1.1 vid 10 proto zebra
961+
bridge mdb add dev br0 port br0 grp 239.1.1.1 vid 10
962+
963+
bridge mdb flush dev br0 proto bgp
964+
965+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port $swp1"
966+
check_fail $? "Entry not flushed by specified routing protocol"
967+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port $swp2"
968+
check_err $? "Entry flushed by wrong routing protocol"
969+
bridge mdb get dev br0 grp 239.1.1.1 vid 10 | grep -q "port br0"
970+
check_err $? "Host entry flushed by wrong routing protocol"
971+
972+
bridge mdb flush dev br0
973+
974+
# Test that an error is returned when trying to flush using unsupported
975+
# parameters.
976+
977+
bridge mdb flush dev br0 src_vni 10 &> /dev/null
978+
check_fail $? "Managed to flush by source VNI"
979+
980+
bridge mdb flush dev br0 dst 198.51.100.1 &> /dev/null
981+
check_fail $? "Managed to flush by destination IP"
982+
983+
bridge mdb flush dev br0 dst_port 4789 &> /dev/null
984+
check_fail $? "Managed to flush by UDP destination port"
985+
986+
bridge mdb flush dev br0 vni 10 &> /dev/null
987+
check_fail $? "Managed to flush by destination VNI"
988+
989+
log_test "Flush tests"
990+
}
991+
806992
cfg_test()
807993
{
808994
cfg_test_host
809995
cfg_test_port
810996
cfg_test_dump
997+
cfg_test_flush
811998
}
812999

8131000
__fwd_test_host_ip()
@@ -1166,8 +1353,8 @@ ctrl_test()
11661353
ctrl_mldv2_is_in_test
11671354
}
11681355

1169-
if ! bridge mdb help 2>&1 | grep -q "get"; then
1170-
echo "SKIP: iproute2 too old, missing bridge mdb get support"
1356+
if ! bridge mdb help 2>&1 | grep -q "flush"; then
1357+
echo "SKIP: iproute2 too old, missing bridge mdb flush support"
11711358
exit $ksft_skip
11721359
fi
11731360

0 commit comments

Comments
 (0)