Suppress 'Network down' warnings when link_master_slave feature is on

Ticket: CM-4462
Reviewed By:
Testing Done: Tested with interfaces file given in the bug.

The 'network down' msg from the kernel is when the lower device is not
'admin up'. In CM-4462 it is seen when the vlan interface on the bond
is 'admin up' when the bond is still in 'admin down' state.
The bond is also a bridge port so, bond will be 'admin up' when
the bridge it belongs to is brought up.

As link_master_slave feature is on only when all network interfaces
are brought up/down, the states of all interfaces will eventually
converge to 'admin up', so ignoring such transient 'network down' messages.
This commit is contained in:
Roopa Prabhu 2014-12-26 09:39:52 -08:00
parent 1f87118e33
commit 61c4d72447
3 changed files with 19 additions and 3 deletions

View File

@ -236,6 +236,21 @@ class ifupdownMain(ifupdownBase):
else: else:
self._link_master_slave = False self._link_master_slave = False
def link_master_slave_ignore_error(self, errorstr):
# If link master slave flag is set,
# there may be cases where the lowerdev may not be
# up resulting in 'Network is down' error
# This can happen if the lowerdev is a LINK_SLAVE
# of another interface which is not up yet
# example of such a case:
# bringing up a vlan on a bond interface and the bond
# is a LINK_SLAVE of a bridge (in other words the bond is
# part of a bridge) which is not up yet
if self._link_master_slave:
if 'Network is down':
return True
return False
def get_ifaceobjs(self, ifacename): def get_ifaceobjs(self, ifacename):
return self.ifaceobjdict.get(ifacename) return self.ifaceobjdict.get(ifacename)

View File

@ -136,8 +136,9 @@ class ifaceScheduler():
try: try:
handler(ifupdownobj, ifaceobjs[0]) handler(ifupdownobj, ifaceobjs[0])
except Exception, e: except Exception, e:
ifupdownobj.logger.warn('%s: %s' if not ifupdownobj.link_master_slave_ignore_error(str(e)):
%(ifaceobjs[0].name, str(e))) ifupdownobj.logger.warn('%s: %s'
%(ifaceobjs[0].name, str(e)))
pass pass
for ifaceobj in ifaceobjs: for ifaceobj in ifaceobjs:
cls.run_iface_op(ifupdownobj, ifaceobj, op, cls.run_iface_op(ifupdownobj, ifaceobj, op,

View File

@ -368,7 +368,7 @@ class iproute2(utilsBase):
def link_set_hwaddress(self, ifacename, hwaddress, force=False): def link_set_hwaddress(self, ifacename, hwaddress, force=False):
if not force: if not force:
if self._cache_check('link', [ifacename, 'hwaddress'], hwaddress): if self._cache_check('link', [ifacename, 'hwaddress'], hwaddress):
return return
self.link_down(ifacename) self.link_down(ifacename)
cmd = 'link set dev %s address %s' %(ifacename, hwaddress) cmd = 'link set dev %s address %s' %(ifacename, hwaddress)
if self.ipbatch: if self.ipbatch: