-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Petr Machata says: ==================== selftests: New selftests for out-of-order-operations patches in mlxsw In the past, the mlxsw driver made the assumption that the user applies configuration in a bottom-up manner. Thus netdevices needed to be added to the bridge before IP addresses were configured on that bridge or SVI added on top of it, because whatever happened before a netdevice was mlxsw upper was generally ignored by mlxsw. Recently, several patch series were pushed to introduce the bookkeeping and replays necessary to offload the full state, not just the immediate configuration step. In this patchset, introduce new selftests that directly exercise the out of order code paths in mlxsw. - Patch #1 adds new tests into the existing selftest router_bridge.sh. - Patches #2-#5 add new generic selftests. - Patches #6-#8 add new mlxsw-specific selftests. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Showing
9 changed files
with
1,580 additions
and
0 deletions.
There are no files selected for viewing
183 changes: 183 additions & 0 deletions
183
tools/testing/selftests/drivers/net/mlxsw/rif_bridge.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
lib_dir=$(dirname $0)/../../../net/forwarding | ||
|
||
ALL_TESTS=" | ||
bridge_rif_add | ||
bridge_rif_nomaster | ||
bridge_rif_remaster | ||
bridge_rif_nomaster_addr | ||
bridge_rif_nomaster_port | ||
bridge_rif_remaster_port | ||
" | ||
|
||
NUM_NETIFS=2 | ||
source $lib_dir/lib.sh | ||
source $lib_dir/devlink_lib.sh | ||
|
||
setup_prepare() | ||
{ | ||
swp1=${NETIFS[p1]} | ||
swp2=${NETIFS[p2]} | ||
|
||
team_create lag1 lacp | ||
ip link set dev lag1 addrgenmode none | ||
ip link set dev lag1 address $(mac_get $swp1) | ||
|
||
team_create lag2 lacp | ||
ip link set dev lag2 addrgenmode none | ||
ip link set dev lag2 address $(mac_get $swp2) | ||
|
||
ip link add name br1 type bridge vlan_filtering 1 | ||
ip link set dev br1 addrgenmode none | ||
ip link set dev br1 address $(mac_get lag1) | ||
ip link set dev br1 up | ||
|
||
ip link set dev lag1 master br1 | ||
|
||
ip link set dev $swp1 master lag1 | ||
ip link set dev $swp1 up | ||
|
||
ip link set dev $swp2 master lag2 | ||
ip link set dev $swp2 up | ||
} | ||
|
||
cleanup() | ||
{ | ||
pre_cleanup | ||
|
||
ip link set dev $swp2 nomaster | ||
ip link set dev $swp2 down | ||
|
||
ip link set dev $swp1 nomaster | ||
ip link set dev $swp1 down | ||
|
||
ip link del dev lag2 | ||
ip link set dev lag1 nomaster | ||
ip link del dev lag1 | ||
|
||
ip link del dev br1 | ||
} | ||
|
||
bridge_rif_add() | ||
{ | ||
RET=0 | ||
|
||
local rifs_occ_t0=$(devlink_resource_occ_get rifs) | ||
__addr_add_del br1 add 192.0.2.2/28 | ||
sleep 1 | ||
local rifs_occ_t1=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0 + 1)) | ||
|
||
((expected_rifs == rifs_occ_t1)) | ||
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used" | ||
|
||
log_test "Add RIF for bridge on address addition" | ||
} | ||
|
||
bridge_rif_nomaster() | ||
{ | ||
RET=0 | ||
|
||
local rifs_occ_t0=$(devlink_resource_occ_get rifs) | ||
ip link set dev lag1 nomaster | ||
sleep 1 | ||
local rifs_occ_t1=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0 - 1)) | ||
|
||
((expected_rifs == rifs_occ_t1)) | ||
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used" | ||
|
||
log_test "Drop RIF for bridge on LAG deslavement" | ||
} | ||
|
||
bridge_rif_remaster() | ||
{ | ||
RET=0 | ||
|
||
local rifs_occ_t0=$(devlink_resource_occ_get rifs) | ||
ip link set dev lag1 master br1 | ||
sleep 1 | ||
local rifs_occ_t1=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0 + 1)) | ||
|
||
((expected_rifs == rifs_occ_t1)) | ||
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used" | ||
|
||
log_test "Add RIF for bridge on LAG reenslavement" | ||
} | ||
|
||
bridge_rif_nomaster_addr() | ||
{ | ||
local rifs_occ_t0=$(devlink_resource_occ_get rifs) | ||
|
||
# Adding an address while the LAG is enslaved shouldn't generate a RIF. | ||
__addr_add_del lag1 add 192.0.2.65/28 | ||
sleep 1 | ||
local rifs_occ_t1=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0)) | ||
|
||
((expected_rifs == rifs_occ_t1)) | ||
check_err $? "After adding IP: Expected $expected_rifs RIFs, $rifs_occ_t1 are used" | ||
|
||
# Removing the LAG from the bridge should drop RIF for the bridge (as | ||
# tested in bridge_rif_lag_nomaster), but since the LAG now has an | ||
# address, it should gain a RIF. | ||
ip link set dev lag1 nomaster | ||
sleep 1 | ||
local rifs_occ_t2=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0)) | ||
|
||
((expected_rifs == rifs_occ_t2)) | ||
check_err $? "After deslaving: Expected $expected_rifs RIFs, $rifs_occ_t2 are used" | ||
|
||
log_test "Add RIF for LAG on deslavement from bridge" | ||
|
||
__addr_add_del lag1 del 192.0.2.65/28 | ||
ip link set dev lag1 master br1 | ||
sleep 1 | ||
} | ||
|
||
bridge_rif_nomaster_port() | ||
{ | ||
RET=0 | ||
|
||
local rifs_occ_t0=$(devlink_resource_occ_get rifs) | ||
ip link set dev $swp1 nomaster | ||
sleep 1 | ||
local rifs_occ_t1=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0 - 1)) | ||
|
||
((expected_rifs == rifs_occ_t1)) | ||
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used" | ||
|
||
log_test "Drop RIF for bridge on deslavement of port from LAG" | ||
} | ||
|
||
bridge_rif_remaster_port() | ||
{ | ||
RET=0 | ||
|
||
local rifs_occ_t0=$(devlink_resource_occ_get rifs) | ||
ip link set dev $swp1 down | ||
ip link set dev $swp1 master lag1 | ||
ip link set dev $swp1 up | ||
setup_wait_dev $swp1 | ||
local rifs_occ_t1=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0 + 1)) | ||
|
||
((expected_rifs == rifs_occ_t1)) | ||
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used" | ||
|
||
log_test "Add RIF for bridge on reenslavement of port to LAG" | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
setup_prepare | ||
setup_wait | ||
|
||
tests_run | ||
|
||
exit $EXIT_STATUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
lib_dir=$(dirname $0)/../../../net/forwarding | ||
|
||
ALL_TESTS=" | ||
lag_rif_add | ||
lag_rif_nomaster | ||
lag_rif_remaster | ||
lag_rif_nomaster_addr | ||
" | ||
|
||
NUM_NETIFS=2 | ||
source $lib_dir/lib.sh | ||
source $lib_dir/devlink_lib.sh | ||
|
||
setup_prepare() | ||
{ | ||
swp1=${NETIFS[p1]} | ||
swp2=${NETIFS[p2]} | ||
|
||
team_create lag1 lacp | ||
ip link set dev lag1 addrgenmode none | ||
ip link set dev lag1 address $(mac_get $swp1) | ||
|
||
team_create lag2 lacp | ||
ip link set dev lag2 addrgenmode none | ||
ip link set dev lag2 address $(mac_get $swp2) | ||
|
||
ip link set dev $swp1 master lag1 | ||
ip link set dev $swp1 up | ||
|
||
ip link set dev $swp2 master lag2 | ||
ip link set dev $swp2 up | ||
} | ||
|
||
cleanup() | ||
{ | ||
pre_cleanup | ||
|
||
ip link set dev $swp2 nomaster | ||
ip link set dev $swp2 down | ||
|
||
ip link set dev $swp1 nomaster | ||
ip link set dev $swp1 down | ||
|
||
ip link del dev lag2 | ||
ip link del dev lag1 | ||
} | ||
|
||
lag_rif_add() | ||
{ | ||
RET=0 | ||
|
||
local rifs_occ_t0=$(devlink_resource_occ_get rifs) | ||
__addr_add_del lag1 add 192.0.2.2/28 | ||
sleep 1 | ||
local rifs_occ_t1=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0 + 1)) | ||
|
||
((expected_rifs == rifs_occ_t1)) | ||
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used" | ||
|
||
log_test "Add RIF for LAG on address addition" | ||
} | ||
|
||
lag_rif_nomaster() | ||
{ | ||
RET=0 | ||
|
||
local rifs_occ_t0=$(devlink_resource_occ_get rifs) | ||
ip link set dev $swp1 nomaster | ||
sleep 1 | ||
local rifs_occ_t1=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0 - 1)) | ||
|
||
((expected_rifs == rifs_occ_t1)) | ||
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used" | ||
|
||
log_test "Drop RIF for LAG on port deslavement" | ||
} | ||
|
||
lag_rif_remaster() | ||
{ | ||
RET=0 | ||
|
||
local rifs_occ_t0=$(devlink_resource_occ_get rifs) | ||
ip link set dev $swp1 down | ||
ip link set dev $swp1 master lag1 | ||
ip link set dev $swp1 up | ||
setup_wait_dev $swp1 | ||
local rifs_occ_t1=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0 + 1)) | ||
|
||
((expected_rifs == rifs_occ_t1)) | ||
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used" | ||
|
||
log_test "Add RIF for LAG on port reenslavement" | ||
} | ||
|
||
lag_rif_nomaster_addr() | ||
{ | ||
local rifs_occ_t0=$(devlink_resource_occ_get rifs) | ||
|
||
# Adding an address while the port is LAG'd shouldn't generate a RIF. | ||
__addr_add_del $swp1 add 192.0.2.65/28 | ||
sleep 1 | ||
local rifs_occ_t1=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0)) | ||
|
||
((expected_rifs == rifs_occ_t1)) | ||
check_err $? "After adding IP: Expected $expected_rifs RIFs, $rifs_occ_t1 are used" | ||
|
||
# Removing the port from LAG should drop RIF for the LAG (as tested in | ||
# lag_rif_nomaster), but since the port now has an address, it should | ||
# gain a RIF. | ||
ip link set dev $swp1 nomaster | ||
sleep 1 | ||
local rifs_occ_t2=$(devlink_resource_occ_get rifs) | ||
local expected_rifs=$((rifs_occ_t0)) | ||
|
||
((expected_rifs == rifs_occ_t2)) | ||
check_err $? "After deslaving: Expected $expected_rifs RIFs, $rifs_occ_t2 are used" | ||
|
||
__addr_add_del $swp1 del 192.0.2.65/28 | ||
log_test "Add RIF for port on deslavement from LAG" | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
setup_prepare | ||
setup_wait | ||
|
||
tests_run | ||
|
||
exit $EXIT_STATUS |
Oops, something went wrong.