Skip to content

Commit fb39843

Browse files
idoschkuba-moo
authored andcommitted
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: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Petr Machata <petrm@nvidia.com> Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 25a26f0 commit fb39843

1 file changed

Lines changed: 105 additions & 0 deletions

File tree

tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l2_drops.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ALL_TESTS="
1414
ingress_stp_filter_test
1515
port_list_is_empty_test
1616
port_loopback_filter_test
17+
locked_port_test
1718
"
1819
NUM_NETIFS=4
1920
source $lib_dir/tc_common.sh
@@ -420,6 +421,110 @@ port_loopback_filter_test()
420421
port_loopback_filter_uc_test
421422
}
422423

424+
locked_port_miss_test()
425+
{
426+
local trap_name="locked_port"
427+
local smac=00:11:22:33:44:55
428+
429+
bridge link set dev $swp1 learning off
430+
bridge link set dev $swp1 locked on
431+
432+
RET=0
433+
434+
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
435+
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
436+
check_fail $? "Trap stats increased before setting action to \"trap\""
437+
438+
devlink_trap_action_set $trap_name "trap"
439+
440+
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
441+
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
442+
check_err $? "Trap stats did not increase when should"
443+
444+
devlink_trap_action_set $trap_name "drop"
445+
446+
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
447+
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
448+
check_fail $? "Trap stats increased after setting action to \"drop\""
449+
450+
devlink_trap_action_set $trap_name "trap"
451+
452+
bridge fdb replace $smac dev $swp1 master static vlan 1
453+
454+
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
455+
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
456+
check_fail $? "Trap stats increased after adding an FDB entry"
457+
458+
bridge fdb del $smac dev $swp1 master static vlan 1
459+
bridge link set dev $swp1 locked off
460+
461+
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
462+
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
463+
check_fail $? "Trap stats increased after unlocking port"
464+
465+
log_test "Locked port - FDB miss"
466+
467+
devlink_trap_action_set $trap_name "drop"
468+
bridge link set dev $swp1 learning on
469+
}
470+
471+
locked_port_mismatch_test()
472+
{
473+
local trap_name="locked_port"
474+
local smac=00:11:22:33:44:55
475+
476+
bridge link set dev $swp1 learning off
477+
bridge link set dev $swp1 locked on
478+
479+
RET=0
480+
481+
bridge fdb replace $smac dev $swp2 master static vlan 1
482+
483+
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
484+
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
485+
check_fail $? "Trap stats increased before setting action to \"trap\""
486+
487+
devlink_trap_action_set $trap_name "trap"
488+
489+
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
490+
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
491+
check_err $? "Trap stats did not increase when should"
492+
493+
devlink_trap_action_set $trap_name "drop"
494+
495+
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
496+
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
497+
check_fail $? "Trap stats increased after setting action to \"drop\""
498+
499+
devlink_trap_action_set $trap_name "trap"
500+
bridge link set dev $swp1 locked off
501+
502+
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
503+
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
504+
check_fail $? "Trap stats increased after unlocking port"
505+
506+
bridge link set dev $swp1 locked on
507+
bridge fdb replace $smac dev $swp1 master static vlan 1
508+
509+
devlink_trap_stats_check $trap_name $MZ $h1 -c 1 \
510+
-a $smac -b $(mac_get $h2) -A 192.0.2.1 -B 192.0.2.2 -p 100 -q
511+
check_fail $? "Trap stats increased after replacing an FDB entry"
512+
513+
bridge fdb del $smac dev $swp1 master static vlan 1
514+
devlink_trap_action_set $trap_name "drop"
515+
516+
log_test "Locked port - FDB mismatch"
517+
518+
bridge link set dev $swp1 locked off
519+
bridge link set dev $swp1 learning on
520+
}
521+
522+
locked_port_test()
523+
{
524+
locked_port_miss_test
525+
locked_port_mismatch_test
526+
}
527+
423528
trap cleanup EXIT
424529

425530
setup_prepare

0 commit comments

Comments
 (0)