WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / router_scale.sh
blobe93878d425969f64a4c64cfa0dc7d6cdbeaa1c86
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 ROUTER_NUM_NETIFS=4
5 : ${TIMEOUT:=20000} # ms
7 router_h1_create()
9 simple_if_init $h1 192.0.1.1/24
12 router_h1_destroy()
14 simple_if_fini $h1 192.0.1.1/24
17 router_h2_create()
19 simple_if_init $h2 192.0.2.1/24
20 tc qdisc add dev $h2 handle ffff: ingress
23 router_h2_destroy()
25 tc qdisc del dev $h2 handle ffff: ingress
26 simple_if_fini $h2 192.0.2.1/24
29 router_create()
31 ip link set dev $rp1 up
32 ip link set dev $rp2 up
34 ip address add 192.0.1.2/24 dev $rp1
35 ip address add 192.0.2.2/24 dev $rp2
38 router_destroy()
40 ip address del 192.0.2.2/24 dev $rp2
41 ip address del 192.0.1.2/24 dev $rp1
43 ip link set dev $rp2 down
44 ip link set dev $rp1 down
47 router_setup_prepare()
49 h1=${NETIFS[p1]}
50 rp1=${NETIFS[p2]}
52 rp2=${NETIFS[p3]}
53 h2=${NETIFS[p4]}
55 h1mac=$(mac_get $h1)
56 rp1mac=$(mac_get $rp1)
58 vrf_prepare
60 router_h1_create
61 router_h2_create
63 router_create
66 wait_for_routes()
68 local t0=$1; shift
69 local route_count=$1; shift
71 local t1=$(ip route | grep -o 'offload' | wc -l)
72 local delta=$((t1 - t0))
73 echo $delta
74 [[ $delta -ge $route_count ]]
77 router_routes_create()
79 local route_count=$1
80 local count=0
82 ROUTE_FILE="$(mktemp)"
84 for i in {0..255}
86 for j in {0..255}
88 for k in {0..255}
90 if [[ $count -eq $route_count ]]; then
91 break 3
94 echo route add 193.${i}.${j}.${k}/32 dev $rp2 \
95 >> $ROUTE_FILE
96 ((count++))
97 done
98 done
99 done
101 ip -b $ROUTE_FILE &> /dev/null
104 router_routes_destroy()
106 if [[ -v ROUTE_FILE ]]; then
107 rm -f $ROUTE_FILE
111 router_test()
113 local route_count=$1
114 local should_fail=$2
115 local delta
117 RET=0
119 local t0=$(ip route | grep -o 'offload' | wc -l)
120 router_routes_create $route_count
121 delta=$(busywait "$TIMEOUT" wait_for_routes $t0 $route_count)
123 check_err_fail $should_fail $? "Offload routes: Expected $route_count, got $delta."
124 if [[ $RET -ne 0 ]] || [[ $should_fail -eq 1 ]]; then
125 return
128 router_routes_destroy
131 router_cleanup()
133 pre_cleanup
135 router_routes_destroy
136 router_destroy
138 router_h2_destroy
139 router_h1_destroy
141 vrf_cleanup