ovs-docker: Ability to set the default gateway.
authorGurucharan Shetty <gshetty@nicira.com>
Fri, 12 Dec 2014 08:32:50 +0000 (00:32 -0800)
committerGurucharan Shetty <gshetty@nicira.com>
Mon, 15 Dec 2014 17:49:10 +0000 (09:49 -0800)
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 <marvin@pascual.com.ph>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Thomas Graf <tgraf@noironetworks.com>
AUTHORS
utilities/ovs-docker

diff --git a/AUTHORS b/AUTHORS
index aa445be..ed7e9b7 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -266,6 +266,7 @@ Luca Falavigna          dktrkranz@debian.org
 Luiz Henrique Ozaki     luiz.ozaki@gmail.com
 Marco d'Itri            md@Linux.IT
 Martin Vizvary          vizvary@ics.muni.cz
+Marvin Pascual          marvin@pascual.com.ph
 Maxime Brun             m.brun@alphalink.fr
 Michael A. Collins      mike.a.collins@ark-net.org
 Michael Hu              mhu@nicira.com
index 4a43a15..6b17b87 100755 (executable)
@@ -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.: