]>
git.ipfire.org Git - people/ms/network.git/blob - functions.switch
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
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. #
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. #
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/>. #
20 ###############################################################################
22 function switch_start
() {
23 local service
="openvswitch.service"
25 if ! service_is_active
"${service}"; then
26 service_start
"${service}"
32 function switch_create
() {
36 # Make sure that the openvswitch service is running.
39 log DEBUG
"Creating virtual switch: ${device}"
40 ovs-vsctl
-- --may-exist add-br
${device}
42 assert device_exists
${device}
47 function switch_remove
() {
52 device_set_down
${device}
54 log DEBUG
"Removing virtual switch: ${device}"
55 ovs-vsctl
-- --if-exists del-br
${device}
60 function switch_exists
() {
64 ovs-vsctl
-- br-exists
${device}
77 function switch_get_members
() {
81 ovs-vsctl
-- list-ports
${device}
85 function switch_attach_port
() {
92 log DEBUG
"Attaching port '${port}' to switch '${device}'"
93 ovs-vsctl
-- --may-exist add-port
"${device}" "${port}"
98 function switch_detach_port
() {
105 log DEBUG
"Detaching port '${port}' from switch '${device}'"
106 ovs-vsctl
-- --if-exists del-port
"${device}" "${port}"
111 function switch_stp_enable
() {
115 log DEBUG
"Enable STP on switch ${device}"
116 ovs-vsctl
set Bridge
${device} "stp_enable=true"
121 function switch_stp_disable
() {
125 log DEBUG
"Disable STP on switch ${device}"
126 ovs-vsctl
set Bridge
${device} "stp_enable=false"
131 function switch_stp_is_enabled
() {
135 local output
=$
(ovs-vsctl
-- --if-exists get Bridge
${device} stp_enable
)
137 if enabled output
; then