106 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding"5NUM_NETIFS=46source lib.sh7 8h1_create()9{10 simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/6411}12 13h1_destroy()14{15 simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/6416}17 18h2_create()19{20 simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/6421}22 23h2_destroy()24{25 simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/6426}27 28switch_create()29{30 ip link add dev br0 type bridge \31 ageing_time $LOW_AGEING_TIME \32 mcast_snooping 033 34 ip link set dev $swp1 master br035 ip link set dev $swp2 master br036 37 ip link set dev br0 up38 ip link set dev $swp1 up39 ip link set dev $swp2 up40}41 42switch_destroy()43{44 ip link set dev $swp2 down45 ip link set dev $swp1 down46 47 ip link del dev br048}49 50setup_prepare()51{52 h1=${NETIFS[p1]}53 swp1=${NETIFS[p2]}54 55 swp2=${NETIFS[p3]}56 h2=${NETIFS[p4]}57 58 vrf_prepare59 60 h1_create61 h2_create62 63 switch_create64}65 66cleanup()67{68 pre_cleanup69 70 switch_destroy71 72 h2_destroy73 h1_destroy74 75 vrf_cleanup76}77 78ping_ipv4()79{80 ping_test $h1 192.0.2.281}82 83ping_ipv6()84{85 ping6_test $h1 2001:db8:1::286}87 88learning()89{90 learning_test "br0" $swp1 $h1 $h291}92 93flooding()94{95 flood_test $swp2 $h1 $h296}97 98trap cleanup EXIT99 100setup_prepare101setup_wait102 103tests_run104 105exit $EXIT_STATUS106