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 ALL_TESTS="
0074 ping_ipv4
0075 multipath_ipv4
0076 "
0077
0078 NUM_NETIFS=10
0079 source lib.sh
0080
0081 h1_create()
0082 {
0083 simple_if_init $h1 192.0.3.2/24
0084 ip route add vrf v$h1 192.0.4.0/24 via 192.0.3.1
0085 }
0086
0087 h1_destroy()
0088 {
0089 ip route del vrf v$h1 192.0.4.0/24 via 192.0.3.1
0090 simple_if_fini $h1 192.0.3.2/24
0091 }
0092
0093 sw1_create()
0094 {
0095 simple_if_init $ol1 192.0.3.1/24
0096 __simple_if_init $ul1 v$ol1 2001:db8:80::1/64
0097
0098 tunnel_create g1 ip6gre 2001:db8:40::1 2001:db8:40::2 tos inherit dev v$ol1
0099 __simple_if_init g1 v$ol1 2001:db8:40::1/128
0100 ip -6 route add vrf v$ol1 2001:db8:40::2/128 via 2001:db8:80::2
0101
0102 ip route add vrf v$ol1 192.0.4.0/24 nexthop dev g1
0103 }
0104
0105 sw1_destroy()
0106 {
0107 ip route del vrf v$ol1 192.0.4.0/24
0108
0109 ip -6 route del vrf v$ol1 2001:db8:40::2/128
0110 __simple_if_fini g1 2001:db8:40::1/128
0111 tunnel_destroy g1
0112
0113 __simple_if_fini $ul1 2001:db8:80::1/64
0114 simple_if_fini $ol1 192.0.3.1/24
0115 }
0116
0117 sw2_create()
0118 {
0119 simple_if_init $ul21 2001:db8:80::2/64
0120 __simple_if_init $ul22 v$ul21
0121 vlan_create $ul22 111 v$ul21 2001:db8:81::1/64
0122 vlan_create $ul22 222 v$ul21 2001:db8:82::1/64
0123
0124 ip -6 route add vrf v$ul21 2001:db8:40::1/128 via 2001:db8:80::1
0125 ip -6 route add vrf v$ul21 2001:db8:40::2/128 \
0126 nexthop via 2001:db8:81::2 \
0127 nexthop via 2001:db8:82::2
0128 }
0129
0130 sw2_destroy()
0131 {
0132 ip -6 route del vrf v$ul21 2001:db8:40::2/128
0133 ip -6 route del vrf v$ul21 2001:db8:40::1/128
0134
0135 vlan_destroy $ul22 222
0136 vlan_destroy $ul22 111
0137 __simple_if_fini $ul22
0138 simple_if_fini $ul21 2001:db8:80::2/64
0139 }
0140
0141 sw3_create()
0142 {
0143 simple_if_init $ul31 2001:db8:83::2/64
0144 __simple_if_init $ul32 v$ul31
0145 vlan_create $ul32 111 v$ul31 2001:db8:81::2/64
0146 vlan_create $ul32 222 v$ul31 2001:db8:82::2/64
0147
0148 ip -6 route add vrf v$ul31 2001:db8:40::2/128 via 2001:db8:83::1
0149 ip -6 route add vrf v$ul31 2001:db8:40::1/128 \
0150 nexthop via 2001:db8:81::1 \
0151 nexthop via 2001:db8:82::1
0152
0153 tc qdisc add dev $ul32 clsact
0154 tc filter add dev $ul32 ingress pref 111 prot 802.1Q \
0155 flower vlan_id 111 action pass
0156 tc filter add dev $ul32 ingress pref 222 prot 802.1Q \
0157 flower vlan_id 222 action pass
0158 }
0159
0160 sw3_destroy()
0161 {
0162 tc qdisc del dev $ul32 clsact
0163
0164 ip -6 route del vrf v$ul31 2001:db8:40::1/128
0165 ip -6 route del vrf v$ul31 2001:db8:40::2/128
0166
0167 vlan_destroy $ul32 222
0168 vlan_destroy $ul32 111
0169 __simple_if_fini $ul32
0170 simple_if_fini $ul31 2001:Db8:83::2/64
0171 }
0172
0173 sw4_create()
0174 {
0175 simple_if_init $ol4 192.0.4.1/24
0176 __simple_if_init $ul4 v$ol4 2001:db8:83::1/64
0177
0178 tunnel_create g2 ip6gre 2001:db8:40::2 2001:db8:40::1 tos inherit dev v$ol4
0179 __simple_if_init g2 v$ol4 2001:db8:40::2/128
0180 ip -6 route add vrf v$ol4 2001:db8:40::1/128 via 2001:db8:83::2
0181
0182 ip route add vrf v$ol4 192.0.3.0/24 nexthop dev g2
0183 }
0184
0185 sw4_destroy()
0186 {
0187 ip route del vrf v$ol4 192.0.3.0/24
0188
0189 ip -6 route del vrf v$ol4 2001:db8:40::1/128
0190 __simple_if_fini g2 2001:db8:40::2/128
0191 tunnel_destroy g2
0192
0193 __simple_if_fini $ul4 2001:db8:83::1/64
0194 simple_if_fini $ol4 192.0.4.1/24
0195 }
0196
0197 h2_create()
0198 {
0199 simple_if_init $h2 192.0.4.2/24
0200 ip route add vrf v$h2 192.0.3.0/24 via 192.0.4.1
0201 }
0202
0203 h2_destroy()
0204 {
0205 ip route del vrf v$h2 192.0.3.0/24 via 192.0.4.1
0206 simple_if_fini $h2 192.0.4.2/24
0207 }
0208
0209 setup_prepare()
0210 {
0211 h1=${NETIFS[p1]}
0212
0213 ol1=${NETIFS[p2]}
0214 ul1=${NETIFS[p3]}
0215
0216 ul21=${NETIFS[p4]}
0217 ul22=${NETIFS[p5]}
0218
0219 ul32=${NETIFS[p6]}
0220 ul31=${NETIFS[p7]}
0221
0222 ul4=${NETIFS[p8]}
0223 ol4=${NETIFS[p9]}
0224
0225 h2=${NETIFS[p10]}
0226
0227 vrf_prepare
0228 h1_create
0229 sw1_create
0230 sw2_create
0231 sw3_create
0232 sw4_create
0233 h2_create
0234
0235 forwarding_enable
0236 }
0237
0238 cleanup()
0239 {
0240 pre_cleanup
0241
0242 forwarding_restore
0243
0244 h2_destroy
0245 sw4_destroy
0246 sw3_destroy
0247 sw2_destroy
0248 sw1_destroy
0249 h1_destroy
0250 vrf_cleanup
0251 }
0252
0253 multipath4_test()
0254 {
0255 local what=$1; shift
0256 local weight1=$1; shift
0257 local weight2=$1; shift
0258
0259 sysctl_set net.ipv6.fib_multipath_hash_policy 2
0260 ip route replace vrf v$ul21 2001:db8:40::2/128 \
0261 nexthop via 2001:db8:81::2 weight $weight1 \
0262 nexthop via 2001:db8:82::2 weight $weight2
0263
0264 local t0_111=$(tc_rule_stats_get $ul32 111 ingress)
0265 local t0_222=$(tc_rule_stats_get $ul32 222 ingress)
0266
0267 ip vrf exec v$h1 \
0268 $MZ $h1 -q -p 64 -A "192.0.3.2-192.0.3.62" -B "192.0.4.2-192.0.4.62" \
0269 -d 1msec -c 50 -t udp "sp=1024,dp=1024"
0270 sleep 1
0271
0272 local t1_111=$(tc_rule_stats_get $ul32 111 ingress)
0273 local t1_222=$(tc_rule_stats_get $ul32 222 ingress)
0274
0275 local d111=$((t1_111 - t0_111))
0276 local d222=$((t1_222 - t0_222))
0277 multipath_eval "$what" $weight1 $weight2 $d111 $d222
0278
0279 ip route replace vrf v$ul21 2001:db8:40::2/128 \
0280 nexthop via 2001:db8:81::2 \
0281 nexthop via 2001:db8:82::2
0282 sysctl_restore net.ipv6.fib_multipath_hash_policy
0283 }
0284
0285 ping_ipv4()
0286 {
0287 ping_test $h1 192.0.4.2
0288 }
0289
0290 multipath_ipv4()
0291 {
0292 log_info "Running IPv4 over GRE over IPv6 multipath tests"
0293 multipath4_test "ECMP" 1 1
0294 multipath4_test "Weighted MP 2:1" 2 1
0295 multipath4_test "Weighted MP 11:45" 11 45
0296 }
0297
0298 trap cleanup EXIT
0299
0300 setup_prepare
0301 setup_wait
0302 tests_run
0303
0304 exit $EXIT_STATUS