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 IPv4 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
10 # +-------------------------+
13 # | 192.0.3.{2-62}/24 | |
14 # +-------------------|-----+
16 # +-------------------|-------------------------+
22 # | loc=2001:db8:40::1 |
23 # | rem=2001:db8:40::2 --. |
27 # | | 2001:db8:80::1/64 |
28 # +-------------------------|-------------------+
30 # +-------------------------|-------------------+
33 # | 2001:db8:80::2/64 |
35 # ! ________________|_____ |
38 # | + $ul22.111 (vlan) + $ul22.222 (vlan) |
39 # | | 2001:db8:81::1/64 | 2001:db8:82::1/64 |
41 # +--|----------------------|-------------------+
43 # +--|----------------------|-------------------+
45 # | + $ul32.111 (vlan) + $ul32.222 (vlan) |
46 # | | 2001:db8:81::2/64 | 2001:db8:82::2/64 |
48 # | \______________________/ |
52 # | 2001:db8:83::2/64 | SW3 |
53 # +-------------------------|-------------------+
55 # +-------------------------|-------------------+
57 # | ^ 2001:db8:83::1/64 |
59 # | loc=2001:db8:40::2 | |
60 # | rem=2001:db8:40::1 --' |
64 # | 192.0.4.1/24 | SW4 |
65 # +--------------------|------------------------+
67 # +--------------------|---------+
70 # | 192.0.4.{2-62}/24 H2 |
71 # +------------------------------+
83 simple_if_init
$h1 192.0.3.2/24
84 ip route add vrf v
$h1 192.0.4.0/24 via
192.0.3.1
89 ip route del vrf v
$h1 192.0.4.0/24 via
192.0.3.1
90 simple_if_fini
$h1 192.0.3.2/24
95 simple_if_init
$ol1 192.0.3.1/24
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 route add vrf v
$ol1 192.0.4.0/24 nexthop dev g1
107 ip route del vrf v
$ol1 192.0.4.0/24
109 ip
-6 route del vrf v
$ol1 2001:db8
:40::2/128
110 __simple_if_fini g1
2001:db8
:40::1/128
113 __simple_if_fini
$ul1 2001:db8
:80::1/64
114 simple_if_fini
$ol1 192.0.3.1/24
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
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
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
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
175 simple_if_init
$ol4 192.0.4.1/24
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 route add vrf v
$ol4 192.0.3.0/24 nexthop dev g2
187 ip route del vrf v
$ol4 192.0.3.0/24
189 ip
-6 route del vrf v
$ol4 2001:db8
:40::1/128
190 __simple_if_fini g2
2001:db8
:40::2/128
193 __simple_if_fini
$ul4 2001:db8
:83::1/64
194 simple_if_fini
$ol4 192.0.4.1/24
199 simple_if_init
$h2 192.0.4.2/24
200 ip route add vrf v
$h2 192.0.3.0/24 via
192.0.4.1
205 ip route del vrf v
$h2 192.0.3.0/24 via
192.0.4.1
206 simple_if_fini
$h2 192.0.4.2/24
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
)
268 $MZ $h1 -q -p 64 -A "192.0.3.2-192.0.3.62" -B "192.0.4.2-192.0.4.62" \
269 -d 1msec
-c 50 -t udp
"sp=1024,dp=1024"
272 local t1_111
=$
(tc_rule_stats_get
$ul32 111 ingress
)
273 local t1_222
=$
(tc_rule_stats_get
$ul32 222 ingress
)
275 local d111
=$
((t1_111
- t0_111
))
276 local d222
=$
((t1_222
- t0_222
))
277 multipath_eval
"$what" $weight1 $weight2 $d111 $d222
279 ip route replace vrf v
$ul21 2001:db8
:40::2/128 \
280 nexthop via
2001:db8
:81::2 \
281 nexthop via
2001:db8
:82::2
282 sysctl_restore net.ipv6.fib_multipath_hash_policy
287 ping_test
$h1 192.0.4.2
292 log_info
"Running IPv4 over GRE over IPv6 multipath tests"
293 multipath4_test
"ECMP" 1 1
294 multipath4_test
"Weighted MP 2:1" 2 1
295 multipath4_test
"Weighted MP 11:45" 11 45