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
10 # +-------------------------+
13 # | 2001:db8:1::2/64 | |
14 # +-------------------|-----+
16 # +-------------------|-------------------------+
19 # | 2001:db8:1::1/64 |
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 # | 2001:db8:2::1/64 | SW4 |
65 # +--------------------|------------------------+
67 # +--------------------|---------+
70 # | 2001:db8:2::2/64 H2 |
71 # +------------------------------+
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
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
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
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
113 __simple_if_fini
$ul1 2001:db8
:80::1/64
114 simple_if_fini
$ol1 2001:db8
:1::1/64
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 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
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
193 __simple_if_fini
$ul4 2001:db8
:83::1/64
194 simple_if_fini
$ol4 2001:db8
:2::1/64
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
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
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 -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"
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
288 ping_test
$h1 2001:db8
:2::2
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