Skip to content

Commit 0491391

Browse files
idoschkuba-moo
authored andcommitted
selftests: forwarding: Add MDB dump test cases
The kernel maintains three markers for the MDB dump: 1. The last bridge device from which the MDB was dumped. 2. The last MDB entry from which the MDB was dumped. 3. The last port-group entry that was dumped. Add test cases for large scale MDB dump to make sure that all the configured entries are dumped and that the markers are used correctly. Specifically, create 2 bridges with 32 ports and add 256 MDB entries in which all the ports are member of. Test that each bridge reports 8192 (256 * 32) permanent entries. Do that with IPv4, IPv6 and L2 MDB entries. On my system, MDB dump of the above is contained in about 50 netlink messages. Example output: # ./bridge_mdb.sh [...] INFO: # Large scale dump tests TEST: IPv4 large scale dump tests [ OK ] TEST: IPv6 large scale dump tests [ OK ] TEST: L2 large scale dump tests [ OK ] [...] Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Petr Machata <petrm@nvidia.com> Acked-by: Nikolay Aleksandrov <razor@blackwall.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 170afa7 commit 0491391

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

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

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,109 @@ cfg_test_port()
742742
cfg_test_port_l2
743743
}
744744

745+
ipv4_grps_get()
746+
{
747+
local max_grps=$1; shift
748+
local i
749+
750+
for i in $(seq 0 $((max_grps - 1))); do
751+
echo "239.1.1.$i"
752+
done
753+
}
754+
755+
ipv6_grps_get()
756+
{
757+
local max_grps=$1; shift
758+
local i
759+
760+
for i in $(seq 0 $((max_grps - 1))); do
761+
echo "ff0e::$(printf %x $i)"
762+
done
763+
}
764+
765+
l2_grps_get()
766+
{
767+
local max_grps=$1; shift
768+
local i
769+
770+
for i in $(seq 0 $((max_grps - 1))); do
771+
echo "01:00:00:00:00:$(printf %02x $i)"
772+
done
773+
}
774+
775+
cfg_test_dump_common()
776+
{
777+
local name=$1; shift
778+
local fn=$1; shift
779+
local max_bridges=2
780+
local max_grps=256
781+
local max_ports=32
782+
local num_entries
783+
local batch_file
784+
local grp
785+
local i j
786+
787+
RET=0
788+
789+
# Create net devices.
790+
for i in $(seq 1 $max_bridges); do
791+
ip link add name br-test${i} up type bridge vlan_filtering 1 \
792+
mcast_snooping 1
793+
for j in $(seq 1 $max_ports); do
794+
ip link add name br-test${i}-du${j} up \
795+
master br-test${i} type dummy
796+
done
797+
done
798+
799+
# Create batch file with MDB entries.
800+
batch_file=$(mktemp)
801+
for i in $(seq 1 $max_bridges); do
802+
for j in $(seq 1 $max_ports); do
803+
for grp in $($fn $max_grps); do
804+
echo "mdb add dev br-test${i} \
805+
port br-test${i}-du${j} grp $grp \
806+
permanent vid 1" >> $batch_file
807+
done
808+
done
809+
done
810+
811+
# Program the batch file and check for expected number of entries.
812+
bridge -b $batch_file
813+
for i in $(seq 1 $max_bridges); do
814+
num_entries=$(bridge mdb show dev br-test${i} | \
815+
grep "permanent" | wc -l)
816+
[[ $num_entries -eq $((max_grps * max_ports)) ]]
817+
check_err $? "Wrong number of entries in br-test${i}"
818+
done
819+
820+
# Cleanup.
821+
rm $batch_file
822+
for i in $(seq 1 $max_bridges); do
823+
ip link del dev br-test${i}
824+
for j in $(seq $max_ports); do
825+
ip link del dev br-test${i}-du${j}
826+
done
827+
done
828+
829+
log_test "$name large scale dump tests"
830+
}
831+
832+
# Check large scale dump.
833+
cfg_test_dump()
834+
{
835+
echo
836+
log_info "# Large scale dump tests"
837+
838+
cfg_test_dump_common "IPv4" ipv4_grps_get
839+
cfg_test_dump_common "IPv6" ipv6_grps_get
840+
cfg_test_dump_common "L2" l2_grps_get
841+
}
842+
745843
cfg_test()
746844
{
747845
cfg_test_host
748846
cfg_test_port
847+
cfg_test_dump
749848
}
750849

751850
__fwd_test_host_ip()

0 commit comments

Comments
 (0)