0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 ALL_TESTS="
0075 ping_ipv6
0076 multipath_ipv6
0077 "
0078
0079 NUM_NETIFS=10
0080 source lib.sh
0081
0082 h1_create()
0083 {
0084 simple_if_init $h1 2001:db8:1::2/64
0085 ip -6 route add vrf v$h1 2001:db8:2::/64 via 2001:db8:1::1
0086 }
0087
0088 h1_destroy()
0089 {
0090 ip -6 route del vrf v$h1 2001:db8:2::/64 via 2001:db8:1::1
0091 simple_if_fini $h1 2001:db8:1::2/64
0092 }
0093
0094 sw1_create()
0095 {
0096 simple_if_init $ol1 2001:db8:1::1/64
0097 __simple_if_init $ul1 v$ol1 192.0.2.129/28
0098
0099 tunnel_create g1 gre 192.0.2.65 192.0.2.66 tos inherit dev v$ol1
0100 __simple_if_init g1 v$ol1 192.0.2.65/32
0101 ip route add vrf v$ol1 192.0.2.66/32 via 192.0.2.130
0102
0103 ip -6 route add vrf v$ol1 2001:db8:2::/64 dev g1
0104 }
0105
0106 sw1_destroy()
0107 {
0108 ip -6 route del vrf v$ol1 2001:db8:2::/64
0109
0110 ip route del vrf v$ol1 192.0.2.66/32
0111 __simple_if_fini g1 192.0.2.65/32
0112 tunnel_destroy g1
0113
0114 __simple_if_fini $ul1 192.0.2.129/28
0115 simple_if_fini $ol1 2001:db8:1::1/64
0116 }
0117
0118 sw2_create()
0119 {
0120 simple_if_init $ul21 192.0.2.130/28
0121 __simple_if_init $ul22 v$ul21
0122 vlan_create $ul22 111 v$ul21 192.0.2.145/28
0123 vlan_create $ul22 222 v$ul21 192.0.2.161/28
0124
0125 ip route add vrf v$ul21 192.0.2.65/32 via 192.0.2.129
0126 ip route add vrf v$ul21 192.0.2.66/32 \
0127 nexthop via 192.0.2.146 \
0128 nexthop via 192.0.2.162
0129 }
0130
0131 sw2_destroy()
0132 {
0133 ip route del vrf v$ul21 192.0.2.66/32
0134 ip route del vrf v$ul21 192.0.2.65/32
0135
0136 vlan_destroy $ul22 222
0137 vlan_destroy $ul22 111
0138 __simple_if_fini $ul22
0139 simple_if_fini $ul21 192.0.2.130/28
0140 }
0141
0142 sw3_create()
0143 {
0144 simple_if_init $ul31 192.0.2.177/28
0145 __simple_if_init $ul32 v$ul31
0146 vlan_create $ul32 111 v$ul31 192.0.2.146/28
0147 vlan_create $ul32 222 v$ul31 192.0.2.162/28
0148
0149 ip route add vrf v$ul31 192.0.2.66/32 via 192.0.2.178
0150 ip route add vrf v$ul31 192.0.2.65/32 \
0151 nexthop via 192.0.2.145 \
0152 nexthop via 192.0.2.161
0153
0154 tc qdisc add dev $ul32 clsact
0155 tc filter add dev $ul32 ingress pref 111 prot 802.1Q \
0156 flower vlan_id 111 action pass
0157 tc filter add dev $ul32 ingress pref 222 prot 802.1Q \
0158 flower vlan_id 222 action pass
0159 }
0160
0161 sw3_destroy()
0162 {
0163 tc qdisc del dev $ul32 clsact
0164
0165 ip route del vrf v$ul31 192.0.2.65/32
0166 ip route del vrf v$ul31 192.0.2.66/32
0167
0168 vlan_destroy $ul32 222
0169 vlan_destroy $ul32 111
0170 __simple_if_fini $ul32
0171 simple_if_fini $ul31 192.0.2.177/28
0172 }
0173
0174 sw4_create()
0175 {
0176 simple_if_init $ol4 2001:db8:2::1/64
0177 __simple_if_init $ul4 v$ol4 192.0.2.178/28
0178
0179 tunnel_create g2 gre 192.0.2.66 192.0.2.65 tos inherit dev v$ol4
0180 __simple_if_init g2 v$ol4 192.0.2.66/32
0181 ip route add vrf v$ol4 192.0.2.65/32 via 192.0.2.177
0182
0183 ip -6 route add vrf v$ol4 2001:db8:1::/64 dev g2
0184 }
0185
0186 sw4_destroy()
0187 {
0188 ip -6 route del vrf v$ol4 2001:db8:1::/64
0189
0190 ip route del vrf v$ol4 192.0.2.65/32
0191 __simple_if_fini g2 192.0.2.66/32
0192 tunnel_destroy g2
0193
0194 __simple_if_fini $ul4 192.0.2.178/28
0195 simple_if_fini $ol4 2001:db8:2::1/64
0196 }
0197
0198 h2_create()
0199 {
0200 simple_if_init $h2 2001:db8:2::2/64
0201 ip -6 route add vrf v$h2 2001:db8:1::/64 via 2001:db8:2::1
0202 }
0203
0204 h2_destroy()
0205 {
0206 ip -6 route del vrf v$h2 2001:db8:1::/64 via 2001:db8:2::1
0207 simple_if_fini $h2 2001:db8:2::2/64
0208 }
0209
0210 setup_prepare()
0211 {
0212 h1=${NETIFS[p1]}
0213
0214 ol1=${NETIFS[p2]}
0215 ul1=${NETIFS[p3]}
0216
0217 ul21=${NETIFS[p4]}
0218 ul22=${NETIFS[p5]}
0219
0220 ul32=${NETIFS[p6]}
0221 ul31=${NETIFS[p7]}
0222
0223 ul4=${NETIFS[p8]}
0224 ol4=${NETIFS[p9]}
0225
0226 h2=${NETIFS[p10]}
0227
0228 vrf_prepare
0229 h1_create
0230 sw1_create
0231 sw2_create
0232 sw3_create
0233 sw4_create
0234 h2_create
0235
0236 forwarding_enable
0237 }
0238
0239 cleanup()
0240 {
0241 pre_cleanup
0242
0243 forwarding_restore
0244
0245 h2_destroy
0246 sw4_destroy
0247 sw3_destroy
0248 sw2_destroy
0249 sw1_destroy
0250 h1_destroy
0251 vrf_cleanup
0252 }
0253
0254 multipath6_test()
0255 {
0256 local what=$1; shift
0257 local weight1=$1; shift
0258 local weight2=$1; shift
0259
0260 sysctl_set net.ipv4.fib_multipath_hash_policy 2
0261 ip route replace vrf v$ul21 192.0.2.66/32 \
0262 nexthop via 192.0.2.146 weight $weight1 \
0263 nexthop via 192.0.2.162 weight $weight2
0264
0265 local t0_111=$(tc_rule_stats_get $ul32 111 ingress)
0266 local t0_222=$(tc_rule_stats_get $ul32 222 ingress)
0267
0268 ip vrf exec v$h1 \
0269 $MZ $h1 -6 -q -p 64 -A "2001:db8:1::2-2001:db8:1::1e" \
0270 -B "2001:db8:2::2-2001:db8:2::1e" \
0271 -d 1msec -c 50 -t udp "sp=1024,dp=1024"
0272 sleep 1
0273
0274 local t1_111=$(tc_rule_stats_get $ul32 111 ingress)
0275 local t1_222=$(tc_rule_stats_get $ul32 222 ingress)
0276
0277 local d111=$((t1_111 - t0_111))
0278 local d222=$((t1_222 - t0_222))
0279 multipath_eval "$what" $weight1 $weight2 $d111 $d222
0280
0281 ip route replace vrf v$ul21 192.0.2.66/32 \
0282 nexthop via 192.0.2.146 \
0283 nexthop via 192.0.2.162
0284 sysctl_restore net.ipv4.fib_multipath_hash_policy
0285 }
0286
0287 ping_ipv6()
0288 {
0289 ping_test $h1 2001:db8:2::2
0290 }
0291
0292 multipath_ipv6()
0293 {
0294 log_info "Running IPv6 over GRE over IPv4 multipath tests"
0295 multipath6_test "ECMP" 1 1
0296 multipath6_test "Weighted MP 2:1" 2 1
0297 multipath6_test "Weighted MP 11:45" 11 45
0298 }
0299
0300 trap cleanup EXIT
0301
0302 setup_prepare
0303 setup_wait
0304 tests_run
0305
0306 exit $EXIT_STATUS