mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-08-19 07:34:10 +00:00

Running "make kselftest TARGETS=net/forwarding" results in multiple ccurrences of the same error: - ./lib.sh: line 787: teamd: command not found This patch adds the variable $REQUIRE_TEAMD in every test that uses the command teamd and checks the $REQUIRE_TEAMD variable in the file "lib.sh" to skip the test if the command is not installed. Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com> Link: https://patch.msgid.link/20250114003323.97207-1-alessandro.zanni87@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
138 lines
3.0 KiB
Bash
Executable File
138 lines
3.0 KiB
Bash
Executable File
#!/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
|
|
"
|
|
|
|
REQUIRE_TEAMD="yes"
|
|
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
|