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 ip link add dev br0 type bridge \ 31 ageing_time $LOW_AGEING_TIME \ 32 mcast_snooping 0 33 34 ip link set dev $swp1 master br0 35 ip link set dev $swp2 master br0 36 37 ip link set dev br0 up 38 ip link set dev $swp1 up 39 ip link set dev $swp2 up 40} 41 42switch_destroy() 43{ 44 ip link set dev $swp2 down 45 ip link set dev $swp1 down 46 47 ip link del dev br0 48} 49 50setup_prepare() 51{ 52 h1=${NETIFS[p1]} 53 swp1=${NETIFS[p2]} 54 55 swp2=${NETIFS[p3]} 56 h2=${NETIFS[p4]} 57 58 vrf_prepare 59 60 h1_create 61 h2_create 62 63 switch_create 64} 65 66cleanup() 67{ 68 pre_cleanup 69 70 switch_destroy 71 72 h2_destroy 73 h1_destroy 74 75 vrf_cleanup 76} 77 78ping_ipv4() 79{ 80 ping_test $h1 192.0.2.2 81} 82 83ping_ipv6() 84{ 85 ping6_test $h1 2001:db8:1::2 86} 87 88learning() 89{ 90 learning_test "br0" $swp1 $h1 $h2 91} 92 93flooding() 94{ 95 flood_test $swp2 $h1 $h2 96} 97 98trap cleanup EXIT 99 100setup_prepare 101setup_wait 102 103tests_run 104 105exit $EXIT_STATUS 106