2 # SPDX-License-Identifier: GPL-2.0
4 # Test traffic distribution when a wECMP route forwards traffic to two GRE
7 # +-------------------------+
11 # | 2001:db8:1::1/64 | |
12 # +-------------------|-----+
14 # +-------------------|------------------------+
18 # | 2001:db8:1::2/64 |
20 # | + g1a (gre) + g1b (gre) |
21 # | loc=192.0.2.65 loc=192.0.2.81 |
22 # | rem=192.0.2.66 --. rem=192.0.2.82 --. |
23 # | tos=inherit | tos=inherit | |
24 # | .------------------' | |
25 # | | .------------------' |
27 # | + $ul1.111 (vlan) + $ul1.222 (vlan) |
28 # | | 192.0.2.129/28 | 192.0.2.145/28 |
30 # | \________________/ |
33 # +------------|-------------------------------+
35 # +------------|-------------------------------+
37 # | _______|________ |
40 # | + $ul2.111 (vlan) + $ul2.222 (vlan) |
41 # | ^ 192.0.2.130/28 ^ 192.0.2.146/28 |
43 # | | '------------------. |
44 # | '------------------. | |
45 # | + g2a (gre) | + g2b (gre) | |
46 # | loc=192.0.2.66 | loc=192.0.2.82 | |
47 # | rem=192.0.2.65 --' rem=192.0.2.81 --' |
48 # | tos=inherit tos=inherit |
52 # | 2001:db8:2::1/64 | |
53 # +-------------------|------------------------+
55 # +-------------------|-----+
59 # | 2001:db8:2::2/64 |
60 # +-------------------------+
74 simple_if_init
$h1 192.0.2.1/28 2001:db8
:1::1/64
75 ip route add vrf v
$h1 192.0.2.16/28 via
192.0.2.2
76 ip route add vrf v
$h1 2001:db8
:2::/64 via
2001:db8
:1::2
81 ip route del vrf v
$h1 2001:db8
:2::/64 via
2001:db8
:1::2
82 ip route del vrf v
$h1 192.0.2.16/28 via
192.0.2.2
83 simple_if_fini
$h1 192.0.2.1/28
88 simple_if_init
$ol1 192.0.2.2/28 2001:db8
:1::2/64
89 __simple_if_init
$ul1 v
$ol1
90 vlan_create
$ul1 111 v
$ol1 192.0.2.129/28
91 vlan_create
$ul1 222 v
$ol1 192.0.2.145/28
93 tunnel_create g1a gre
192.0.2.65 192.0.2.66 tos inherit dev v
$ol1
94 __simple_if_init g1a v
$ol1 192.0.2.65/32
95 ip route add vrf v
$ol1 192.0.2.66/32 via
192.0.2.130
97 tunnel_create g1b gre
192.0.2.81 192.0.2.82 tos inherit dev v
$ol1
98 __simple_if_init g1b v
$ol1 192.0.2.81/32
99 ip route add vrf v
$ol1 192.0.2.82/32 via
192.0.2.146
101 ip
-6 nexthop add id
101 dev g1a
102 ip
-6 nexthop add id
102 dev g1b
103 ip nexthop add id
103 group
101/102 type resilient buckets
512 \
106 ip route add vrf v
$ol1 192.0.2.16/28 nhid
103
107 ip route add vrf v
$ol1 2001:db8
:2::/64 nhid
103
112 ip route del vrf v
$ol1 2001:db8
:2::/64
113 ip route del vrf v
$ol1 192.0.2.16/28
115 ip nexthop del id
103
116 ip
-6 nexthop del id
102
117 ip
-6 nexthop del id
101
119 ip route del vrf v
$ol1 192.0.2.82/32 via
192.0.2.146
120 __simple_if_fini g1b
192.0.2.81/32
123 ip route del vrf v
$ol1 192.0.2.66/32 via
192.0.2.130
124 __simple_if_fini g1a
192.0.2.65/32
127 vlan_destroy
$ul1 222
128 vlan_destroy
$ul1 111
129 __simple_if_fini
$ul1
130 simple_if_fini
$ol1 192.0.2.2/28 2001:db8
:1::2/64
135 simple_if_init
$ol2 192.0.2.17/28 2001:db8
:2::1/64
136 __simple_if_init
$ul2 v
$ol2
137 vlan_create
$ul2 111 v
$ol2 192.0.2.130/28
138 vlan_create
$ul2 222 v
$ol2 192.0.2.146/28
140 tunnel_create g2a gre
192.0.2.66 192.0.2.65 tos inherit dev v
$ol2
141 __simple_if_init g2a v
$ol2 192.0.2.66/32
142 ip route add vrf v
$ol2 192.0.2.65/32 via
192.0.2.129
144 tunnel_create g2b gre
192.0.2.82 192.0.2.81 tos inherit dev v
$ol2
145 __simple_if_init g2b v
$ol2 192.0.2.82/32
146 ip route add vrf v
$ol2 192.0.2.81/32 via
192.0.2.145
148 ip
-6 nexthop add id
201 dev g2a
149 ip
-6 nexthop add id
202 dev g2b
150 ip nexthop add id
203 group
201/202 type resilient buckets
512 \
153 ip route add vrf v
$ol2 192.0.2.0/28 nhid
203
154 ip route add vrf v
$ol2 2001:db8
:1::/64 nhid
203
156 tc qdisc add dev
$ul2 clsact
157 tc filter add dev
$ul2 ingress pref
111 prot
802.1Q \
158 flower vlan_id
111 action pass
159 tc filter add dev
$ul2 ingress pref
222 prot
802.1Q \
160 flower vlan_id
222 action pass
165 tc qdisc del dev
$ul2 clsact
167 ip route del vrf v
$ol2 2001:db8
:1::/64
168 ip route del vrf v
$ol2 192.0.2.0/28
170 ip nexthop del id
203
171 ip
-6 nexthop del id
202
172 ip
-6 nexthop del id
201
174 ip route del vrf v
$ol2 192.0.2.81/32 via
192.0.2.145
175 __simple_if_fini g2b
192.0.2.82/32
178 ip route del vrf v
$ol2 192.0.2.65/32 via
192.0.2.129
179 __simple_if_fini g2a
192.0.2.66/32
182 vlan_destroy
$ul2 222
183 vlan_destroy
$ul2 111
184 __simple_if_fini
$ul2
185 simple_if_fini
$ol2 192.0.2.17/28 2001:db8
:2::1/64
190 simple_if_init
$h2 192.0.2.18/28 2001:db8
:2::2/64
191 ip route add vrf v
$h2 192.0.2.0/28 via
192.0.2.17
192 ip route add vrf v
$h2 2001:db8
:1::/64 via
2001:db8
:2::1
197 ip route del vrf v
$h2 2001:db8
:1::/64 via
2001:db8
:2::1
198 ip route del vrf v
$h2 192.0.2.0/28 via
192.0.2.17
199 simple_if_fini
$h2 192.0.2.18/28 2001:db8
:2::2/64
238 local weight1
=$1; shift
239 local weight2
=$1; shift
241 sysctl_set net.ipv4.fib_multipath_hash_policy
1
242 ip nexthop replace id
103 group
101,$weight1/102,$weight2 \
245 local t0_111
=$
(tc_rule_stats_get
$ul2 111 ingress
)
246 local t0_222
=$
(tc_rule_stats_get
$ul2 222 ingress
)
249 $MZ $h1 -q -p 64 -A 192.0.2.1 -B 192.0.2.18 \
250 -d $MZ_DELAY -t udp
"sp=1024,dp=0-32768"
252 local t1_111
=$
(tc_rule_stats_get
$ul2 111 ingress
)
253 local t1_222
=$
(tc_rule_stats_get
$ul2 222 ingress
)
255 local d111
=$
((t1_111
- t0_111
))
256 local d222
=$
((t1_222
- t0_222
))
257 multipath_eval
"$what" $weight1 $weight2 $d111 $d222
259 ip nexthop replace id
103 group
101/102 type resilient
260 sysctl_restore net.ipv4.fib_multipath_hash_policy
266 local weight1
=$1; shift
267 local weight2
=$1; shift
269 sysctl_set net.ipv6.fib_multipath_hash_policy
1
270 ip nexthop replace id
103 group
101,$weight1/102,$weight2 \
273 local t0_111
=$
(tc_rule_stats_get
$ul2 111 ingress
)
274 local t0_222
=$
(tc_rule_stats_get
$ul2 222 ingress
)
277 $MZ $h1 -6 -q -p 64 -A 2001:db8
:1::1 -B 2001:db8
:2::2 \
278 -d $MZ_DELAY -t udp
"sp=1024,dp=0-32768"
280 local t1_111
=$
(tc_rule_stats_get
$ul2 111 ingress
)
281 local t1_222
=$
(tc_rule_stats_get
$ul2 222 ingress
)
283 local d111
=$
((t1_111
- t0_111
))
284 local d222
=$
((t1_222
- t0_222
))
285 multipath_eval
"$what" $weight1 $weight2 $d111 $d222
287 ip nexthop replace id
103 group
101/102 type resilient
288 sysctl_restore net.ipv6.fib_multipath_hash_policy
293 ping_test
$h1 192.0.2.18
298 ping6_test
$h1 2001:db8
:2::2
303 log_info
"Running IPv4 multipath tests"
304 multipath4_test
"ECMP" 1 1
305 multipath4_test
"Weighted MP 2:1" 2 1
306 multipath4_test
"Weighted MP 11:45" 11 45
311 log_info
"Running IPv6 multipath tests"
312 multipath6_test
"ECMP" 1 1
313 multipath6_test
"Weighted MP 2:1" 2 1
314 multipath6_test
"Weighted MP 11:45" 11 45