2 # SPDX-License-Identifier: GPL-2.0
4 # Test traffic distribution when a wECMP route forwards traffic to two GRE
7 # +-------------------------+
11 # +-------------------|-----+
13 # +-------------------|------------------------+
18 # | + g1a (gre) + g1b (gre) |
19 # | loc=192.0.2.65 loc=192.0.2.81 |
20 # | rem=192.0.2.66 --. rem=192.0.2.82 --. |
21 # | tos=inherit | tos=inherit | |
22 # | .------------------' | |
23 # | | .------------------' |
25 # | + $ul1.111 (vlan) + $ul1.222 (vlan) |
26 # | | 192.0.2.129/28 | 192.0.2.145/28 |
28 # | \________________/ |
31 # +------------|-------------------------------+
33 # +------------|-------------------------------+
35 # | _______|________ |
38 # | + $ul2.111 (vlan) + $ul2.222 (vlan) |
39 # | ^ 192.0.2.130/28 ^ 192.0.2.146/28 |
41 # | | '------------------. |
42 # | '------------------. | |
43 # | + g2a (gre) | + g2b (gre) | |
44 # | loc=192.0.2.66 | loc=192.0.2.82 | |
45 # | rem=192.0.2.65 --' rem=192.0.2.81 --' |
46 # | tos=inherit tos=inherit |
50 # +-------------------|------------------------+
52 # +-------------------|-----+
56 # +-------------------------+
68 simple_if_init
$h1 192.0.2.1/28 2001:db8
:1::1/64
69 ip route add vrf v
$h1 192.0.2.16/28 via
192.0.2.2
74 ip route del vrf v
$h1 192.0.2.16/28 via
192.0.2.2
75 simple_if_fini
$h1 192.0.2.1/28
80 simple_if_init
$ol1 192.0.2.2/28
81 __simple_if_init
$ul1 v
$ol1
82 vlan_create
$ul1 111 v
$ol1 192.0.2.129/28
83 vlan_create
$ul1 222 v
$ol1 192.0.2.145/28
85 tunnel_create g1a gre
192.0.2.65 192.0.2.66 tos inherit dev v
$ol1
86 __simple_if_init g1a v
$ol1 192.0.2.65/32
87 ip route add vrf v
$ol1 192.0.2.66/32 via
192.0.2.130
89 tunnel_create g1b gre
192.0.2.81 192.0.2.82 tos inherit dev v
$ol1
90 __simple_if_init g1b v
$ol1 192.0.2.81/32
91 ip route add vrf v
$ol1 192.0.2.82/32 via
192.0.2.146
93 ip route add vrf v
$ol1 192.0.2.16/28 \
100 ip route del vrf v
$ol1 192.0.2.16/28
102 ip route del vrf v
$ol1 192.0.2.82/32 via
192.0.2.146
103 __simple_if_fini g1b
192.0.2.81/32
106 ip route del vrf v
$ol1 192.0.2.66/32 via
192.0.2.130
107 __simple_if_fini g1a
192.0.2.65/32
110 vlan_destroy
$ul1 222
111 vlan_destroy
$ul1 111
112 __simple_if_fini
$ul1
113 simple_if_fini
$ol1 192.0.2.2/28
118 simple_if_init
$ol2 192.0.2.17/28
119 __simple_if_init
$ul2 v
$ol2
120 vlan_create
$ul2 111 v
$ol2 192.0.2.130/28
121 vlan_create
$ul2 222 v
$ol2 192.0.2.146/28
123 tunnel_create g2a gre
192.0.2.66 192.0.2.65 tos inherit dev v
$ol2
124 __simple_if_init g2a v
$ol2 192.0.2.66/32
125 ip route add vrf v
$ol2 192.0.2.65/32 via
192.0.2.129
127 tunnel_create g2b gre
192.0.2.82 192.0.2.81 tos inherit dev v
$ol2
128 __simple_if_init g2b v
$ol2 192.0.2.82/32
129 ip route add vrf v
$ol2 192.0.2.81/32 via
192.0.2.145
131 ip route add vrf v
$ol2 192.0.2.0/28 \
135 tc qdisc add dev
$ul2 clsact
136 tc filter add dev
$ul2 ingress pref
111 prot
802.1Q \
137 flower vlan_id
111 action pass
138 tc filter add dev
$ul2 ingress pref
222 prot
802.1Q \
139 flower vlan_id
222 action pass
144 tc qdisc del dev
$ul2 clsact
146 ip route del vrf v
$ol2 192.0.2.0/28
148 ip route del vrf v
$ol2 192.0.2.81/32 via
192.0.2.145
149 __simple_if_fini g2b
192.0.2.82/32
152 ip route del vrf v
$ol2 192.0.2.65/32 via
192.0.2.129
153 __simple_if_fini g2a
192.0.2.66/32
156 vlan_destroy
$ul2 222
157 vlan_destroy
$ul2 111
158 __simple_if_fini
$ul2
159 simple_if_fini
$ol2 192.0.2.17/28
164 simple_if_init
$h2 192.0.2.18/28
165 ip route add vrf v
$h2 192.0.2.0/28 via
192.0.2.17
170 ip route del vrf v
$h2 192.0.2.0/28 via
192.0.2.17
171 simple_if_fini
$h2 192.0.2.18/28
210 local weight1
=$1; shift
211 local weight2
=$1; shift
213 sysctl_set net.ipv4.fib_multipath_hash_policy
1
214 ip route replace vrf v
$ol1 192.0.2.16/28 \
215 nexthop dev g1a weight
$weight1 \
216 nexthop dev g1b weight
$weight2
218 local t0_111
=$
(tc_rule_stats_get
$ul2 111 ingress
)
219 local t0_222
=$
(tc_rule_stats_get
$ul2 222 ingress
)
222 $MZ $h1 -q -p 64 -A 192.0.2.1 -B 192.0.2.18 \
223 -d 1msec
-t udp
"sp=1024,dp=0-32768"
225 local t1_111
=$
(tc_rule_stats_get
$ul2 111 ingress
)
226 local t1_222
=$
(tc_rule_stats_get
$ul2 222 ingress
)
228 local d111
=$
((t1_111
- t0_111
))
229 local d222
=$
((t1_222
- t0_222
))
230 multipath_eval
"$what" $weight1 $weight2 $d111 $d222
232 ip route replace vrf v
$ol1 192.0.2.16/28 \
235 sysctl_restore net.ipv4.fib_multipath_hash_policy
240 ping_test
$h1 192.0.2.18
245 log_info
"Running IPv4 multipath tests"
246 multipath4_test
"ECMP" 1 1
247 multipath4_test
"Weighted MP 2:1" 2 1
248 multipath4_test
"Weighted MP 11:45" 11 45