selftests: mlxsw: Reduce router scale running time using offload indication

Currently, the test inserts X /32 routes and for each route it is
testing that a packet sent from the first host is received by the second
host, which is very time-consuming.

Instead only validate the offload flag of each route and get the same result.

Wait between the creation of the routes and the offload validation in
order to make sure that all the routes were successfully offloaded.

Signed-off-by: Danielle Ratson <danieller@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Danielle Ratson 2020-02-27 08:50:20 +01:00 committed by David S. Miller
parent abfce9e062
commit e781eedae2

View File

@ -2,16 +2,15 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
ROUTER_NUM_NETIFS=4 ROUTER_NUM_NETIFS=4
: ${TIMEOUT:=20000} # ms
router_h1_create() router_h1_create()
{ {
simple_if_init $h1 192.0.1.1/24 simple_if_init $h1 192.0.1.1/24
ip route add 193.0.0.0/8 via 192.0.1.2 dev $h1
} }
router_h1_destroy() router_h1_destroy()
{ {
ip route del 193.0.0.0/8 via 192.0.1.2 dev $h1
simple_if_fini $h1 192.0.1.1/24 simple_if_fini $h1 192.0.1.1/24
} }
@ -64,13 +63,15 @@ router_setup_prepare()
router_create router_create
} }
router_offload_validate() wait_for_routes()
{ {
local route_count=$1 local t0=$1; shift
local offloaded_count local route_count=$1; shift
offloaded_count=$(ip route | grep -o 'offload' | wc -l) local t1=$(ip route | grep -o 'offload' | wc -l)
[[ $offloaded_count -ge $route_count ]] local delta=$((t1 - t0))
echo $delta
[[ $delta -ge $route_count ]]
} }
router_routes_create() router_routes_create()
@ -90,8 +91,8 @@ router_routes_create()
break 3 break 3
fi fi
echo route add 193.${i}.${j}.${k}/32 via \ echo route add 193.${i}.${j}.${k}/32 dev $rp2 \
192.0.2.1 dev $rp2 >> $ROUTE_FILE >> $ROUTE_FILE
((count++)) ((count++))
done done
done done
@ -111,45 +112,19 @@ router_test()
{ {
local route_count=$1 local route_count=$1
local should_fail=$2 local should_fail=$2
local count=0 local delta
RET=0 RET=0
local t0=$(ip route | grep -o 'offload' | wc -l)
router_routes_create $route_count router_routes_create $route_count
delta=$(busywait "$TIMEOUT" wait_for_routes $t0 $route_count)
router_offload_validate $route_count check_err_fail $should_fail $? "Offload routes: Expected $route_count, got $delta."
check_err_fail $should_fail $? "Offload of $route_count routes"
if [[ $RET -ne 0 ]] || [[ $should_fail -eq 1 ]]; then if [[ $RET -ne 0 ]] || [[ $should_fail -eq 1 ]]; then
return return
fi fi
tc filter add dev $h2 ingress protocol ip pref 1 flower \
skip_sw dst_ip 193.0.0.0/8 action drop
for i in {0..255}
do
for j in {0..255}
do
for k in {0..255}
do
if [[ $count -eq $route_count ]]; then
break 3
fi
$MZ $h1 -c 1 -p 64 -a $h1mac -b $rp1mac \
-A 192.0.1.1 -B 193.${i}.${j}.${k} \
-t ip -q
((count++))
done
done
done
tc_check_packets "dev $h2 ingress" 1 $route_count
check_err $? "Offload mismatch"
tc filter del dev $h2 ingress protocol ip pref 1 flower \
skip_sw dst_ip 193.0.0.0/8 action drop
router_routes_destroy router_routes_destroy
} }