~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/mlxsw/router_scale.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 ROUTER_NUM_NETIFS=4
  5 : ${TIMEOUT:=20000} # ms
  6 
  7 router_h1_create()
  8 {
  9         simple_if_init $h1 192.0.1.1/24
 10 }
 11 
 12 router_h1_destroy()
 13 {
 14         simple_if_fini $h1 192.0.1.1/24
 15 }
 16 
 17 router_h2_create()
 18 {
 19         simple_if_init $h2 192.0.2.1/24
 20         tc qdisc add dev $h2 handle ffff: ingress
 21 }
 22 
 23 router_h2_destroy()
 24 {
 25         tc qdisc del dev $h2 handle ffff: ingress
 26         simple_if_fini $h2 192.0.2.1/24
 27 }
 28 
 29 router_create()
 30 {
 31         ip link set dev $rp1 up
 32         ip link set dev $rp2 up
 33 
 34         ip address add 192.0.1.2/24 dev $rp1
 35         ip address add 192.0.2.2/24 dev $rp2
 36 }
 37 
 38 router_destroy()
 39 {
 40         ip address del 192.0.2.2/24 dev $rp2
 41         ip address del 192.0.1.2/24 dev $rp1
 42 
 43         ip link set dev $rp2 down
 44         ip link set dev $rp1 down
 45 }
 46 
 47 router_setup_prepare()
 48 {
 49         h1=${NETIFS[p1]}
 50         rp1=${NETIFS[p2]}
 51 
 52         rp2=${NETIFS[p3]}
 53         h2=${NETIFS[p4]}
 54 
 55         h1mac=$(mac_get $h1)
 56         rp1mac=$(mac_get $rp1)
 57 
 58         vrf_prepare
 59 
 60         router_h1_create
 61         router_h2_create
 62 
 63         router_create
 64 }
 65 
 66 wait_for_routes()
 67 {
 68         local t0=$1; shift
 69         local route_count=$1; shift
 70 
 71         local t1=$(ip route | grep 'offload' | grep -v 'offload_failed' | wc -l)
 72         local delta=$((t1 - t0))
 73         echo $delta
 74         [[ $delta -ge $route_count ]]
 75 }
 76 
 77 router_routes_create()
 78 {
 79         local route_count=$1
 80         local count=0
 81 
 82         ROUTE_FILE="$(mktemp)"
 83 
 84         for i in {0..255}
 85         do
 86                 for j in {0..255}
 87                 do
 88                         for k in {0..255}
 89                         do
 90                                 if [[ $count -eq $route_count ]]; then
 91                                         break 3
 92                                 fi
 93 
 94                                 echo route add 193.${i}.${j}.${k}/32 dev $rp2 \
 95                                         >> $ROUTE_FILE
 96                                 ((count++))
 97                         done
 98                 done
 99         done
100 
101         ip -b $ROUTE_FILE &> /dev/null
102 }
103 
104 router_routes_destroy()
105 {
106         if [[ -v ROUTE_FILE ]]; then
107                 rm -f $ROUTE_FILE
108         fi
109 }
110 
111 router_test()
112 {
113         local route_count=$1
114         local should_fail=$2
115         local delta
116 
117         RET=0
118 
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)
122 
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
126         fi
127 
128         router_routes_destroy
129 }
130 
131 router_cleanup()
132 {
133         pre_cleanup
134 
135         router_routes_destroy
136         router_destroy
137 
138         router_h2_destroy
139         router_h1_destroy
140 
141         vrf_cleanup
142 }

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php