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
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144 source lib.sh
0145
0146 h1_create()
0147 {
0148 simple_if_init $h1 192.0.2.1/28 2001:db8:1::1/64
0149 ip route add vrf v$h1 192.0.2.16/28 via 192.0.2.2
0150 }
0151
0152 h1_destroy()
0153 {
0154 ip route del vrf v$h1 192.0.2.16/28 via 192.0.2.2
0155 simple_if_fini $h1 192.0.2.1/28
0156 }
0157
0158 h2_create()
0159 {
0160 simple_if_init $h2 192.0.2.18/28
0161 ip route add vrf v$h2 192.0.2.0/28 via 192.0.2.17
0162 }
0163
0164 h2_destroy()
0165 {
0166 ip route del vrf v$h2 192.0.2.0/28 via 192.0.2.17
0167 simple_if_fini $h2 192.0.2.18/28
0168 }
0169
0170 sw1_flat_create()
0171 {
0172 local type=$1; shift
0173 local ol1=$1; shift
0174 local ul1=$1; shift
0175
0176 ip link set dev $ol1 up
0177 __addr_add_del $ol1 add "192.0.2.2/28"
0178
0179 ip link set dev $ul1 up
0180 vlan_create $ul1 111 "" 192.0.2.129/28
0181
0182 tunnel_create g1a $type 192.0.2.65 192.0.2.66 tos inherit "$@"
0183 ip link set dev g1a up
0184 __addr_add_del g1a add "192.0.2.65/32"
0185
0186 ip route add 192.0.2.66/32 via 192.0.2.130
0187
0188 ip route add 192.0.2.16/28 nexthop dev g1a
0189 }
0190
0191 sw1_flat_destroy()
0192 {
0193 local ol1=$1; shift
0194 local ul1=$1; shift
0195
0196 ip route del 192.0.2.16/28
0197
0198 ip route del 192.0.2.66/32 via 192.0.2.130
0199 __simple_if_fini g1a 192.0.2.65/32
0200 tunnel_destroy g1a
0201
0202 vlan_destroy $ul1 111
0203 __simple_if_fini $ul1
0204 __simple_if_fini $ol1 192.0.2.2/28
0205 }
0206
0207 sw2_flat_create()
0208 {
0209 local type=$1; shift
0210 local ol2=$1; shift
0211 local ul2=$1; shift
0212
0213 simple_if_init $ol2 192.0.2.17/28
0214 __simple_if_init $ul2 v$ol2
0215 vlan_create $ul2 111 v$ol2 192.0.2.130/28
0216
0217 tunnel_create g2a $type 192.0.2.66 192.0.2.65 tos inherit dev v$ol2 \
0218 "$@"
0219 __simple_if_init g2a v$ol2 192.0.2.66/32
0220
0221 ip route add vrf v$ol2 192.0.2.65/32 via 192.0.2.129
0222 ip route add vrf v$ol2 192.0.2.0/28 nexthop dev g2a
0223 }
0224
0225 sw2_flat_destroy()
0226 {
0227 local ol2=$1; shift
0228 local ul2=$1; shift
0229
0230 ip route del vrf v$ol2 192.0.2.0/28
0231
0232 ip route del vrf v$ol2 192.0.2.65/32 via 192.0.2.129
0233 __simple_if_fini g2a 192.0.2.66/32
0234 tunnel_destroy g2a
0235
0236 vlan_destroy $ul2 111
0237 __simple_if_fini $ul2
0238 simple_if_fini $ol2 192.0.2.17/28
0239 }
0240
0241 sw1_hierarchical_create()
0242 {
0243 local type=$1; shift
0244 local ol1=$1; shift
0245 local ul1=$1; shift
0246
0247 simple_if_init $ol1 192.0.2.2/28
0248 simple_if_init $ul1
0249 ip link add name dummy1 type dummy
0250 __simple_if_init dummy1 v$ul1 192.0.2.65/32
0251
0252 vlan_create $ul1 111 v$ul1 192.0.2.129/28
0253 tunnel_create g1a $type 192.0.2.65 192.0.2.66 tos inherit dev dummy1 \
0254 "$@"
0255 ip link set dev g1a master v$ol1
0256
0257 ip route add vrf v$ul1 192.0.2.66/32 via 192.0.2.130
0258 ip route add vrf v$ol1 192.0.2.16/28 nexthop dev g1a
0259 }
0260
0261 sw1_hierarchical_destroy()
0262 {
0263 local ol1=$1; shift
0264 local ul1=$1; shift
0265
0266 ip route del vrf v$ol1 192.0.2.16/28
0267 ip route del vrf v$ul1 192.0.2.66/32
0268
0269 tunnel_destroy g1a
0270 vlan_destroy $ul1 111
0271
0272 __simple_if_fini dummy1 192.0.2.65/32
0273 ip link del dev dummy1
0274
0275 simple_if_fini $ul1
0276 simple_if_fini $ol1 192.0.2.2/28
0277 }
0278
0279 sw2_hierarchical_create()
0280 {
0281 local type=$1; shift
0282 local ol2=$1; shift
0283 local ul2=$1; shift
0284
0285 simple_if_init $ol2 192.0.2.17/28
0286 simple_if_init $ul2
0287
0288 ip link add name dummy2 type dummy
0289 __simple_if_init dummy2 v$ul2 192.0.2.66/32
0290
0291 vlan_create $ul2 111 v$ul2 192.0.2.130/28
0292 tunnel_create g2a $type 192.0.2.66 192.0.2.65 tos inherit dev dummy2 \
0293 "$@"
0294 ip link set dev g2a master v$ol2
0295
0296 ip route add vrf v$ul2 192.0.2.65/32 via 192.0.2.129
0297 ip route add vrf v$ol2 192.0.2.0/28 nexthop dev g2a
0298 }
0299
0300 sw2_hierarchical_destroy()
0301 {
0302 local ol2=$1; shift
0303 local ul2=$1; shift
0304
0305 ip route del vrf v$ol2 192.0.2.0/28
0306 ip route del vrf v$ul2 192.0.2.65/32
0307
0308 tunnel_destroy g2a
0309 vlan_destroy $ul2 111
0310
0311 __simple_if_fini dummy2 192.0.2.66/32
0312 ip link del dev dummy2
0313
0314 simple_if_fini $ul2
0315 simple_if_fini $ol2 192.0.2.17/28
0316 }
0317
0318 topo_mtu_change()
0319 {
0320 local mtu=$1
0321
0322 ip link set mtu $mtu dev $h1
0323 ip link set mtu $mtu dev $ol1
0324 ip link set mtu $mtu dev g1a
0325 ip link set mtu $mtu dev $ul1
0326 ip link set mtu $mtu dev $ul1.111
0327 ip link set mtu $mtu dev $h2
0328 ip link set mtu $mtu dev $ol2
0329 ip link set mtu $mtu dev g2a
0330 ip link set mtu $mtu dev $ul2
0331 ip link set mtu $mtu dev $ul2.111
0332 }
0333
0334 test_mtu_change()
0335 {
0336 local encap=$1; shift
0337
0338 RET=0
0339
0340 ping_do $h1 192.0.2.18 "-s 1800 -w 3"
0341 check_fail $? "ping $encap should not pass with size 1800"
0342
0343 RET=0
0344
0345 topo_mtu_change 2000
0346 ping_do $h1 192.0.2.18 "-s 1800 -w 3"
0347 check_err $?
0348 log_test "ping $encap packet size 1800 after MTU change"
0349 }