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