From 61c4d7244735cb490229d65a70ab53264d9346d9 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Fri, 26 Dec 2014 09:39:52 -0800 Subject: [PATCH] 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. --- ifupdown/ifupdownmain.py | 15 +++++++++++++++ ifupdown/scheduler.py | 5 +++-- ifupdownaddons/iproute2.py | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ifupdown/ifupdownmain.py b/ifupdown/ifupdownmain.py index 416cfdb..3d01704 100644 --- a/ifupdown/ifupdownmain.py +++ b/ifupdown/ifupdownmain.py @@ -236,6 +236,21 @@ class ifupdownMain(ifupdownBase): else: 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): return self.ifaceobjdict.get(ifacename) diff --git a/ifupdown/scheduler.py b/ifupdown/scheduler.py index 794c552..4b4bb57 100644 --- a/ifupdown/scheduler.py +++ b/ifupdown/scheduler.py @@ -136,8 +136,9 @@ class ifaceScheduler(): try: handler(ifupdownobj, ifaceobjs[0]) except Exception, e: - ifupdownobj.logger.warn('%s: %s' - %(ifaceobjs[0].name, str(e))) + if not ifupdownobj.link_master_slave_ignore_error(str(e)): + ifupdownobj.logger.warn('%s: %s' + %(ifaceobjs[0].name, str(e))) pass for ifaceobj in ifaceobjs: cls.run_iface_op(ifupdownobj, ifaceobj, op, diff --git a/ifupdownaddons/iproute2.py b/ifupdownaddons/iproute2.py index b2111a1..6d6f0db 100644 --- a/ifupdownaddons/iproute2.py +++ b/ifupdownaddons/iproute2.py @@ -368,7 +368,7 @@ class iproute2(utilsBase): def link_set_hwaddress(self, ifacename, hwaddress, force=False): if not force: if self._cache_check('link', [ifacename, 'hwaddress'], hwaddress): - return + return self.link_down(ifacename) cmd = 'link set dev %s address %s' %(ifacename, hwaddress) if self.ipbatch: