ovs-docker currently lets one add the ability to set the
IP address on an OVS interface. Ability to set the default
gateway too can be an useful addition. (orchestrators
who plan to use OVS interfaces can do this from a single
utility instead of multiple utilities)

Requested-by: Marvin Pascual <mar...@pascual.com.ph>
Signed-off-by: Gurucharan Shetty <gshe...@nicira.com>
---
 AUTHORS              |  1 +
 utilities/ovs-docker | 13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index aa445be..ed7e9b7 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -266,6 +266,7 @@ Luca Falavigna          dktrkr...@debian.org
 Luiz Henrique Ozaki     luiz.oz...@gmail.com
 Marco d'Itri            m...@linux.it
 Martin Vizvary          vizv...@ics.muni.cz
+Marvin Pascual          mar...@pascual.com.ph
 Maxime Brun             m.b...@alphalink.fr
 Michael A. Collins      mike.a.coll...@ark-net.org
 Michael Hu              m...@nicira.com
diff --git a/utilities/ovs-docker b/utilities/ovs-docker
index 4a43a15..6b17b87 100755
--- a/utilities/ovs-docker
+++ b/utilities/ovs-docker
@@ -47,6 +47,7 @@ add_port () {
     INTERFACE="$2"
     CONTAINER="$3"
     ADDRESS="$4"
+    GATEWAY="$5"
 
     if [ "$#" -lt 3 ]; then
         usage
@@ -90,6 +91,10 @@ add_port () {
     if [ -n "$ADDRESS" ]; then
         ip netns exec "$PID" ip addr add "$ADDRESS" dev "$INTERFACE"
     fi
+
+    if [ -n "$GATEWAY" ]; then
+        ip netns exec "$PID" ip route add default via "$GATEWAY"
+    fi
 }
 
 del_port () {
@@ -142,12 +147,14 @@ ${UTIL}: Performs integration of Open vSwitch with Docker.
 usage: ${UTIL} COMMAND
 
 Commands:
-  add-port BRIDGE INTERFACE CONTAINER [ADDRESS]
+  add-port BRIDGE INTERFACE CONTAINER [ADDRESS [GATEWAY]]
                     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.:
-                    ${UTIL} add-port br-int eth1 c474a0e2830e 192.168.1.2/24
+                    prefix length. Along with ADDRESS, optionally set the
+                    default gateway for the container. e.g.:
+                    ${UTIL} add-port br-int eth1 c474a0e2830e 192.168.1.2/24 \
+                        192.168.1.1
   del-port BRIDGE INTERFACE CONTAINER
                     Deletes INTERFACE inside CONTAINER and removes its
                     connection to Open vSwitch BRIDGE. e.g.:
-- 
1.9.1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to