diff mbox

[ovs-dev,1/4] system-common-macros: Enhance ADD_VETH to take mac and gateway.

Message ID 1468305329-28456-1-git-send-email-guru@ovn.org
State Superseded
Headers show

Commit Message

Gurucharan Shetty July 12, 2016, 6:35 a.m. UTC
It is useful to set the mac address and gateway while using ADD_VETH
to connect a namespace to a OVN logical topology. Upcoming commits
use this enhancement.

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
---
 tests/system-common-macros.at | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Joe Stringer July 13, 2016, 12:14 a.m. UTC | #1
On 11 July 2016 at 23:35, Gurucharan Shetty <guru@ovn.org> wrote:
> It is useful to set the mac address and gateway while using ADD_VETH
> to connect a namespace to a OVN logical topology. Upcoming commits
> use this enhancement.
>
> Signed-off-by: Gurucharan Shetty <guru@ovn.org>

Acked-by: Joe Stringer <joe@ovn.org>
diff mbox

Patch

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 1e3219c..27fceed 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -56,7 +56,7 @@  m4_define([ADD_INT],
     ]
 )
 
-# ADD_VETH([port], [namespace], [ovs-br], [ip_addr])
+# ADD_VETH([port], [namespace], [ovs-br], [ip_addr] [mac_addr [gateway]])
 #
 # Add a pair of veth ports. 'port' will be added to name space 'namespace',
 # and "ovs-'port'" will be added to ovs bridge 'ovs-br'.
@@ -64,6 +64,9 @@  m4_define([ADD_INT],
 # The 'port' in 'namespace' will be brought up with static IP address
 # with 'ip_addr' in CIDR notation.
 #
+# Optionally, one can specify the 'mac_addr' for 'port' and the default
+# 'gateway'.
+#
 # The existing 'port' or 'ovs-port' will be removed before new ones are added.
 #
 m4_define([ADD_VETH],
@@ -74,6 +77,12 @@  m4_define([ADD_VETH],
       AT_CHECK([ovs-vsctl add-port $3 ovs-$1])
       NS_CHECK_EXEC([$2], [ip addr add $4 dev $1])
       NS_CHECK_EXEC([$2], [ip link set dev $1 up])
+      if test -n "$5"; then
+        NS_CHECK_EXEC([$2], [ip link set dev $1 address $5])
+      fi
+      if test -n "$6"; then
+        NS_CHECK_EXEC([$2], [ip route add default via $6])
+      fi
       on_exit 'ip link del ovs-$1'
     ]
 )