Commit fb398432 authored by Ido Schimmel's avatar Ido Schimmel Committed by Jakub Kicinski

selftests: mlxsw: Add a test for locked port trap

Test that packets received via a locked bridge port whose {SMAC, VID}
does not appear in the bridge's FDB or appears with a different port,
trigger the "locked_port" packet trap.
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 25a26f0c
...@@ -14,6 +14,7 @@ ALL_TESTS=" ...@@ -14,6 +14,7 @@ ALL_TESTS="
ingress_stp_filter_test ingress_stp_filter_test
port_list_is_empty_test port_list_is_empty_test
port_loopback_filter_test port_loopback_filter_test
locked_port_test
" "
NUM_NETIFS=4 NUM_NETIFS=4
source $lib_dir/tc_common.sh source $lib_dir/tc_common.sh
...@@ -420,6 +421,110 @@ port_loopback_filter_test() ...@@ -420,6 +421,110 @@ port_loopback_filter_test()
port_loopback_filter_uc_test port_loopback_filter_uc_test
} }
locked_port_miss_test()
{
local trap_name="locked_port"
local smac=00:11:22:33:44:55
bridge link set dev $swp1 learning off
bridge link set dev $swp1 locked on
RET=0
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
check_fail $? "Trap stats increased before setting action to \"trap\""
devlink_trap_action_set $trap_name "trap"
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
check_err $? "Trap stats did not increase when should"
devlink_trap_action_set $trap_name "drop"
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
check_fail $? "Trap stats increased after setting action to \"drop\""
devlink_trap_action_set $trap_name "trap"
bridge fdb replace $smac dev $swp1 master static vlan 1
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
check_fail $? "Trap stats increased after adding an FDB entry"
bridge fdb del $smac dev $swp1 master static vlan 1
bridge link set dev $swp1 locked off
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
check_fail $? "Trap stats increased after unlocking port"
log_test "Locked port - FDB miss"
devlink_trap_action_set $trap_name "drop"
bridge link set dev $swp1 learning on
}
locked_port_mismatch_test()
{
local trap_name="locked_port"
local smac=00:11:22:33:44:55
bridge link set dev $swp1 learning off
bridge link set dev $swp1 locked on
RET=0
bridge fdb replace $smac dev $swp2 master static vlan 1
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
check_fail $? "Trap stats increased before setting action to \"trap\""
devlink_trap_action_set $trap_name "trap"
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
check_err $? "Trap stats did not increase when should"
devlink_trap_action_set $trap_name "drop"
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
check_fail $? "Trap stats increased after setting action to \"drop\""
devlink_trap_action_set $trap_name "trap"
bridge link set dev $swp1 locked off
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
check_fail $? "Trap stats increased after unlocking port"
bridge link set dev $swp1 locked on
bridge fdb replace $smac dev $swp1 master static vlan 1
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
check_fail $? "Trap stats increased after replacing an FDB entry"
bridge fdb del $smac dev $swp1 master static vlan 1
devlink_trap_action_set $trap_name "drop"
log_test "Locked port - FDB mismatch"
bridge link set dev $swp1 locked off
bridge link set dev $swp1 learning on
}
locked_port_test()
{
locked_port_miss_test
locked_port_mismatch_test
}
trap cleanup EXIT trap cleanup EXIT
setup_prepare setup_prepare
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment