2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-29 13:27:59 +00:00

system-common-macros: Enhance ADD_VETH to take mac and gateway.

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>
This commit is contained in:
Gurucharan Shetty 2016-07-11 02:55:59 -07:00
parent 17573cf18f
commit 8ab9b45e85

View File

@ -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'
]
)