WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / ip6gre_inner_v6_multipath.sh
blobd208f5243adea226fa79603e423d96aace59da02
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Test traffic distribution when there are multiple routes between an IPv6
5 # GRE tunnel. The tunnel carries IPv6 traffic between multiple hosts.
6 # Multiple routes are in the underlay network. With the default multipath
7 # policy, SW2 will only look at the outer IP addresses, hence only a single
8 # route would be used.
10 # +-------------------------+
11 # | H1 |
12 # | $h1 + |
13 # | 2001:db8:1::2/64 | |
14 # +-------------------|-----+
15 # |
16 # +-------------------|-------------------------+
17 # | SW1 | |
18 # | $ol1 + |
19 # | 2001:db8:1::1/64 |
20 # | |
21 # | + g1 (gre) |
22 # | loc=2001:db8:40::1 |
23 # | rem=2001:db8:40::2 --. |
24 # | tos=inherit | |
25 # | v |
26 # | + $ul1 |
27 # | | 2001:db8:80::1/64 |
28 # +-------------------------|-------------------+
29 # |
30 # +-------------------------|-------------------+
31 # | SW2 | |
32 # | $ul21 + |
33 # | 2001:db8:80::2/64 |
34 # | | |
35 # ! ________________|_____ |
36 # | / \ |
37 # | | | |
38 # | + $ul22.111 (vlan) + $ul22.222 (vlan) |
39 # | | 2001:db8:81::1/64 | 2001:db8:82::1/64 |
40 # | | | |
41 # +--|----------------------|-------------------+
42 # | |
43 # +--|----------------------|-------------------+
44 # | | | |
45 # | + $ul32.111 (vlan) + $ul32.222 (vlan) |
46 # | | 2001:db8:81::2/64 | 2001:db8:82::2/64 |
47 # | | | |
48 # | \______________________/ |
49 # | | |
50 # | | |
51 # | $ul31 + |
52 # | 2001:db8:83::2/64 | SW3 |
53 # +-------------------------|-------------------+
54 # |
55 # +-------------------------|-------------------+
56 # | + $ul4 |
57 # | ^ 2001:db8:83::1/64 |
58 # | + g2 (gre) | |
59 # | loc=2001:db8:40::2 | |
60 # | rem=2001:db8:40::1 --' |
61 # | tos=inherit |
62 # | |
63 # | $ol4 + |
64 # | 2001:db8:2::1/64 | SW4 |
65 # +--------------------|------------------------+
66 # |
67 # +--------------------|---------+
68 # | | |
69 # | $h2 + |
70 # | 2001:db8:2::2/64 H2 |
71 # +------------------------------+
73 ALL_TESTS="
74 ping_ipv6
75 multipath_ipv6
78 NUM_NETIFS=10
79 source lib.sh
81 h1_create()
83 simple_if_init $h1 2001:db8:1::2/64
84 ip -6 route add vrf v$h1 2001:db8:2::/64 via 2001:db8:1::1
87 h1_destroy()
89 ip -6 route del vrf v$h1 2001:db8:2::/64 via 2001:db8:1::1
90 simple_if_fini $h1 2001:db8:1::2/64
93 sw1_create()
95 simple_if_init $ol1 2001:db8:1::1/64
96 __simple_if_init $ul1 v$ol1 2001:db8:80::1/64
98 tunnel_create g1 ip6gre 2001:db8:40::1 2001:db8:40::2 tos inherit dev v$ol1
99 __simple_if_init g1 v$ol1 2001:db8:40::1/128
100 ip -6 route add vrf v$ol1 2001:db8:40::2/128 via 2001:db8:80::2
102 ip -6 route add vrf v$ol1 2001:db8:2::/64 dev g1
105 sw1_destroy()
107 ip -6 route del vrf v$ol1 2001:db8:2::/64
109 ip -6 route del vrf v$ol1 2001:db8:40::2/128
110 __simple_if_fini g1 2001:db8:40::1/128
111 tunnel_destroy g1
113 __simple_if_fini $ul1 2001:db8:80::1/64
114 simple_if_fini $ol1 2001:db8:1::1/64
117 sw2_create()
119 simple_if_init $ul21 2001:db8:80::2/64
120 __simple_if_init $ul22 v$ul21
121 vlan_create $ul22 111 v$ul21 2001:db8:81::1/64
122 vlan_create $ul22 222 v$ul21 2001:db8:82::1/64
124 ip -6 route add vrf v$ul21 2001:db8:40::1/128 via 2001:db8:80::1
125 ip -6 route add vrf v$ul21 2001:db8:40::2/128 \
126 nexthop via 2001:db8:81::2 \
127 nexthop via 2001:db8:82::2
130 sw2_destroy()
132 ip -6 route del vrf v$ul21 2001:db8:40::2/128
133 ip -6 route del vrf v$ul21 2001:db8:40::1/128
135 vlan_destroy $ul22 222
136 vlan_destroy $ul22 111
137 __simple_if_fini $ul22
138 simple_if_fini $ul21 2001:db8:80::2/64
141 sw3_create()
143 simple_if_init $ul31 2001:db8:83::2/64
144 __simple_if_init $ul32 v$ul31
145 vlan_create $ul32 111 v$ul31 2001:db8:81::2/64
146 vlan_create $ul32 222 v$ul31 2001:db8:82::2/64
148 ip -6 route add vrf v$ul31 2001:db8:40::2/128 via 2001:db8:83::1
149 ip -6 route add vrf v$ul31 2001:db8:40::1/128 \
150 nexthop via 2001:db8:81::1 \
151 nexthop via 2001:db8:82::1
153 tc qdisc add dev $ul32 clsact
154 tc filter add dev $ul32 ingress pref 111 prot 802.1Q \
155 flower vlan_id 111 action pass
156 tc filter add dev $ul32 ingress pref 222 prot 802.1Q \
157 flower vlan_id 222 action pass
160 sw3_destroy()
162 tc qdisc del dev $ul32 clsact
164 ip -6 route del vrf v$ul31 2001:db8:40::1/128
165 ip -6 route del vrf v$ul31 2001:db8:40::2/128
167 vlan_destroy $ul32 222
168 vlan_destroy $ul32 111
169 __simple_if_fini $ul32
170 simple_if_fini $ul31 2001:Db8:83::2/64
173 sw4_create()
175 simple_if_init $ol4 2001:db8:2::1/64
176 __simple_if_init $ul4 v$ol4 2001:db8:83::1/64
178 tunnel_create g2 ip6gre 2001:db8:40::2 2001:db8:40::1 tos inherit dev v$ol4
179 __simple_if_init g2 v$ol4 2001:db8:40::2/128
180 ip -6 route add vrf v$ol4 2001:db8:40::1/128 via 2001:db8:83::2
182 ip -6 route add vrf v$ol4 2001:db8:1::/64 dev g2
185 sw4_destroy()
187 ip -6 route del vrf v$ol4 2001:db8:1::/64
189 ip -6 route del vrf v$ol4 2001:db8:40::1/128
190 __simple_if_fini g2 2001:db8:40::2/128
191 tunnel_destroy g2
193 __simple_if_fini $ul4 2001:db8:83::1/64
194 simple_if_fini $ol4 2001:db8:2::1/64
197 h2_create()
199 simple_if_init $h2 2001:db8:2::2/64
200 ip -6 route add vrf v$h2 2001:db8:1::/64 via 2001:db8:2::1
203 h2_destroy()
205 ip -6 route del vrf v$h2 2001:db8:1::/64 via 2001:db8:2::1
206 simple_if_fini $h2 2001:db8:2::2/64
209 setup_prepare()
211 h1=${NETIFS[p1]}
213 ol1=${NETIFS[p2]}
214 ul1=${NETIFS[p3]}
216 ul21=${NETIFS[p4]}
217 ul22=${NETIFS[p5]}
219 ul32=${NETIFS[p6]}
220 ul31=${NETIFS[p7]}
222 ul4=${NETIFS[p8]}
223 ol4=${NETIFS[p9]}
225 h2=${NETIFS[p10]}
227 vrf_prepare
228 h1_create
229 sw1_create
230 sw2_create
231 sw3_create
232 sw4_create
233 h2_create
235 forwarding_enable
238 cleanup()
240 pre_cleanup
242 forwarding_restore
244 h2_destroy
245 sw4_destroy
246 sw3_destroy
247 sw2_destroy
248 sw1_destroy
249 h1_destroy
250 vrf_cleanup
253 multipath6_test()
255 local what=$1; shift
256 local weight1=$1; shift
257 local weight2=$1; shift
259 sysctl_set net.ipv6.fib_multipath_hash_policy 2
260 ip route replace vrf v$ul21 2001:db8:40::2/128 \
261 nexthop via 2001:db8:81::2 weight $weight1 \
262 nexthop via 2001:db8:82::2 weight $weight2
264 local t0_111=$(tc_rule_stats_get $ul32 111 ingress)
265 local t0_222=$(tc_rule_stats_get $ul32 222 ingress)
267 ip vrf exec v$h1 \
268 $MZ $h1 -6 -q -p 64 -A "2001:db8:1::2-2001:db8:1::1e" \
269 -B "2001:db8:2::2-2001:db8:2::1e" \
270 -d 1msec -c 50 -t udp "sp=1024,dp=1024"
271 sleep 1
273 local t1_111=$(tc_rule_stats_get $ul32 111 ingress)
274 local t1_222=$(tc_rule_stats_get $ul32 222 ingress)
276 local d111=$((t1_111 - t0_111))
277 local d222=$((t1_222 - t0_222))
278 multipath_eval "$what" $weight1 $weight2 $d111 $d222
280 ip route replace vrf v$ul21 2001:db8:40::2/128 \
281 nexthop via 2001:db8:81::2 \
282 nexthop via 2001:db8:82::2
283 sysctl_restore net.ipv6.fib_multipath_hash_policy
286 ping_ipv6()
288 ping_test $h1 2001:db8:2::2
291 multipath_ipv6()
293 log_info "Running IPv6 over GRE over IPv6 multipath tests"
294 multipath6_test "ECMP" 1 1
295 multipath6_test "Weighted MP 2:1" 2 1
296 multipath6_test "Weighted MP 11:45" 11 45
299 trap cleanup EXIT
301 setup_prepare
302 setup_wait
303 tests_run
305 exit $EXIT_STATUS