Skip to content

Commit

Permalink
selftests: net: Fix bridge backup port test flakiness
Browse files Browse the repository at this point in the history
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 adding a one second delay after a carrier change in places where
a packet is sent immediately after 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: b408453 ("selftests: net: Add bridge backup port and backup nexthop ID test")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: NipaLocal <nipa@local>
  • Loading branch information
idosch authored and NipaLocal committed Feb 2, 2024
1 parent a2d7d91 commit 5686f2d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/testing/selftests/net/test_bridge_backup_port.sh
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ backup_port()

run_cmd "ip -n $sw1 link set dev swp1 carrier off"
log_test $? 0 "swp1 carrier off"
sleep 1

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"
tc_check_packets $sw1 "dev swp1 egress" 101 1
Expand All @@ -285,6 +286,7 @@ backup_port()

run_cmd "ip -n $sw1 link set dev swp1 carrier off"
log_test $? 0 "swp1 carrier off"
sleep 1

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"
tc_check_packets $sw1 "dev swp1 egress" 101 2
Expand All @@ -294,6 +296,7 @@ backup_port()

run_cmd "ip -n $sw1 link set dev swp1 carrier on"
log_test $? 0 "swp1 carrier on"
sleep 1

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"
tc_check_packets $sw1 "dev swp1 egress" 101 3
Expand All @@ -315,6 +318,7 @@ backup_port()

run_cmd "ip -n $sw1 link set dev swp1 carrier off"
log_test $? 0 "swp1 carrier off"
sleep 1

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"
tc_check_packets $sw1 "dev swp1 egress" 101 4
Expand Down Expand Up @@ -370,6 +374,7 @@ backup_nhid()

run_cmd "ip -n $sw1 link set dev swp1 carrier off"
log_test $? 0 "swp1 carrier off"
sleep 1

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"
tc_check_packets $sw1 "dev swp1 egress" 101 1
Expand Down Expand Up @@ -399,6 +404,7 @@ backup_nhid()

run_cmd "ip -n $sw1 link set dev swp1 carrier off"
log_test $? 0 "swp1 carrier off"
sleep 1

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"
tc_check_packets $sw1 "dev swp1 egress" 101 2
Expand All @@ -412,6 +418,7 @@ backup_nhid()

run_cmd "ip -n $sw1 link set dev swp1 carrier on"
log_test $? 0 "swp1 carrier on"
sleep 1

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"
tc_check_packets $sw1 "dev swp1 egress" 101 3
Expand Down Expand Up @@ -442,6 +449,7 @@ backup_nhid()

run_cmd "ip -n $sw1 link set dev swp1 carrier off"
log_test $? 0 "swp1 carrier off"
sleep 1

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"
tc_check_packets $sw1 "dev swp1 egress" 101 4
Expand Down Expand Up @@ -498,6 +506,7 @@ backup_nhid_invalid()

run_cmd "ip -n $sw1 link set dev swp1 carrier off"
log_test $? 0 "swp1 carrier off"
sleep 1

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"
tc_check_packets $sw1 "dev swp1 egress" 101 0
Expand Down Expand Up @@ -605,6 +614,7 @@ backup_nhid_ping()

run_cmd "ip -n $sw1 link set dev swp1 carrier off"
run_cmd "ip -n $sw2 link set dev swp1 carrier off"
sleep 1

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"
Expand Down

0 comments on commit 5686f2d

Please sign in to comment.