staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / router_scale.sh
blobd231649b4f01e405db11741be5dcde9e699619d9
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 ROUTER_NUM_NETIFS=4
6 router_h1_create()
8 simple_if_init $h1 192.0.1.1/24
9 ip route add 193.0.0.0/8 via 192.0.1.2 dev $h1
12 router_h1_destroy()
14 ip route del 193.0.0.0/8 via 192.0.1.2 dev $h1
15 simple_if_fini $h1 192.0.1.1/24
18 router_h2_create()
20 simple_if_init $h2 192.0.2.1/24
21 tc qdisc add dev $h2 handle ffff: ingress
24 router_h2_destroy()
26 tc qdisc del dev $h2 handle ffff: ingress
27 simple_if_fini $h2 192.0.2.1/24
30 router_create()
32 ip link set dev $rp1 up
33 ip link set dev $rp2 up
35 ip address add 192.0.1.2/24 dev $rp1
36 ip address add 192.0.2.2/24 dev $rp2
39 router_destroy()
41 ip address del 192.0.2.2/24 dev $rp2
42 ip address del 192.0.1.2/24 dev $rp1
44 ip link set dev $rp2 down
45 ip link set dev $rp1 down
48 router_setup_prepare()
50 h1=${NETIFS[p1]}
51 rp1=${NETIFS[p2]}
53 rp2=${NETIFS[p3]}
54 h2=${NETIFS[p4]}
56 h1mac=$(mac_get $h1)
57 rp1mac=$(mac_get $rp1)
59 vrf_prepare
61 router_h1_create
62 router_h2_create
64 router_create
67 router_offload_validate()
69 local route_count=$1
70 local offloaded_count
72 offloaded_count=$(ip route | grep -o 'offload' | wc -l)
73 [[ $offloaded_count -ge $route_count ]]
76 router_routes_create()
78 local route_count=$1
79 local count=0
81 ROUTE_FILE="$(mktemp)"
83 for i in {0..255}
85 for j in {0..255}
87 for k in {0..255}
89 if [[ $count -eq $route_count ]]; then
90 break 3
93 echo route add 193.${i}.${j}.${k}/32 via \
94 192.0.2.1 dev $rp2 >> $ROUTE_FILE
95 ((count++))
96 done
97 done
98 done
100 ip -b $ROUTE_FILE &> /dev/null
103 router_routes_destroy()
105 if [[ -v ROUTE_FILE ]]; then
106 rm -f $ROUTE_FILE
110 router_test()
112 local route_count=$1
113 local should_fail=$2
114 local count=0
116 RET=0
118 router_routes_create $route_count
120 router_offload_validate $route_count
121 check_err_fail $should_fail $? "Offload of $route_count routes"
122 if [[ $RET -ne 0 ]] || [[ $should_fail -eq 1 ]]; then
123 return
126 tc filter add dev $h2 ingress protocol ip pref 1 flower \
127 skip_sw dst_ip 193.0.0.0/8 action drop
129 for i in {0..255}
131 for j in {0..255}
133 for k in {0..255}
135 if [[ $count -eq $route_count ]]; then
136 break 3
139 $MZ $h1 -c 1 -p 64 -a $h1mac -b $rp1mac \
140 -A 192.0.1.1 -B 193.${i}.${j}.${k} \
141 -t ip -q
142 ((count++))
143 done
144 done
145 done
147 tc_check_packets "dev $h2 ingress" 1 $route_count
148 check_err $? "Offload mismatch"
150 tc filter del dev $h2 ingress protocol ip pref 1 flower \
151 skip_sw dst_ip 193.0.0.0/8 action drop
153 router_routes_destroy
156 router_cleanup()
158 pre_cleanup
160 router_routes_destroy
161 router_destroy
163 router_h2_destroy
164 router_h1_destroy
166 vrf_cleanup