Linux-libre 5.3.12-gnu
[librecmc/linux-libre.git] / tools / testing / selftests / net / forwarding / bridge_vlan_unaware.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding"
5 NUM_NETIFS=4
6 source lib.sh
7
8 h1_create()
9 {
10         simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
11 }
12
13 h1_destroy()
14 {
15         simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
16 }
17
18 h2_create()
19 {
20         simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/64
21 }
22
23 h2_destroy()
24 {
25         simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64
26 }
27
28 switch_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
41 switch_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
49 setup_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
65 cleanup()
66 {
67         pre_cleanup
68
69         switch_destroy
70
71         h2_destroy
72         h1_destroy
73
74         vrf_cleanup
75 }
76
77 ping_ipv4()
78 {
79         ping_test $h1 192.0.2.2
80 }
81
82 ping_ipv6()
83 {
84         ping6_test $h1 2001:db8:1::2
85 }
86
87 learning()
88 {
89         learning_test "br0" $swp1 $h1 $h2
90 }
91
92 flooding()
93 {
94         flood_test $swp2 $h1 $h2
95 }
96
97 trap cleanup EXIT
98
99 setup_prepare
100 setup_wait
101
102 tests_run
103
104 exit $EXIT_STATUS