1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding" 5NUM_NETIFS=4 6source lib.sh 7 8h1_create() 9{ 10 simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64 11} 12 13h1_destroy() 14{ 15 simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64 16} 17 18h2_create() 19{ 20 simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/64 21} 22 23h2_destroy() 24{ 25 simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64 26} 27 28switch_create() 29{ 30 # 10 Seconds ageing time. 31 ip link add dev br0 type bridge ageing_time 1000 mcast_snooping 0 32 33 ip link set dev $swp1 master br0 34 ip link set dev $swp2 master br0 35 36 ip link set dev br0 up 37 ip link set dev $swp1 up 38 ip link set dev $swp2 up 39} 40 41switch_destroy() 42{ 43 ip link set dev $swp2 down 44 ip link set dev $swp1 down 45 46 ip link del dev br0 47} 48 49setup_prepare() 50{ 51 h1=${NETIFS[p1]} 52 swp1=${NETIFS[p2]} 53 54 swp2=${NETIFS[p3]} 55 h2=${NETIFS[p4]} 56 57 vrf_prepare 58 59 h1_create 60 h2_create 61 62 switch_create 63} 64 65cleanup() 66{ 67 pre_cleanup 68 69 switch_destroy 70 71 h2_destroy 72 h1_destroy 73 74 vrf_cleanup 75} 76 77ping_ipv4() 78{ 79 ping_test $h1 192.0.2.2 80} 81 82ping_ipv6() 83{ 84 ping6_test $h1 2001:db8:1::2 85} 86 87learning() 88{ 89 learning_test "br0" $swp1 $h1 $h2 90} 91 92flooding() 93{ 94 flood_test $swp2 $h1 $h2 95} 96 97trap cleanup EXIT 98 99setup_prepare 100setup_wait 101 102tests_run 103 104exit $EXIT_STATUS 105