[ovs-dev] [PATCH] ovs-docker : add fake bridges support.

Paul-Emmanuel Raoul skyper205 at gmail.com
Wed Dec 17 20:56:59 UTC 2014


From 7b693f8f8b5028e445c116531d9d960603222e06 Mon Sep 17 00:00:00 2001
From: Paul-Emmanuel Raoul <skyper at skyplabs.net>
Date: Wed, 17 Dec 2014 02:25:30 +0100
Subject: [PATCH] ovs-docker : add fake bridges support.

Also updates ovs-docker README documentation.

Signed-off-by: Paul-Emmanuel Raoul <skyper at skyplabs.net>
---
 INSTALL.Docker.md    |  9 +++++++++
 utilities/ovs-docker | 51
++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 47 insertions(+), 13 deletions(-)

diff --git a/INSTALL.Docker.md b/INSTALL.Docker.md
index ddbef99..29b3a70 100644
--- a/INSTALL.Docker.md
+++ b/INSTALL.Docker.md
@@ -56,10 +56,19 @@ and then attaches it to the Open vSwitch bridge
'br-int'.  This is done by
 creating a veth pair.  One end of the interface becomes 'eth1' inside
the
 container and the other end attaches to 'br-int'.
 
+If an Open vSwitch fake bridge should be used, you have to specify its
+parent and VLAN.  e.g.:
+
+`% ovs-docker add-port br-int br-parent 10 eth1 $CONTAINER_ID`
+
 The script also lets one to add an IP address to the interface.  e.g.:
 
 `% ovs-docker add-port br-int eth1 $CONTAINER_ID 192.168.1.1/24`
 
+The previous two options can be combined :
+
+`% ovs-docker add-port br-int br-parent 10 eth1 $CONTAINER_ID
192.168.1.1/24`
+
 * A previously added network interface can be deleted.  e.g.:
 
 `% ovs-docker del-port br-int eth1 $CONTAINER_ID`
diff --git a/utilities/ovs-docker b/utilities/ovs-docker
index 4a43a15..e2c306d 100755
--- a/utilities/ovs-docker
+++ b/utilities/ovs-docker
@@ -43,20 +43,44 @@ delete_netns_link () {
 }
 
 add_port () {
-    BRIDGE="$1"
-    INTERFACE="$2"
-    CONTAINER="$3"
-    ADDRESS="$4"
-
     if [ "$#" -lt 3 ]; then
         usage
         exit 1
+	elif [ "$#" -eq 3 ]; then
+		BRIDGE="$1"
+		INTERFACE="$2"
+		CONTAINER="$3"
+	elif [ "$#" -eq 4 ]; then
+		BRIDGE="$1"
+		INTERFACE="$2"
+		CONTAINER="$3"
+		ADDRESS="$4"
+	elif [ "$#" -eq 5 ]; then
+		BRIDGE="$1"
+		PARENT="$2"
+		VLAN="$3"
+		INTERFACE="$4"
+		CONTAINER="$5"
+	elif [ "$#" -eq 6 ]; then
+		BRIDGE="$1"
+		PARENT="$2"
+		VLAN="$3"
+		INTERFACE="$4"
+		CONTAINER="$5"
+		ADDRESS="$6"
     fi
 
-    if ovs_vsctl --may-exist add-br "$BRIDGE"; then :; else
-        echo >&2 "$UTIL: Failed to create bridge $BRIDGE"
-        exit 1
-    fi
+	if [ -n "$PARENT" ]; then
+		if ovs_vsctl --may-exist add-br "$BRIDGE" "$PARENT" "$VLAN"; then :;
else
+			echo >&2 "$UTIL: Failed to create fake bridge $BRIDGE"
+			exit 1
+		fi
+	else
+		if ovs_vsctl --may-exist add-br "$BRIDGE"; then :; else
+			echo >&2 "$UTIL: Failed to create bridge $BRIDGE"
+			exit 1
+		fi
+	fi
 
     if PID=`docker inspect -f '{{.State.Pid}}' "$CONTAINER"`; then :;
else
         echo >&2 "$UTIL: Failed to get the PID of the container"
@@ -142,11 +166,12 @@ ${UTIL}: Performs integration of Open vSwitch with
Docker.
 usage: ${UTIL} COMMAND
 
 Commands:
-  add-port BRIDGE INTERFACE CONTAINER [ADDRESS]
+  add-port BRIDGE [PARENT] [VLAN] INTERFACE CONTAINER [ADDRESS]
                     Adds INTERFACE inside CONTAINER and connects it as
a port
-                    in Open vSwitch BRIDGE. Optionally, sets ADDRESS on
-                    INTERFACE. ADDRESS can include a '/' to represent
network
-                    prefix length. e.g.:
+                    in Open vSwitch BRIDGE. If BRIDGE is a fake bridge,
you
+                    have to specify its PARENT and VLAN. Optionally,
sets
+                    ADDRESS on INTERFACE. ADDRESS can include a '/' to
+                    represent network prefix length. e.g.:
                     ${UTIL} add-port br-int eth1 c474a0e2830e
192.168.1.2/24
   del-port BRIDGE INTERFACE CONTAINER
                     Deletes INTERFACE inside CONTAINER and removes its
-- 
1.9.3





More information about the dev mailing list