mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
selftests: net: Fix bridge backup port test flakiness
The test toggles the carrier of a bridge port in order to test the
bridge backup port feature.
Due to the linkwatch delayed work the carrier change is not always
reflected fast enough to the bridge driver and packets are not forwarded
as the test expects, resulting in failures [1].
Fix by busy waiting on the bridge port state until it changes to the
desired state following the carrier change.
[1]
# Backup port
# -----------
[...]
# TEST: swp1 carrier off [ OK ]
# TEST: No forwarding out of swp1 [FAIL]
[ 641.995910] br0: port 1(swp1) entered disabled state
# TEST: No forwarding out of vx0 [ OK ]
Fixes: b408453053
("selftests: net: Add bridge backup port and backup nexthop ID test")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://lore.kernel.org/r/20240208123110.1063930-1-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
02d9009f4e
commit
38ee0cb2a2
@ -124,6 +124,16 @@ tc_check_packets()
|
||||
[[ $pkts == $count ]]
|
||||
}
|
||||
|
||||
bridge_link_check()
|
||||
{
|
||||
local ns=$1; shift
|
||||
local dev=$1; shift
|
||||
local state=$1; shift
|
||||
|
||||
bridge -n $ns -d -j link show dev $dev | \
|
||||
jq -e ".[][\"state\"] == \"$state\"" &> /dev/null
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Setup
|
||||
|
||||
@ -259,6 +269,7 @@ backup_port()
|
||||
log_test $? 0 "No forwarding out of vx0"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier off"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 disabled
|
||||
log_test $? 0 "swp1 carrier off"
|
||||
|
||||
run_cmd "ip netns exec $sw1 mausezahn br0.10 -a $smac -b $dmac -A 198.51.100.1 -B 198.51.100.2 -t ip -p 100 -q -c 1"
|
||||
@ -268,6 +279,7 @@ backup_port()
|
||||
log_test $? 0 "No forwarding out of vx0"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier on"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 forwarding
|
||||
log_test $? 0 "swp1 carrier on"
|
||||
|
||||
# Configure vx0 as the backup port of swp1 and check that packets are
|
||||
@ -284,6 +296,7 @@ backup_port()
|
||||
log_test $? 0 "No forwarding out of vx0"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier off"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 disabled
|
||||
log_test $? 0 "swp1 carrier off"
|
||||
|
||||
run_cmd "ip netns exec $sw1 mausezahn br0.10 -a $smac -b $dmac -A 198.51.100.1 -B 198.51.100.2 -t ip -p 100 -q -c 1"
|
||||
@ -293,6 +306,7 @@ backup_port()
|
||||
log_test $? 0 "Forwarding out of vx0"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier on"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 forwarding
|
||||
log_test $? 0 "swp1 carrier on"
|
||||
|
||||
run_cmd "ip netns exec $sw1 mausezahn br0.10 -a $smac -b $dmac -A 198.51.100.1 -B 198.51.100.2 -t ip -p 100 -q -c 1"
|
||||
@ -314,6 +328,7 @@ backup_port()
|
||||
log_test $? 0 "No forwarding out of vx0"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier off"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 disabled
|
||||
log_test $? 0 "swp1 carrier off"
|
||||
|
||||
run_cmd "ip netns exec $sw1 mausezahn br0.10 -a $smac -b $dmac -A 198.51.100.1 -B 198.51.100.2 -t ip -p 100 -q -c 1"
|
||||
@ -369,6 +384,7 @@ backup_nhid()
|
||||
log_test $? 0 "No forwarding out of vx0"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier off"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 disabled
|
||||
log_test $? 0 "swp1 carrier off"
|
||||
|
||||
run_cmd "ip netns exec $sw1 mausezahn br0.10 -a $smac -b $dmac -A 198.51.100.1 -B 198.51.100.2 -t ip -p 100 -q -c 1"
|
||||
@ -382,6 +398,7 @@ backup_nhid()
|
||||
log_test $? 0 "Forwarding using VXLAN FDB entry"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier on"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 forwarding
|
||||
log_test $? 0 "swp1 carrier on"
|
||||
|
||||
# Configure nexthop ID 10 as the backup nexthop ID of swp1 and check
|
||||
@ -398,6 +415,7 @@ backup_nhid()
|
||||
log_test $? 0 "No forwarding out of vx0"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier off"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 disabled
|
||||
log_test $? 0 "swp1 carrier off"
|
||||
|
||||
run_cmd "ip netns exec $sw1 mausezahn br0.10 -a $smac -b $dmac -A 198.51.100.1 -B 198.51.100.2 -t ip -p 100 -q -c 1"
|
||||
@ -411,6 +429,7 @@ backup_nhid()
|
||||
log_test $? 0 "No forwarding using VXLAN FDB entry"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier on"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 forwarding
|
||||
log_test $? 0 "swp1 carrier on"
|
||||
|
||||
run_cmd "ip netns exec $sw1 mausezahn br0.10 -a $smac -b $dmac -A 198.51.100.1 -B 198.51.100.2 -t ip -p 100 -q -c 1"
|
||||
@ -441,6 +460,7 @@ backup_nhid()
|
||||
log_test $? 0 "No forwarding using VXLAN FDB entry"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier off"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 disabled
|
||||
log_test $? 0 "swp1 carrier off"
|
||||
|
||||
run_cmd "ip netns exec $sw1 mausezahn br0.10 -a $smac -b $dmac -A 198.51.100.1 -B 198.51.100.2 -t ip -p 100 -q -c 1"
|
||||
@ -497,6 +517,7 @@ backup_nhid_invalid()
|
||||
log_test $? 0 "Valid nexthop as backup nexthop"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier off"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 disabled
|
||||
log_test $? 0 "swp1 carrier off"
|
||||
|
||||
run_cmd "ip netns exec $sw1 mausezahn br0.10 -a $smac -b $dmac -A 198.51.100.1 -B 198.51.100.2 -t ip -p 100 -q -c 1"
|
||||
@ -604,7 +625,9 @@ backup_nhid_ping()
|
||||
run_cmd "bridge -n $sw2 link set dev swp1 backup_nhid 10"
|
||||
|
||||
run_cmd "ip -n $sw1 link set dev swp1 carrier off"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw1 swp1 disabled
|
||||
run_cmd "ip -n $sw2 link set dev swp1 carrier off"
|
||||
busywait $BUSYWAIT_TIMEOUT bridge_link_check $sw2 swp1 disabled
|
||||
|
||||
run_cmd "ip netns exec $sw1 ping -i 0.1 -c 10 -w $PING_TIMEOUT 192.0.2.66"
|
||||
log_test $? 0 "Ping with backup nexthop ID"
|
||||
|
Loading…
Reference in New Issue
Block a user