-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path30-stp-vlan.sh
49 lines (36 loc) · 1.4 KB
/
30-stp-vlan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Basic VLAN forwarding test. Two access ports in separate VLANS and one
# trunk port. Inject frames on both access ports and verify blocking on
# one VLAN on the trunk.
# shellcheck disable=SC2154 disable=SC2046 disable=SC2086
basic_stp_vlan()
{
require3loops
if ! bridge vlan help 2>&1 | grep -q STP_STATE; then
step "STP per VLAN not supported, skipping."
skip
fi
create_br $br0 "vlan_default_pvid 0 vlan_filtering 1" $bports
bridge vlan add vid 1 dev $b1 pvid untagged
bridge vlan add vid 2 dev $b2 pvid untagged
bridge vlan add vid 2 dev $b3
bridge vlan add vid 1 dev $b3
capture $h3
step "Injecting broadcast on $h1 and $h2"
eth -b | { cat; echo from $h1; } | inject $h1
eth -b | { cat; echo from $h2; } | inject $h2
step "Verifying broadcast on $h3"
report $h3 | grep -q "from $h1" || fail
report $h3 | grep -q "from $h2" || fail
step "Setting VLAN 1 on $b3 in blocking state"
bridge vlan set vid 1 dev $b3 state blocking
bridge -d vlan show
step "Injecting broadcast on $b1 and $b2"
capture $h3
eth -b | { cat; echo from $h1; } | inject $h1
eth -b | { cat; echo from $h2; } | inject $h2
step "Verifying broadcast on $h3, now only from $b2 (VLAN 2)"
report $h3 | grep -q "from $h1" && fail
report $h3 | grep -q "from $h2" || fail
pass
}
experimentaltests="$experimentaltests basic_stp_vlan"