mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Check for zero address on bridge ports before enslaving it to the bridge
Ticket: CM-4859, CM-4382 Reviewed By: Testing Done: Tested with config which included bond bridge ports with zero address on the bond. The bridge driver rejects the port add with -EINVAL. A bond with no slaves is one usecase where the bond interface has a zero hw address and is rejected by the bridge. EINVAL currently is very confusing. This patch checks for a valid ether add before enslaving the port to the bridge.
This commit is contained in:
@ -314,6 +314,12 @@ class bridge(moduleBase):
|
||||
%(ifaceobj.name, bridgeport))
|
||||
err += 1
|
||||
continue
|
||||
hwaddress = self.ipcmd.link_get_hwaddress(bridgeport)
|
||||
if not self._valid_ethaddr(hwaddress):
|
||||
self.log_warn('%s: skipping port %s, ' %(ifaceobj.name,
|
||||
bridgeport) + 'invalid ether addr %s'
|
||||
%hwaddress)
|
||||
continue
|
||||
self.ipcmd.link_set(bridgeport, 'master', ifaceobj.name)
|
||||
self.ipcmd.addr_flush(bridgeport)
|
||||
except Exception, e:
|
||||
|
@ -231,11 +231,10 @@ class ifenslave(moduleBase):
|
||||
attrval = ifaceobj.get_attr_value_first('clag-id')
|
||||
clag_id = attrval if attrval else '0'
|
||||
for slave in Set(slaves).difference(Set(runningslaves)):
|
||||
if (not self.PERFMODE and
|
||||
not self.ipcmd.link_exists(slave)):
|
||||
self.log_warn('%s: skipping slave %s, does not exist'
|
||||
%(ifaceobj.name, slave))
|
||||
continue
|
||||
if not self.PERFMODE and not self.ipcmd.link_exists(slave):
|
||||
self.log_warn('%s: skipping slave %s, does not exist'
|
||||
%(ifaceobj.name, slave))
|
||||
continue
|
||||
link_up = False
|
||||
if self.ipcmd.is_link_up(slave):
|
||||
rtnetlink_api.rtnl_api.link_set(slave, "down")
|
||||
|
@ -515,7 +515,13 @@ class iproute2(utilsBase):
|
||||
return self._cache_get('link', [ifacename, 'mtu'])
|
||||
|
||||
def link_get_hwaddress(self, ifacename):
|
||||
return self._cache_get('link', [ifacename, 'hwaddress'])
|
||||
address = self._cache_get('link', [ifacename, 'hwaddress'])
|
||||
# newly created logical interface addresses dont end up in the cache
|
||||
# read hwaddress from sysfs file for these interfaces
|
||||
if not address:
|
||||
address = self.read_file_oneline('/sys/class/net/%s/address'
|
||||
%ifacename)
|
||||
return address
|
||||
|
||||
def link_create(self, ifacename, type, link=None):
|
||||
if self.link_exists(ifacename):
|
||||
|
@ -355,3 +355,9 @@ class moduleBase(object):
|
||||
%(self._resv_vlan_range[0], self._resv_vlan_range[1]))
|
||||
return True
|
||||
return False
|
||||
|
||||
def _valid_ethaddr(self, ethaddr):
|
||||
""" Check if address is 00:00:00:00:00:00 """
|
||||
if not ethaddr or re.match('00:00:00:00:00:00', ethaddr):
|
||||
return False
|
||||
return True
|
||||
|
Reference in New Issue
Block a user