1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

addons: addressvirtual: enslave macvlans on vrf slaves to the vrf master

Ticket: CM-11803
Reviewed By: dsa, scotte, wkok, nikhil, julien
Testing Done: tested config of address-virtual lines on vrf slaves

This patch does the following:
- addressvirtual: enslaves macvlans created on vrf slaves
to the vrf master
- vrf: when looking for stale slaves on vrf master, skip
macvlan devices. This code does basic checking right now
and can be improved to include more cases.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
This commit is contained in:
Roopa Prabhu
2016-07-17 22:50:26 -07:00
parent 1efda6c232
commit 1b284018d5
3 changed files with 33 additions and 2 deletions

View File

@@ -125,6 +125,11 @@ class addressvirtual(moduleBase):
%str(e))
pass
def _handle_vrf_slaves(self, macvlan_ifacename, ifaceobj):
vrfname = self.ipcmd.link_get_master(ifaceobj.name)
if vrfname:
self.ipcmd.link_set(macvlan_ifacename, 'master', vrfname)
def _get_macs_from_old_config(self, ifaceobj=None):
""" This method returns a list of the mac addresses
in the address-virtual attribute for the bridge. """
@@ -196,6 +201,10 @@ class addressvirtual(moduleBase):
if lower_iface_mtu and lower_iface_mtu != self.ipcmd.link_get_mtu(macvlan_ifacename):
self.ipcmd.link_set_mtu(macvlan_ifacename, lower_iface_mtu)
# handle vrf slaves
if (ifaceobj.link_privflags & ifaceLinkPrivFlags.VRF_SLAVE):
self._handle_vrf_slaves(macvlan_ifacename, ifaceobj)
# Disable IPv6 duplicate address detection on VRR interfaces
for key, sysval in { 'accept_dad' : '0', 'dad_transmits' : '0' }.iteritems():
syskey = 'net.ipv6.conf.%s.%s' % (macvlan_ifacename, key)
@@ -283,8 +292,8 @@ class addressvirtual(moduleBase):
self._remove_address_config(ifaceobj, address_virtual_list)
return
if ifaceobj.upperifaces and \
not ifaceobj.link_privflags & ifaceLinkPrivFlags.VRF_SLAVE:
if (ifaceobj.upperifaces and
not ifaceobj.link_privflags & ifaceLinkPrivFlags.VRF_SLAVE):
self.log_error('%s: invalid placement of address-virtual lines (must be configured under an interface with no upper interfaces or parent interfaces)'
% (ifaceobj.name), ifaceobj)
return

View File

@@ -483,6 +483,23 @@ class vrf(moduleBase):
vrf_dev_name)
utils.exec_command(rule_cmd)
def _is_address_virtual_slaves(self, vrfobj, config_vrfslaves,
vrfslave):
# Address virtual lines on a vrf slave will create
# macvlan devices on the vrf slave and enslave them
# to the vrf master. This function checks if the
# vrf slave is such a macvlan interface.
# XXX: additional possible checks that can be done here
# are:
# - check if it is also a macvlan device of the
# format <vrf_slave>-v<int> created by the
# address virtual module
vrfslave_lowers = self.ipcmd.link_get_lowers(vrfslave)
if vrfslave_lowers:
if vrfslave_lowers[0] in config_vrfslaves:
return True
return False
def _add_vrf_slaves(self, ifaceobj, ifaceobj_getfunc=None):
running_slaves = self.ipcmd.link_get_lowers(ifaceobj.name)
config_slaves = ifaceobj.lowerifaces
@@ -510,6 +527,9 @@ class vrf(moduleBase):
if del_slaves:
for s in del_slaves:
try:
if self._is_address_virtual_slaves(ifaceobj,
config_slaves, s):
continue
sobj = None
if ifaceobj_getfunc:
sobj = ifaceobj_getfunc(s)

View File

@@ -133,6 +133,8 @@ class iproute2(utilsBase):
elif citems[i] == 'vrf_slave':
linkattrs['kind'] = 'vrf_slave'
break
elif citems[i] == 'macvlan' and citems[i + 1] == 'mode':
linkattrs['kind'] = 'macvlan'
except Exception as e:
if warn:
self.logger.debug('%s: parsing error: id, mtu, state, link/ether, vlan, dummy, vxlan, local, remote, ageing, nolearning, vrf, table, vrf_slave are reserved keywords: %s' % (ifname, str(e)))