]> git.ipfire.org Git - people/stevee/network.git/blobdiff - functions.switch
firewall: Re-unity firewall6/4 configuration again.
[people/stevee/network.git] / functions.switch
index 69894ff47d5b5aa7ddb49fc1a491f569197bf7a2..5a370efe719db5782f9f3cbd697b39f488ee9c7b 100644 (file)
 #                                                                             #
 ###############################################################################
 
+function switch_start() {
+       local service="openvswitch.service"
+
+       if ! service_is_active "${service}"; then
+               service_start "${service}"
+       fi
+
+       return ${EXIT_OK}
+}
+
 function switch_create() {
        local device=${1}
        assert isset device
 
+       # Make sure that the openvswitch service is running.
+       switch_start
+
        log DEBUG "Creating virtual switch: ${device}"
        ovs-vsctl -- --may-exist add-br ${device}
 
@@ -77,7 +90,7 @@ function switch_attach_port() {
        assert isset port
 
        log DEBUG "Attaching port '${port}' to switch '${device}'"
-       ovs-vsctl -- --may-exist ${device} ${port}
+       ovs-vsctl -- --may-exist add-port "${device}" "${port}"
 
        return ${EXIT_OK}
 }
@@ -90,7 +103,7 @@ function switch_detach_port() {
        assert isset port
 
        log DEBUG "Detaching port '${port}' from switch '${device}'"
-       ovs-vsctl -- --if-exists ${device} ${port}
+       ovs-vsctl -- --if-exists del-port "${device}" "${port}"
 
        return ${EXIT_OK}
 }