]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests: net/bridge : add tests for per vlan snooping with stp state changes
authorYong Wang <yongwang@nvidia.com>
Thu, 17 Apr 2025 13:43:14 +0000 (15:43 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 Apr 2025 12:02:20 +0000 (13:02 +0100)
Change ALL_TESTS definition to "test-per-line".

Add the test case of per vlan snooping with port stp state change to
forwarding and also vlan equivalent case in both bridge_igmp.sh and
bridge_mld.sh.

Signed-off-by: Yong Wang <yongwang@nvidia.com>
Reviewed-by: Andy Roulin <aroulin@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/forwarding/bridge_igmp.sh
tools/testing/selftests/net/forwarding/bridge_mld.sh
tools/testing/selftests/net/forwarding/config

index e6a3e04fd83f31f7897cb7111ed11406665fffb6..d4e7dd6593548dcf2a6e572a7fe6732cb72e001c 100755 (executable)
@@ -1,10 +1,24 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
-ALL_TESTS="v2reportleave_test v3include_test v3inc_allow_test v3inc_is_include_test \
-          v3inc_is_exclude_test v3inc_to_exclude_test v3exc_allow_test v3exc_is_include_test \
-          v3exc_is_exclude_test v3exc_to_exclude_test v3inc_block_test v3exc_block_test \
-          v3exc_timeout_test v3star_ex_auto_add_test"
+ALL_TESTS="
+       v2reportleave_test
+       v3include_test
+       v3inc_allow_test
+       v3inc_is_include_test
+       v3inc_is_exclude_test
+       v3inc_to_exclude_test
+       v3exc_allow_test
+       v3exc_is_include_test
+       v3exc_is_exclude_test
+       v3exc_to_exclude_test
+       v3inc_block_test
+       v3exc_block_test
+       v3exc_timeout_test
+       v3star_ex_auto_add_test
+       v2per_vlan_snooping_port_stp_test
+       v2per_vlan_snooping_vlan_stp_test
+"
 NUM_NETIFS=4
 CHECK_TC="yes"
 TEST_GROUP="239.10.10.10"
@@ -554,6 +568,64 @@ v3star_ex_auto_add_test()
        v3cleanup $swp2 $TEST_GROUP
 }
 
+v2per_vlan_snooping_stp_test()
+{
+       local is_port=$1
+
+       local msg="port"
+       [[ $is_port -ne 1 ]] && msg="vlan"
+
+       ip link set br0 up type bridge vlan_filtering 1 \
+                                       mcast_igmp_version 2 \
+                                       mcast_snooping 1 \
+                                       mcast_vlan_snooping 1 \
+                                       mcast_querier 1 \
+                                       mcast_stats_enabled 1
+       bridge vlan global set vid 1 dev br0 \
+                                       mcast_snooping 1 \
+                                       mcast_querier 1 \
+                                       mcast_query_interval 100 \
+                                       mcast_startup_query_count 0
+       [[ $is_port -eq 1 ]] && bridge link set dev $swp1 state 0
+       [[ $is_port -ne 1 ]] && bridge vlan set vid 1 dev $swp1 state 4
+       sleep 5
+       local tx_s=$(ip -j -p stats show dev $swp1 \
+                       group xstats_slave subgroup bridge suite mcast \
+                       | jq '.[]["multicast"]["igmp_queries"]["tx_v2"]')
+
+       [[ $is_port -eq 1 ]] && bridge link set dev $swp1 state 3
+       [[ $is_port -ne 1 ]] && bridge vlan set vid 1 dev $swp1 state 3
+       sleep 5
+       local tx_e=$(ip -j -p stats show dev $swp1 \
+                       group xstats_slave subgroup bridge suite mcast \
+                       | jq '.[]["multicast"]["igmp_queries"]["tx_v2"]')
+
+       RET=0
+       local tx=$(expr $tx_e - $tx_s)
+       test $tx -gt 0
+       check_err $? "No IGMP queries after STP state becomes forwarding"
+       log_test "per vlan snooping with $msg stp state change"
+
+       # restore settings
+       bridge vlan global set vid 1 dev br0 \
+                                       mcast_querier 0 \
+                                       mcast_query_interval 12500 \
+                                       mcast_startup_query_count 2
+       ip link set br0 up type bridge vlan_filtering 0 \
+                                       mcast_vlan_snooping 0 \
+                                       mcast_stats_enabled 0
+}
+
+v2per_vlan_snooping_port_stp_test()
+{
+       v2per_vlan_snooping_stp_test 1
+}
+
+v2per_vlan_snooping_vlan_stp_test()
+{
+       v2per_vlan_snooping_stp_test 0
+}
+
 trap cleanup EXIT
 
 setup_prepare
