WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / bridge_vlan_aware.sh
blobb90dff8d3a94bf41640564513e4bb73e54f7bcdc
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding vlan_deletion extern_learn"
5 NUM_NETIFS=4
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 switch_create()
31 # 10 Seconds ageing time.
32 ip link add dev br0 type bridge vlan_filtering 1 ageing_time 1000 \
33 mcast_snooping 0
35 ip link set dev $swp1 master br0
36 ip link set dev $swp2 master br0
38 ip link set dev br0 up
39 ip link set dev $swp1 up
40 ip link set dev $swp2 up
43 switch_destroy()
45 ip link set dev $swp2 down
46 ip link set dev $swp1 down
48 ip link del dev br0
51 setup_prepare()
53 h1=${NETIFS[p1]}
54 swp1=${NETIFS[p2]}
56 swp2=${NETIFS[p3]}
57 h2=${NETIFS[p4]}
59 vrf_prepare
61 h1_create
62 h2_create
64 switch_create
67 cleanup()
69 pre_cleanup
71 switch_destroy
73 h2_destroy
74 h1_destroy
76 vrf_cleanup
79 ping_ipv4()
81 ping_test $h1 192.0.2.2
84 ping_ipv6()
86 ping6_test $h1 2001:db8:1::2
89 learning()
91 learning_test "br0" $swp1 $h1 $h2
94 flooding()
96 flood_test $swp2 $h1 $h2
99 vlan_deletion()
101 # Test that the deletion of a VLAN on a bridge port does not affect
102 # the PVID VLAN
103 log_info "Add and delete a VLAN on bridge port $swp1"
105 bridge vlan add vid 10 dev $swp1
106 bridge vlan del vid 10 dev $swp1
108 ping_ipv4
109 ping_ipv6
112 extern_learn()
114 local mac=de:ad:be:ef:13:37
115 local ageing_time
117 # Test that externally learned FDB entries can roam, but not age out
118 RET=0
120 bridge fdb add de:ad:be:ef:13:37 dev $swp1 master extern_learn vlan 1
122 bridge fdb show brport $swp1 | grep -q de:ad:be:ef:13:37
123 check_err $? "Did not find FDB entry when should"
125 # Wait for 10 seconds after the ageing time to make sure the FDB entry
126 # was not aged out
127 ageing_time=$(bridge_ageing_time_get br0)
128 sleep $((ageing_time + 10))
130 bridge fdb show brport $swp1 | grep -q de:ad:be:ef:13:37
131 check_err $? "FDB entry was aged out when should not"
133 $MZ $h2 -c 1 -p 64 -a $mac -t ip -q
135 bridge fdb show brport $swp2 | grep -q de:ad:be:ef:13:37
136 check_err $? "FDB entry did not roam when should"
138 log_test "Externally learned FDB entry - ageing & roaming"
140 bridge fdb del de:ad:be:ef:13:37 dev $swp2 master vlan 1 &> /dev/null
141 bridge fdb del de:ad:be:ef:13:37 dev $swp1 master vlan 1 &> /dev/null
144 trap cleanup EXIT
146 setup_prepare
147 setup_wait
149 tests_run
151 exit $EXIT_STATUS