841 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# +-----------------------+ +------------------------+5# | H1 (vrf) | | H2 (vrf) |6# | + $h1.10 | | + $h2.10 |7# | | 192.0.2.1/28 | | | 192.0.2.2/28 |8# | | | | | |9# | | + $h1.20 | | | + $h2.20 |10# | \ | 198.51.100.1/24 | | \ | 198.51.100.2/24 |11# | \| | | \| |12# | + $h1 | | + $h2 |13# +----|------------------+ +----|-------------------+14# | |15# +----|--------------------------------------------------|-------------------+16# | SW | | |17# | +--|--------------------------------------------------|-----------------+ |18# | | + $swp1 BR1 (802.1q) + $swp2 | |19# | | vid 10 vid 10 | |20# | | vid 20 vid 20 | |21# | | | |22# | | + vx10 (vxlan) + vx20 (vxlan) | |23# | | local 192.0.2.17 local 192.0.2.17 | |24# | | remote 192.0.2.34 192.0.2.50 remote 192.0.2.34 192.0.2.50 | |25# | | id 1000 dstport $VXPORT id 2000 dstport $VXPORT | |26# | | vid 10 pvid untagged vid 20 pvid untagged | |27# | +-----------------------------------------------------------------------+ |28# | |29# | 192.0.2.32/28 via 192.0.2.18 |30# | 192.0.2.48/28 via 192.0.2.18 |31# | |32# | + $rp1 |33# | | 192.0.2.17/28 |34# +----|----------------------------------------------------------------------+35# |36# +----|--------------------------------------------------------+37# | | VRP2 (vrf) |38# | + $rp2 |39# | 192.0.2.18/28 |40# | | (maybe) HW41# =============================================================================42# | | (likely) SW43# | + v1 (veth) + v3 (veth) |44# | | 192.0.2.33/28 | 192.0.2.49/28 |45# +----|---------------------------------------|----------------+46# | |47# +----|------------------------------+ +----|------------------------------+48# | + v2 (veth) NS1 (netns) | | + v4 (veth) NS2 (netns) |49# | 192.0.2.34/28 | | 192.0.2.50/28 |50# | | | |51# | 192.0.2.16/28 via 192.0.2.33 | | 192.0.2.16/28 via 192.0.2.49 |52# | 192.0.2.50/32 via 192.0.2.33 | | 192.0.2.34/32 via 192.0.2.49 |53# | | | |54# | +-------------------------------+ | | +-------------------------------+ |55# | | BR2 (802.1q) | | | | BR2 (802.1q) | |56# | | + vx10 (vxlan) | | | | + vx10 (vxlan) | |57# | | local 192.0.2.34 | | | | local 192.0.2.50 | |58# | | remote 192.0.2.17 | | | | remote 192.0.2.17 | |59# | | remote 192.0.2.50 | | | | remote 192.0.2.34 | |60# | | id 1000 dstport $VXPORT | | | | id 1000 dstport $VXPORT | |61# | | vid 10 pvid untagged | | | | vid 10 pvid untagged | |62# | | | | | | | |63# | | + vx20 (vxlan) | | | | + vx20 (vxlan) | |64# | | local 192.0.2.34 | | | | local 192.0.2.50 | |65# | | remote 192.0.2.17 | | | | remote 192.0.2.17 | |66# | | remote 192.0.2.50 | | | | remote 192.0.2.34 | |67# | | id 2000 dstport $VXPORT | | | | id 2000 dstport $VXPORT | |68# | | vid 20 pvid untagged | | | | vid 20 pvid untagged | |69# | | | | | | | |70# | | + w1 (veth) | | | | + w1 (veth) | |71# | | | vid 10 | | | | | vid 10 | |72# | | | vid 20 | | | | | vid 20 | |73# | +--|----------------------------+ | | +--|----------------------------+ |74# | | | | | |75# | +--|----------------------------+ | | +--|----------------------------+ |76# | | + w2 (veth) VW2 (vrf) | | | | + w2 (veth) VW2 (vrf) | |77# | | |\ | | | | |\ | |78# | | | + w2.10 | | | | | + w2.10 | |79# | | | 192.0.2.3/28 | | | | | 192.0.2.4/28 | |80# | | | | | | | | | |81# | | + w2.20 | | | | + w2.20 | |82# | | 198.51.100.3/24 | | | | 198.51.100.4/24 | |83# | +-------------------------------+ | | +-------------------------------+ |84# +-----------------------------------+ +-----------------------------------+85 86: ${VXPORT:=4789}87export VXPORT88 89: ${ALL_TESTS:="90 ping_ipv491 test_flood92 test_unicast93 reapply_config94 ping_ipv495 test_flood96 test_unicast97 test_learning98 test_pvid99 "}100 101NUM_NETIFS=6102source lib.sh103 104h1_create()105{106 simple_if_init $h1107 tc qdisc add dev $h1 clsact108 vlan_create $h1 10 v$h1 192.0.2.1/28109 vlan_create $h1 20 v$h1 198.51.100.1/24110}111 112h1_destroy()113{114 vlan_destroy $h1 20115 vlan_destroy $h1 10116 tc qdisc del dev $h1 clsact117 simple_if_fini $h1118}119 120h2_create()121{122 simple_if_init $h2123 tc qdisc add dev $h2 clsact124 vlan_create $h2 10 v$h2 192.0.2.2/28125 vlan_create $h2 20 v$h2 198.51.100.2/24126}127 128h2_destroy()129{130 vlan_destroy $h2 20131 vlan_destroy $h2 10132 tc qdisc del dev $h2 clsact133 simple_if_fini $h2134}135 136rp1_set_addr()137{138 ip address add dev $rp1 192.0.2.17/28139 140 ip route add 192.0.2.32/28 nexthop via 192.0.2.18141 ip route add 192.0.2.48/28 nexthop via 192.0.2.18142}143 144rp1_unset_addr()145{146 ip route del 192.0.2.48/28 nexthop via 192.0.2.18147 ip route del 192.0.2.32/28 nexthop via 192.0.2.18148 149 ip address del dev $rp1 192.0.2.17/28150}151 152switch_create()153{154 ip link add name br1 type bridge vlan_filtering 1 vlan_default_pvid 0 \155 mcast_snooping 0156 # Make sure the bridge uses the MAC address of the local port and not157 # that of the VxLAN's device.158 ip link set dev br1 address $(mac_get $swp1)159 ip link set dev br1 up160 161 ip link set dev $rp1 up162 rp1_set_addr163 164 ip link add name vx10 type vxlan id 1000 \165 local 192.0.2.17 dstport "$VXPORT" \166 nolearning noudpcsum tos inherit ttl 100167 ip link set dev vx10 up168 169 ip link set dev vx10 master br1170 bridge vlan add vid 10 dev vx10 pvid untagged171 172 ip link add name vx20 type vxlan id 2000 \173 local 192.0.2.17 dstport "$VXPORT" \174 nolearning noudpcsum tos inherit ttl 100175 ip link set dev vx20 up176 177 ip link set dev vx20 master br1178 bridge vlan add vid 20 dev vx20 pvid untagged179 180 ip link set dev $swp1 master br1181 ip link set dev $swp1 up182 bridge vlan add vid 10 dev $swp1183 bridge vlan add vid 20 dev $swp1184 185 ip link set dev $swp2 master br1186 ip link set dev $swp2 up187 bridge vlan add vid 10 dev $swp2188 bridge vlan add vid 20 dev $swp2189 190 bridge fdb append dev vx10 00:00:00:00:00:00 dst 192.0.2.34 self191 bridge fdb append dev vx10 00:00:00:00:00:00 dst 192.0.2.50 self192 193 bridge fdb append dev vx20 00:00:00:00:00:00 dst 192.0.2.34 self194 bridge fdb append dev vx20 00:00:00:00:00:00 dst 192.0.2.50 self195}196 197switch_destroy()198{199 bridge fdb del dev vx20 00:00:00:00:00:00 dst 192.0.2.50 self200 bridge fdb del dev vx20 00:00:00:00:00:00 dst 192.0.2.34 self201 202 bridge fdb del dev vx10 00:00:00:00:00:00 dst 192.0.2.50 self203 bridge fdb del dev vx10 00:00:00:00:00:00 dst 192.0.2.34 self204 205 bridge vlan del vid 20 dev $swp2206 bridge vlan del vid 10 dev $swp2207 ip link set dev $swp2 down208 ip link set dev $swp2 nomaster209 210 bridge vlan del vid 20 dev $swp1211 bridge vlan del vid 10 dev $swp1212 ip link set dev $swp1 down213 ip link set dev $swp1 nomaster214 215 bridge vlan del vid 20 dev vx20216 ip link set dev vx20 nomaster217 218 ip link set dev vx20 down219 ip link del dev vx20220 221 bridge vlan del vid 10 dev vx10222 ip link set dev vx10 nomaster223 224 ip link set dev vx10 down225 ip link del dev vx10226 227 rp1_unset_addr228 ip link set dev $rp1 down229 230 ip link set dev br1 down231 ip link del dev br1232}233 234vrp2_create()235{236 simple_if_init $rp2 192.0.2.18/28237 __simple_if_init v1 v$rp2 192.0.2.33/28238 __simple_if_init v3 v$rp2 192.0.2.49/28239 tc qdisc add dev v1 clsact240}241 242vrp2_destroy()243{244 tc qdisc del dev v1 clsact245 __simple_if_fini v3 192.0.2.49/28246 __simple_if_fini v1 192.0.2.33/28247 simple_if_fini $rp2 192.0.2.18/28248}249 250ns_init_common()251{252 local in_if=$1; shift253 local in_addr=$1; shift254 local other_in_addr=$1; shift255 local nh_addr=$1; shift256 local host_addr1=$1; shift257 local host_addr2=$1; shift258 259 ip link set dev $in_if up260 ip address add dev $in_if $in_addr/28261 tc qdisc add dev $in_if clsact262 263 ip link add name br2 type bridge vlan_filtering 1 vlan_default_pvid 0264 ip link set dev br2 up265 266 ip link add name w1 type veth peer name w2267 268 ip link set dev w1 master br2269 ip link set dev w1 up270 271 bridge vlan add vid 10 dev w1272 bridge vlan add vid 20 dev w1273 274 ip link add name vx10 type vxlan id 1000 local $in_addr \275 dstport "$VXPORT"276 ip link set dev vx10 up277 bridge fdb append dev vx10 00:00:00:00:00:00 dst 192.0.2.17 self278 bridge fdb append dev vx10 00:00:00:00:00:00 dst $other_in_addr self279 280 ip link set dev vx10 master br2281 tc qdisc add dev vx10 clsact282 283 bridge vlan add vid 10 dev vx10 pvid untagged284 285 ip link add name vx20 type vxlan id 2000 local $in_addr \286 dstport "$VXPORT"287 ip link set dev vx20 up288 bridge fdb append dev vx20 00:00:00:00:00:00 dst 192.0.2.17 self289 bridge fdb append dev vx20 00:00:00:00:00:00 dst $other_in_addr self290 291 ip link set dev vx20 master br2292 tc qdisc add dev vx20 clsact293 294 bridge vlan add vid 20 dev vx20 pvid untagged295 296 simple_if_init w2297 vlan_create w2 10 vw2 $host_addr1/28298 vlan_create w2 20 vw2 $host_addr2/24299 300 ip route add 192.0.2.16/28 nexthop via $nh_addr301 ip route add $other_in_addr/32 nexthop via $nh_addr302}303export -f ns_init_common304 305ns1_create()306{307 ip netns add ns1308 ip link set dev v2 netns ns1309 in_ns ns1 \310 ns_init_common v2 192.0.2.34 192.0.2.50 192.0.2.33 192.0.2.3 \311 198.51.100.3312}313 314ns1_destroy()315{316 ip netns exec ns1 ip link set dev v2 netns 1317 ip netns del ns1318}319 320ns2_create()321{322 ip netns add ns2323 ip link set dev v4 netns ns2324 in_ns ns2 \325 ns_init_common v4 192.0.2.50 192.0.2.34 192.0.2.49 192.0.2.4 \326 198.51.100.4327}328 329ns2_destroy()330{331 ip netns exec ns2 ip link set dev v4 netns 1332 ip netns del ns2333}334 335setup_prepare()336{337 h1=${NETIFS[p1]}338 swp1=${NETIFS[p2]}339 340 swp2=${NETIFS[p3]}341 h2=${NETIFS[p4]}342 343 rp1=${NETIFS[p5]}344 rp2=${NETIFS[p6]}345 346 vrf_prepare347 forwarding_enable348 349 h1_create350 h2_create351 switch_create352 353 ip link add name v1 type veth peer name v2354 ip link add name v3 type veth peer name v4355 vrp2_create356 ns1_create357 ns2_create358 359 r1_mac=$(in_ns ns1 mac_get w2)360 r2_mac=$(in_ns ns2 mac_get w2)361 h2_mac=$(mac_get $h2)362}363 364cleanup()365{366 pre_cleanup367 368 ns2_destroy369 ns1_destroy370 vrp2_destroy371 ip link del dev v3372 ip link del dev v1373 374 switch_destroy375 h2_destroy376 h1_destroy377 378 forwarding_restore379 vrf_cleanup380}381 382# For the first round of tests, vx10 and vx20 were the first devices to get383# attached to the bridge, and that at the point that the local IP is already384# configured. Try the other scenario of attaching these devices to a bridge385# that already has local ports members, and only then assign the local IP.386reapply_config()387{388 log_info "Reapplying configuration"389 390 bridge fdb del dev vx20 00:00:00:00:00:00 dst 192.0.2.50 self391 bridge fdb del dev vx20 00:00:00:00:00:00 dst 192.0.2.34 self392 393 bridge fdb del dev vx10 00:00:00:00:00:00 dst 192.0.2.50 self394 bridge fdb del dev vx10 00:00:00:00:00:00 dst 192.0.2.34 self395 396 ip link set dev vx20 nomaster397 ip link set dev vx10 nomaster398 399 rp1_unset_addr400 sleep 5401 402 ip link set dev vx10 master br1403 bridge vlan add vid 10 dev vx10 pvid untagged404 405 ip link set dev vx20 master br1406 bridge vlan add vid 20 dev vx20 pvid untagged407 408 bridge fdb append dev vx10 00:00:00:00:00:00 dst 192.0.2.34 self409 bridge fdb append dev vx10 00:00:00:00:00:00 dst 192.0.2.50 self410 411 bridge fdb append dev vx20 00:00:00:00:00:00 dst 192.0.2.34 self412 bridge fdb append dev vx20 00:00:00:00:00:00 dst 192.0.2.50 self413 414 rp1_set_addr415 sleep 5416}417 418ping_ipv4()419{420 ping_test $h1.10 192.0.2.2 ": local->local vid 10"421 ping_test $h1.20 198.51.100.2 ": local->local vid 20"422 ping_test $h1.10 192.0.2.3 ": local->remote 1 vid 10"423 ping_test $h1.10 192.0.2.4 ": local->remote 2 vid 10"424 ping_test $h1.20 198.51.100.3 ": local->remote 1 vid 20"425 ping_test $h1.20 198.51.100.4 ": local->remote 2 vid 20"426}427 428maybe_in_ns()429{430 echo ${1:+in_ns} $1431}432 433__flood_counter_add_del()434{435 local add_del=$1; shift436 local dev=$1; shift437 local ns=$1; shift438 439 # Putting the ICMP capture both to HW and to SW will end up440 # double-counting the packets that are trapped to slow path, such as for441 # the unicast test. Adding either skip_hw or skip_sw fixes this problem,442 # but with skip_hw, the flooded packets are not counted at all, because443 # those are dropped due to MAC address mismatch; and skip_sw is a no-go444 # for veth-based topologies.445 #446 # So try to install with skip_sw and fall back to skip_sw if that fails.447 448 $(maybe_in_ns $ns) __icmp_capture_add_del \449 $add_del 100 "" $dev skip_sw 2>/dev/null || \450 $(maybe_in_ns $ns) __icmp_capture_add_del \451 $add_del 100 "" $dev skip_hw452}453 454flood_counter_install()455{456 __flood_counter_add_del add "$@"457}458 459flood_counter_uninstall()460{461 __flood_counter_add_del del "$@"462}463 464flood_fetch_stat()465{466 local dev=$1; shift467 local ns=$1; shift468 469 $(maybe_in_ns $ns) tc_rule_stats_get $dev 100 ingress470}471 472flood_fetch_stats()473{474 local counters=("${@}")475 local counter476 477 for counter in "${counters[@]}"; do478 flood_fetch_stat $counter479 done480}481 482vxlan_flood_test()483{484 local mac=$1; shift485 local dst=$1; shift486 local vid=$1; shift487 local -a expects=("${@}")488 489 local -a counters=($h2 "vx10 ns1" "vx20 ns1" "vx10 ns2" "vx20 ns2")490 local counter491 local key492 493 # Packets reach the local host tagged whereas they reach the VxLAN494 # devices untagged. In order to be able to use the same filter for495 # all counters, make sure the packets also reach the local host496 # untagged497 bridge vlan add vid $vid dev $swp2 untagged498 for counter in "${counters[@]}"; do499 flood_counter_install $counter500 done501 502 local -a t0s=($(flood_fetch_stats "${counters[@]}"))503 $MZ $h1 -Q $vid -c 10 -d 100msec -p 64 -b $mac -B $dst -t icmp -q504 sleep 1505 local -a t1s=($(flood_fetch_stats "${counters[@]}"))506 507 for key in ${!t0s[@]}; do508 local delta=$((t1s[$key] - t0s[$key]))509 local expect=${expects[$key]}510 511 ((expect == delta))512 check_err $? "${counters[$key]}: Expected to capture $expect packets, got $delta."513 done514 515 for counter in "${counters[@]}"; do516 flood_counter_uninstall $counter517 done518 bridge vlan add vid $vid dev $swp2519}520 521__test_flood()522{523 local mac=$1; shift524 local dst=$1; shift525 local vid=$1; shift526 local what=$1; shift527 local -a expects=("${@}")528 529 RET=0530 531 vxlan_flood_test $mac $dst $vid "${expects[@]}"532 533 log_test "VXLAN: $what"534}535 536test_flood()537{538 __test_flood de:ad:be:ef:13:37 192.0.2.100 10 "flood vlan 10" \539 10 10 0 10 0540 __test_flood ca:fe:be:ef:13:37 198.51.100.100 20 "flood vlan 20" \541 10 0 10 0 10542}543 544vxlan_fdb_add_del()545{546 local add_del=$1; shift547 local vid=$1; shift548 local mac=$1; shift549 local dev=$1; shift550 local dst=$1; shift551 552 bridge fdb $add_del dev $dev $mac self static permanent \553 ${dst:+dst} $dst 2>/dev/null554 bridge fdb $add_del dev $dev $mac master static vlan $vid 2>/dev/null555}556 557__test_unicast()558{559 local mac=$1; shift560 local dst=$1; shift561 local hit_idx=$1; shift562 local vid=$1; shift563 local what=$1; shift564 565 RET=0566 567 local -a expects=(0 0 0 0 0)568 expects[$hit_idx]=10569 570 vxlan_flood_test $mac $dst $vid "${expects[@]}"571 572 log_test "VXLAN: $what"573}574 575test_unicast()576{577 local -a targets=("$h2_mac $h2"578 "$r1_mac vx10 192.0.2.34"579 "$r2_mac vx10 192.0.2.50")580 local target581 582 log_info "unicast vlan 10"583 584 for target in "${targets[@]}"; do585 vxlan_fdb_add_del add 10 $target586 done587 588 __test_unicast $h2_mac 192.0.2.2 0 10 "local MAC unicast"589 __test_unicast $r1_mac 192.0.2.3 1 10 "remote MAC 1 unicast"590 __test_unicast $r2_mac 192.0.2.4 3 10 "remote MAC 2 unicast"591 592 for target in "${targets[@]}"; do593 vxlan_fdb_add_del del 10 $target594 done595 596 log_info "unicast vlan 20"597 598 targets=("$h2_mac $h2" "$r1_mac vx20 192.0.2.34" \599 "$r2_mac vx20 192.0.2.50")600 601 for target in "${targets[@]}"; do602 vxlan_fdb_add_del add 20 $target603 done604 605 __test_unicast $h2_mac 198.51.100.2 0 20 "local MAC unicast"606 __test_unicast $r1_mac 198.51.100.3 2 20 "remote MAC 1 unicast"607 __test_unicast $r2_mac 198.51.100.4 4 20 "remote MAC 2 unicast"608 609 for target in "${targets[@]}"; do610 vxlan_fdb_add_del del 20 $target611 done612}613 614test_pvid()615{616 local -a expects=(0 0 0 0 0)617 local mac=de:ad:be:ef:13:37618 local dst=192.0.2.100619 local vid=10620 621 # Check that flooding works622 RET=0623 624 expects[0]=10; expects[1]=10; expects[3]=10625 vxlan_flood_test $mac $dst $vid "${expects[@]}"626 627 log_test "VXLAN: flood before pvid off"628 629 # Toggle PVID off and test that flood to remote hosts does not work630 RET=0631 632 bridge vlan add vid 10 dev vx10633 634 expects[0]=10; expects[1]=0; expects[3]=0635 vxlan_flood_test $mac $dst $vid "${expects[@]}"636 637 log_test "VXLAN: flood after pvid off"638 639 # Toggle PVID on and test that flood to remote hosts does work640 RET=0641 642 bridge vlan add vid 10 dev vx10 pvid untagged643 644 expects[0]=10; expects[1]=10; expects[3]=10645 vxlan_flood_test $mac $dst $vid "${expects[@]}"646 647 log_test "VXLAN: flood after pvid on"648 649 # Add a new VLAN and test that it does not affect flooding650 RET=0651 652 bridge vlan add vid 30 dev vx10653 654 expects[0]=10; expects[1]=10; expects[3]=10655 vxlan_flood_test $mac $dst $vid "${expects[@]}"656 657 bridge vlan del vid 30 dev vx10658 659 log_test "VXLAN: flood after vlan add"660 661 # Remove currently mapped VLAN and test that flood to remote hosts does662 # not work663 RET=0664 665 bridge vlan del vid 10 dev vx10666 667 expects[0]=10; expects[1]=0; expects[3]=0668 vxlan_flood_test $mac $dst $vid "${expects[@]}"669 670 log_test "VXLAN: flood after vlan delete"671 672 # Re-add the VLAN and test that flood to remote hosts does work673 RET=0674 675 bridge vlan add vid 10 dev vx10 pvid untagged676 677 expects[0]=10; expects[1]=10; expects[3]=10678 vxlan_flood_test $mac $dst $vid "${expects[@]}"679 680 log_test "VXLAN: flood after vlan re-add"681}682 683__test_learning()684{685 local -a expects=(0 0 0 0 0)686 local mac=$1; shift687 local dst=$1; shift688 local vid=$1; shift689 local idx1=$1; shift690 local idx2=$1; shift691 local vx=vx$vid692 693 # Check that flooding works694 RET=0695 696 expects[0]=10; expects[$idx1]=10; expects[$idx2]=10697 vxlan_flood_test $mac $dst $vid "${expects[@]}"698 699 log_test "VXLAN: flood before learning"700 701 # Send a packet with source mac set to $mac from host w2 and check that702 # a corresponding entry is created in the VxLAN device703 RET=0704 705 in_ns ns1 $MZ w2 -Q $vid -c 1 -p 64 -a $mac -b ff:ff:ff:ff:ff:ff \706 -B $dst -t icmp -q707 sleep 1708 709 bridge fdb show brport $vx | grep $mac | grep -q self710 check_err $?711 bridge fdb show brport $vx | grep $mac | grep "vlan $vid" \712 | grep -q -v self713 check_err $?714 715 log_test "VXLAN: show learned FDB entry"716 717 # Repeat first test and check that packets only reach host w2 in ns1718 RET=0719 720 expects[0]=0; expects[$idx1]=10; expects[$idx2]=0721 vxlan_flood_test $mac $dst $vid "${expects[@]}"722 723 log_test "VXLAN: learned FDB entry"724 725 # Delete the learned FDB entry from the VxLAN and bridge devices and726 # check that packets are flooded727 RET=0728 729 bridge fdb del dev $vx $mac master self vlan $vid730 sleep 1731 732 expects[0]=10; expects[$idx1]=10; expects[$idx2]=10733 vxlan_flood_test $mac $dst $vid "${expects[@]}"734 735 log_test "VXLAN: deletion of learned FDB entry"736 737 # Re-learn the first FDB entry and check that it is correctly aged-out738 RET=0739 740 in_ns ns1 $MZ w2 -Q $vid -c 1 -p 64 -a $mac -b ff:ff:ff:ff:ff:ff \741 -B $dst -t icmp -q742 sleep 1743 744 bridge fdb show brport $vx | grep $mac | grep -q self745 check_err $?746 bridge fdb show brport $vx | grep $mac | grep "vlan $vid" \747 | grep -q -v self748 check_err $?749 750 expects[0]=0; expects[$idx1]=10; expects[$idx2]=0751 vxlan_flood_test $mac $dst $vid "${expects[@]}"752 753 sleep 60754 755 bridge fdb show brport $vx | grep $mac | grep -q self756 check_fail $?757 bridge fdb show brport $vx | grep $mac | grep "vlan $vid" \758 | grep -q -v self759 check_fail $?760 761 expects[0]=10; expects[$idx1]=10; expects[$idx2]=10762 vxlan_flood_test $mac $dst $vid "${expects[@]}"763 764 log_test "VXLAN: Ageing of learned FDB entry"765 766 # Toggle learning on the bridge port and check that the bridge's FDB767 # is populated only when it should768 RET=0769 770 ip link set dev $vx type bridge_slave learning off771 772 in_ns ns1 $MZ w2 -Q $vid -c 1 -p 64 -a $mac -b ff:ff:ff:ff:ff:ff \773 -B $dst -t icmp -q774 sleep 1775 776 bridge fdb show brport $vx | grep $mac | grep "vlan $vid" \777 | grep -q -v self778 check_fail $?779 780 ip link set dev $vx type bridge_slave learning on781 782 in_ns ns1 $MZ w2 -Q $vid -c 1 -p 64 -a $mac -b ff:ff:ff:ff:ff:ff \783 -B $dst -t icmp -q784 sleep 1785 786 bridge fdb show brport $vx | grep $mac | grep "vlan $vid" \787 | grep -q -v self788 check_err $?789 790 log_test "VXLAN: learning toggling on bridge port"791}792 793test_learning()794{795 local mac=de:ad:be:ef:13:37796 local dst=192.0.2.100797 local vid=10798 799 # Enable learning on the VxLAN devices and set ageing time to 30 seconds800 ip link set dev br1 type bridge ageing_time 3000801 ip link set dev vx10 type vxlan ageing 30802 ip link set dev vx10 type vxlan learning803 ip link set dev vx20 type vxlan ageing 30804 ip link set dev vx20 type vxlan learning805 reapply_config806 807 log_info "learning vlan 10"808 809 __test_learning $mac $dst $vid 1 3810 811 log_info "learning vlan 20"812 813 mac=ca:fe:be:ef:13:37814 dst=198.51.100.100815 vid=20816 817 __test_learning $mac $dst $vid 2 4818 819 # Restore previous settings820 ip link set dev vx20 type vxlan nolearning821 ip link set dev vx20 type vxlan ageing 300822 ip link set dev vx10 type vxlan nolearning823 ip link set dev vx10 type vxlan ageing 300824 ip link set dev br1 type bridge ageing_time 30000825 reapply_config826}827 828test_all()829{830 log_info "Running tests with UDP port $VXPORT"831 tests_run832}833 834trap cleanup EXIT835 836setup_prepare837setup_wait838test_all839 840exit $EXIT_STATUS841