index f84ab2e657547a285fbd02c8828245f6cf2d5409..4cacef5a813aae1169d4416942efcf89b209b4ba 100755 (executable)
@@ -1,10 +1,23 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
-ALL_TESTS="mldv2include_test mldv2inc_allow_test mldv2inc_is_include_test mldv2inc_is_exclude_test \
-          mldv2inc_to_exclude_test mldv2exc_allow_test mldv2exc_is_include_test \
-          mldv2exc_is_exclude_test mldv2exc_to_exclude_test mldv2inc_block_test \
-          mldv2exc_block_test mldv2exc_timeout_test mldv2star_ex_auto_add_test"
+ALL_TESTS="
+       mldv2include_test
+       mldv2inc_allow_test
+       mldv2inc_is_include_test
+       mldv2inc_is_exclude_test
+       mldv2inc_to_exclude_test
+       mldv2exc_allow_test
+       mldv2exc_is_include_test
+       mldv2exc_is_exclude_test
+       mldv2exc_to_exclude_test
+       mldv2inc_block_test
+       mldv2exc_block_test
+       mldv2exc_timeout_test
+       mldv2star_ex_auto_add_test
+       mldv2per_vlan_snooping_port_stp_test
+       mldv2per_vlan_snooping_vlan_stp_test
+"
 NUM_NETIFS=4
 CHECK_TC="yes"
 TEST_GROUP="ff02::cc"
@@ -554,6 +567,66 @@ mldv2star_ex_auto_add_test()
        mldv2cleanup $swp2
 }
 
+mldv2per_vlan_snooping_stp_test()
+{
+       local is_port=$1
+
+       local msg="port"
+       [[ $is_port -ne 1 ]] && msg="vlan"
+
+       ip link set br0 up type bridge vlan_filtering 1 \
+                                       mcast_mld_version 2 \
+                                       mcast_snooping 1 \
+                                       mcast_vlan_snooping 1 \
+                                       mcast_querier 1 \
+                                       mcast_stats_enabled 1
+       bridge vlan global set vid 1 dev br0 \
+                                       mcast_mld_version 2 \
+                                       mcast_snooping 1 \
+                                       mcast_querier 1 \
+                                       mcast_query_interval 100 \
+                                       mcast_startup_query_count 0
+
+       [[ $is_port -eq 1 ]] && bridge link set dev $swp1 state 0
+       [[ $is_port -ne 1 ]] && bridge vlan set vid 1 dev $swp1 state 4
+       sleep 5
+       local tx_s=$(ip -j -p stats show dev $swp1 \
+                       group xstats_slave subgroup bridge suite mcast \
+                       | jq '.[]["multicast"]["mld_queries"]["tx_v2"]')
+       [[ $is_port -eq 1 ]] && bridge link set dev $swp1 state 3
+       [[ $is_port -ne 1 ]] && bridge vlan set vid 1 dev $swp1 state 3
+       sleep 5
+       local tx_e=$(ip -j -p stats show dev $swp1 \
+                       group xstats_slave subgroup bridge suite mcast \
+                       | jq '.[]["multicast"]["mld_queries"]["tx_v2"]')
+
+       RET=0
+       local tx=$(expr $tx_e - $tx_s)
+       test $tx -gt 0
+       check_err $? "No MLD queries after STP state becomes forwarding"
+       log_test "per vlan snooping with $msg stp state change"
+
+       # restore settings
+       bridge vlan global set vid 1 dev br0 \
+                                       mcast_querier 0 \
+                                       mcast_query_interval 12500 \
+                                       mcast_startup_query_count 2 \
+                                       mcast_mld_version 1
+       ip link set br0 up type bridge vlan_filtering 0 \
+                                       mcast_vlan_snooping 0 \
+                                       mcast_stats_enabled 0
+}
+
+mldv2per_vlan_snooping_port_stp_test()
+{
+       mldv2per_vlan_snooping_stp_test 1
+}
+
+mldv2per_vlan_snooping_vlan_stp_test()
+{
+       mldv2per_vlan_snooping_stp_test 0
+}
+
 trap cleanup EXIT
 
 setup_prepare
index 8d7a1a004b7c34397ab192266c4275c78538e71b..18fd69d8d937d5ea03a4d5790997bab7af95dd5a 100644 (file)
@@ -1,6 +1,7 @@
 CONFIG_BRIDGE=m
 CONFIG_VLAN_8021Q=m
 CONFIG_BRIDGE_VLAN_FILTERING=y
+CONFIG_BRIDGE_IGMP_SNOOPING=y
 CONFIG_NET_L3_MASTER_DEV=y
 CONFIG_IPV6_MULTIPLE_TABLES=y
 CONFIG_NET_VRF=m