]>
Commit | Line | Data |
---|---|---|
30812a00 MT |
1 | #!/bin/sh |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire - An Open Source Firewall Solution # | |
5 | # Copyright (C) 2011 IPFire development team # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
7d85603e MT |
22 | EXIT_USERSPACE_STP=0 |
23 | EXIT_KERNEL_STP=1 | |
24 | ||
6c95a49a MT |
25 | # Change LOG_FACILITY that we will find our messages in syslog. |
26 | LOG_FACILITY=$(basename ${0}) | |
27 | ||
4cf2e1dd MT |
28 | . /usr/lib/network/functions |
29 | ||
6c95a49a | 30 | zone=${1} |
6c95a49a | 31 | assert isset zone |
7d85603e MT |
32 | |
33 | action=${2} | |
6c95a49a MT |
34 | assert isset action |
35 | ||
36 | # Exit immediately, if zone configuration does not exist. | |
37 | # This is for manually created bridges. | |
38 | if ! zone_exists ${zone}; then | |
7d85603e | 39 | exit ${EXIT_KERNEL_STP} |
6c95a49a MT |
40 | fi |
41 | ||
7d85603e MT |
42 | # Read zone configuration. |
43 | zone_config_read ${zone} | |
6c95a49a | 44 | |
7d85603e MT |
45 | # Make sure STP is enabled for this zone. |
46 | assert enabled STP | |
6c95a49a | 47 | |
7d85603e MT |
48 | log DEBUG "Configured STP mode is '${STP_MODE}'" |
49 | ||
50 | case "${STP_MODE}" in | |
51 | rstp) | |
52 | # Check if mstpd is running. If not, try to start it. | |
53 | if ! service_is_active mstpd; then | |
54 | service_start "mstpd.service" | |
55 | ||
56 | if ! service_is_active "mstpd.service"; then | |
57 | log ERROR "mstpd is not running. STP might not work." | |
58 | exit 1 | |
59 | fi | |
60 | fi | |
61 | ||
064655d5 MT |
62 | # Set the right protocol that should be used. |
63 | # Do this after the bridge has been added. | |
64 | ( | |
65 | sleep 2 | |
66 | stp_bridge_set_protocol ${bridge} ${STP_MODE} | |
67 | ) & | |
68 | ||
7d85603e MT |
69 | # Tell mstpd that STP has to be enabled/disabled. |
70 | case "${action}" in | |
71 | start) | |
72 | log DEBUG "Enabling userspace STP for zone '${zone}'" | |
73 | exec mstpctl addbridge ${zone} | |
74 | ;; | |
75 | stop) | |
76 | log DEBUG "Disabling userspace STP for zone '${zone}'" | |
77 | exec mstpctl delbridge ${zone} | |
78 | ;; | |
79 | esac | |
80 | ||
81 | log ERROR "Could not properly exec mstpctl." | |
6c95a49a | 82 | ;; |
7d85603e MT |
83 | stp) |
84 | case "${action}" in | |
85 | start) | |
86 | log DEBUG "Enabling kernel STP for zone '${zone}'" | |
87 | exit ${EXIT_KERNEL_STP} | |
88 | ;; | |
89 | stop) | |
90 | log DEBUG "Disabling kernel STP for zone '${zone}'" | |
91 | exit ${EXIT_OK} | |
92 | ;; | |
93 | esac | |
6c95a49a MT |
94 | ;; |
95 | esac | |
a955a84f | 96 | |
7d85603e MT |
97 | # Fall back to kernel STP. |
98 | exit ${EXIT_KERNEL_STP} |