WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / bridge_port_isolation.sh
bloba43b4645c4de1dd5648a85413ad7a012acb82f5b
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS="ping_ipv4 ping_ipv6 flooding"
5 NUM_NETIFS=6
6 CHECK_TC="yes"
7 source lib.sh
9 h1_create()
11 simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
14 h1_destroy()
16 simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
19 h2_create()
21 simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/64
24 h2_destroy()
26 simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64
29 h3_create()
31 simple_if_init $h3 192.0.2.3/24 2001:db8:1::3/64
34 h3_destroy()
36 simple_if_fini $h3 192.0.2.3/24 2001:db8:1::3/64
39 switch_create()
41 ip link add dev br0 type bridge
43 ip link set dev $swp1 master br0
44 ip link set dev $swp2 master br0
45 ip link set dev $swp3 master br0
47 ip link set dev $swp1 type bridge_slave isolated on
48 check_err $? "Can't set isolation on port $swp1"
49 ip link set dev $swp2 type bridge_slave isolated on
50 check_err $? "Can't set isolation on port $swp2"
51 ip link set dev $swp3 type bridge_slave isolated off
52 check_err $? "Can't disable isolation on port $swp3"
54 ip link set dev br0 up
55 ip link set dev $swp1 up
56 ip link set dev $swp2 up
57 ip link set dev $swp3 up
60 switch_destroy()
62 ip link set dev $swp3 down
63 ip link set dev $swp2 down
64 ip link set dev $swp1 down
66 ip link del dev br0
69 setup_prepare()
71 h1=${NETIFS[p1]}
72 swp1=${NETIFS[p2]}
74 swp2=${NETIFS[p3]}
75 h2=${NETIFS[p4]}
77 swp3=${NETIFS[p5]}
78 h3=${NETIFS[p6]}
80 vrf_prepare
82 h1_create
83 h2_create
84 h3_create
86 switch_create
89 cleanup()
91 pre_cleanup
93 switch_destroy
95 h3_destroy
96 h2_destroy
97 h1_destroy
99 vrf_cleanup
102 ping_ipv4()
104 RET=0
105 ping_do $h1 192.0.2.2
106 check_fail $? "Ping worked when it should not have"
108 RET=0
109 ping_do $h3 192.0.2.2
110 check_err $? "Ping didn't work when it should have"
112 log_test "Isolated port ping"
115 ping_ipv6()
117 RET=0
118 ping6_do $h1 2001:db8:1::2
119 check_fail $? "Ping6 worked when it should not have"
121 RET=0
122 ping6_do $h3 2001:db8:1::2
123 check_err $? "Ping6 didn't work when it should have"
125 log_test "Isolated port ping6"
128 flooding()
130 local mac=de:ad:be:ef:13:37
131 local ip=192.0.2.100
133 RET=0
134 flood_test_do false $mac $ip $h1 $h2
135 check_err $? "Packet was flooded when it should not have been"
137 RET=0
138 flood_test_do true $mac $ip $h3 $h2
139 check_err $? "Packet was not flooded when it should have been"
141 log_test "Isolated port flooding"
144 trap cleanup EXIT
146 setup_prepare
147 setup_wait
149 tests_run
151 exit $EXIT_STATUS