Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / net / forwarding / router_bridge_1d_lag.sh
blobe064b946e8213b24d54e10c9e482a478481a3eae
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # +--------------------------------------------+
5 # | H1 (vrf) |
6 # | |
7 # | + LAG1.100 + LAG1.200 |
8 # | | 192.0.2.1/28 | 192.0.2.17/28 |
9 # | | 2001:db8:1::1/64 | 2001:db8:3:1/64 |
10 # | \___________ _______/ |
11 # | v |
12 # | + LAG1 (team) |
13 # | | |
14 # | ____^____ |
15 # | / \ |
16 # | + $h1 + $h4 |
17 # | | | |
18 # +----------|-----------|---------------------+
19 # | |
20 # +----------|-----------|---------------------+
21 # | SW | | |
22 # | + $swp1 + $swp4 |
23 # | \____ ____/ |
24 # | v |
25 # | LAG2 (team) + |
26 # | | |
27 # | _______^______________ |
28 # | / \ |
29 # | +------|------------+ +-------|----------+ |
30 # | | + LAG2.100 | | + LAG2.200 | |
31 # | | | | | |
32 # | | BR1 (802.1d) | | BR2 (802.1d) | |
33 # | | 192.0.2.2/28 | | 192.0.2.18/28 | |
34 # | | 2001:db8:1::2/64 | | 2001:db8:3:2/64 | |
35 # | | | | | |
36 # | +-------------------+ +------------------+ |
37 # | |
38 # | + LAG3.100 + LAG3.200 |
39 # | | 192.0.2.129/28 | 192.0.2.145/28 |
40 # | | 2001:db8:2::1/64 | 2001:db8:4::1/64 |
41 # | | | |
42 # | \_________ ___________/ |
43 # | v |
44 # | + LAG3 (team) |
45 # | ____|____ |
46 # | / \ |
47 # | + $swp2 + $swp3 |
48 # | | | |
49 # +-------|---------|--------------------------+
50 # | |
51 # +-------|---------|--------------------------+
52 # | | | |
53 # | + $h2 + $h3 |
54 # | \____ ___/ |
55 # | | |
56 # | + LAG4 (team) |
57 # | | |
58 # | __________^__________ |
59 # | / \ |
60 # | | | |
61 # | + LAG4.100 + LAG4.200 |
62 # | 192.0.2.130/28 192.0.2.146/28 |
63 # | 2001:db8:2::2/64 2001:db8:4::2/64 |
64 # | |
65 # | H2 (vrf) |
66 # +--------------------------------------------+
68 ALL_TESTS="
69 ping_ipv4
70 ping_ipv6
72 $(: exercise remastering of LAG2 slaves )
73 config_deslave_swp4
74 config_wait
75 ping_ipv4
76 ping_ipv6
77 config_enslave_swp4
78 config_deslave_swp1
79 config_wait
80 ping_ipv4
81 ping_ipv6
82 config_deslave_swp4
83 config_enslave_swp1
84 config_enslave_swp4
85 config_wait
86 ping_ipv4
87 ping_ipv6
89 $(: exercise remastering of LAG2 itself )
90 config_remaster_lag2
91 config_wait
92 ping_ipv4
93 ping_ipv6
95 $(: exercise remastering of LAG3 slaves )
96 config_deslave_swp2
97 config_wait
98 ping_ipv4
99 ping_ipv6
100 config_enslave_swp2
101 config_deslave_swp3
102 config_wait
103 ping_ipv4
104 ping_ipv6
105 config_deslave_swp2
106 config_enslave_swp3
107 config_enslave_swp2
108 config_wait
109 ping_ipv4
110 ping_ipv6
112 NUM_NETIFS=8
113 source lib.sh
115 h1_create()
117 team_create lag1 lacp
118 ip link set dev lag1 addrgenmode none
119 ip link set dev lag1 address $(mac_get $h1)
120 ip link set dev $h1 master lag1
121 ip link set dev $h4 master lag1
122 simple_if_init lag1
123 ip link set dev $h1 up
124 ip link set dev $h4 up
126 vlan_create lag1 100 vlag1 192.0.2.1/28 2001:db8:1::1/64
127 vlan_create lag1 200 vlag1 192.0.2.17/28 2001:db8:3::1/64
129 ip -4 route add 192.0.2.128/28 vrf vlag1 nexthop via 192.0.2.2
130 ip -6 route add 2001:db8:2::/64 vrf vlag1 nexthop via 2001:db8:1::2
132 ip -4 route add 192.0.2.144/28 vrf vlag1 nexthop via 192.0.2.18
133 ip -6 route add 2001:db8:4::/64 vrf vlag1 nexthop via 2001:db8:3::2
136 h1_destroy()
138 ip -6 route del 2001:db8:4::/64 vrf vlag1
139 ip -4 route del 192.0.2.144/28 vrf vlag1
141 ip -6 route del 2001:db8:2::/64 vrf vlag1
142 ip -4 route del 192.0.2.128/28 vrf vlag1
144 vlan_destroy lag1 200
145 vlan_destroy lag1 100
147 ip link set dev $h4 down
148 ip link set dev $h1 down
149 simple_if_fini lag1
150 ip link set dev $h4 nomaster
151 ip link set dev $h1 nomaster
152 team_destroy lag1
155 h2_create()
157 team_create lag4 lacp
158 ip link set dev lag4 addrgenmode none
159 ip link set dev lag4 address $(mac_get $h2)
160 ip link set dev $h2 master lag4
161 ip link set dev $h3 master lag4
162 simple_if_init lag4
163 ip link set dev $h2 up
164 ip link set dev $h3 up
166 vlan_create lag4 100 vlag4 192.0.2.130/28 2001:db8:2::2/64
167 vlan_create lag4 200 vlag4 192.0.2.146/28 2001:db8:4::2/64
169 ip -4 route add 192.0.2.0/28 vrf vlag4 nexthop via 192.0.2.129
170 ip -6 route add 2001:db8:1::/64 vrf vlag4 nexthop via 2001:db8:2::1
172 ip -4 route add 192.0.2.16/28 vrf vlag4 nexthop via 192.0.2.145
173 ip -6 route add 2001:db8:3::/64 vrf vlag4 nexthop via 2001:db8:4::1
176 h2_destroy()
178 ip -6 route del 2001:db8:3::/64 vrf vlag4
179 ip -4 route del 192.0.2.16/28 vrf vlag4
181 ip -6 route del 2001:db8:1::/64 vrf vlag4
182 ip -4 route del 192.0.2.0/28 vrf vlag4
184 vlan_destroy lag4 200
185 vlan_destroy lag4 100
187 ip link set dev $h3 down
188 ip link set dev $h2 down
189 simple_if_fini lag4
190 ip link set dev $h3 nomaster
191 ip link set dev $h2 nomaster
192 team_destroy lag4
195 router_create()
197 team_create lag2 lacp
198 ip link set dev lag2 addrgenmode none
199 ip link set dev lag2 address $(mac_get $swp1)
200 ip link set dev $swp1 master lag2
201 ip link set dev $swp4 master lag2
203 vlan_create lag2 100
204 vlan_create lag2 200
206 ip link add name br1 type bridge vlan_filtering 0
207 ip link set dev br1 address $(mac_get lag2.100)
208 ip link set dev lag2.100 master br1
210 ip link add name br2 type bridge vlan_filtering 0
211 ip link set dev br2 address $(mac_get lag2.200)
212 ip link set dev lag2.200 master br2
214 ip link set dev $swp1 up
215 ip link set dev $swp4 up
216 ip link set dev br1 up
217 ip link set dev br2 up
219 __addr_add_del br1 add 192.0.2.2/28 2001:db8:1::2/64
220 __addr_add_del br2 add 192.0.2.18/28 2001:db8:3::2/64
222 team_create lag3 lacp
223 ip link set dev lag3 addrgenmode none
224 ip link set dev lag3 address $(mac_get $swp2)
225 ip link set dev $swp2 master lag3
226 ip link set dev $swp3 master lag3
227 ip link set dev $swp2 up
228 ip link set dev $swp3 up
230 vlan_create lag3 100
231 vlan_create lag3 200
233 __addr_add_del lag3.100 add 192.0.2.129/28 2001:db8:2::1/64
234 __addr_add_del lag3.200 add 192.0.2.145/28 2001:db8:4::1/64
237 router_destroy()
239 __addr_add_del lag3.200 del 192.0.2.145/28 2001:db8:4::1/64
240 __addr_add_del lag3.100 del 192.0.2.129/28 2001:db8:2::1/64
242 vlan_destroy lag3 200
243 vlan_destroy lag3 100
245 ip link set dev $swp3 down
246 ip link set dev $swp2 down
247 ip link set dev $swp3 nomaster
248 ip link set dev $swp2 nomaster
249 team_destroy lag3
251 __addr_add_del br2 del 192.0.2.18/28 2001:db8:3::2/64
252 __addr_add_del br1 del 192.0.2.2/28 2001:db8:1::2/64
254 ip link set dev br2 down
255 ip link set dev br1 down
256 ip link set dev $swp4 down
257 ip link set dev $swp1 down
259 ip link set dev lag2.200 nomaster
260 ip link del dev br2
262 ip link set dev lag2.100 nomaster
263 ip link del dev br1
265 vlan_destroy lag2 200
266 vlan_destroy lag2 100
268 ip link set dev $swp4 nomaster
269 ip link set dev $swp1 nomaster
270 team_destroy lag2
273 config_remaster_lag2()
275 log_info "Remaster bridge slaves"
277 ip link set dev lag2.200 nomaster
278 ip link set dev lag2.100 nomaster
279 sleep 2
280 ip link set dev lag2.100 master br1
281 ip link set dev lag2.200 master br2
284 config_deslave()
286 local netdev=$1; shift
288 log_info "Deslave $netdev"
289 ip link set dev $netdev down
290 ip link set dev $netdev nomaster
291 ip link set dev $netdev up
294 config_deslave_swp1()
296 config_deslave $swp1
299 config_deslave_swp2()
301 config_deslave $swp2
304 config_deslave_swp3()
306 config_deslave $swp3
309 config_deslave_swp4()
311 config_deslave $swp4
314 config_enslave()
316 local netdev=$1; shift
317 local master=$1; shift
319 log_info "Enslave $netdev to $master"
320 ip link set dev $netdev down
321 ip link set dev $netdev master $master
322 ip link set dev $netdev up
325 config_enslave_swp1()
327 config_enslave $swp1 lag2
330 config_enslave_swp2()
332 config_enslave $swp2 lag3
335 config_enslave_swp3()
337 config_enslave $swp3 lag3
340 config_enslave_swp4()
342 config_enslave $swp4 lag2
345 config_wait()
347 setup_wait_dev lag2
348 setup_wait_dev lag3
351 setup_prepare()
353 h1=${NETIFS[p1]}
354 swp1=${NETIFS[p2]}
356 swp2=${NETIFS[p3]}
357 h2=${NETIFS[p4]}
359 swp3=${NETIFS[p5]}
360 h3=${NETIFS[p6]}
362 h4=${NETIFS[p7]}
363 swp4=${NETIFS[p8]}
365 vrf_prepare
367 h1_create
368 h2_create
370 router_create
372 forwarding_enable
375 cleanup()
377 pre_cleanup
379 forwarding_restore
381 router_destroy
383 h2_destroy
384 h1_destroy
386 vrf_cleanup
389 ping_ipv4()
391 ping_test lag1.100 192.0.2.130 ": via 100"
392 ping_test lag1.200 192.0.2.146 ": via 200"
395 ping_ipv6()
397 ping6_test lag1.100 2001:db8:2::2 ": via 100"
398 ping6_test lag1.200 2001:db8:4::2 ": via 200"
401 trap cleanup EXIT
403 setup_prepare
404 setup_wait
406 tests_run
408 exit $EXIT_STATUS