mirror of
https://git.proxmox.com/git/mirror_ifupdown2
synced 2025-08-26 01:48:31 +00:00
netlink ip link set up/down may silently fail, adding try/except statements
Ticket: CM-12609 Reviewed By: Roopa, Nikhil G Testing Done: ifupdown2 smoke tests Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
parent
781b55c5b0
commit
707aeb7378
@ -338,6 +338,7 @@ class address(moduleBase):
|
|||||||
self.logger.error('%s: %s' % (ifaceobj.name, str(e)))
|
self.logger.error('%s: %s' % (ifaceobj.name, str(e)))
|
||||||
ifaceobj.set_status(ifaceStatus.ERROR)
|
ifaceobj.set_status(ifaceStatus.ERROR)
|
||||||
|
|
||||||
|
try:
|
||||||
hwaddress = self._get_hwaddress(ifaceobj)
|
hwaddress = self._get_hwaddress(ifaceobj)
|
||||||
if hwaddress:
|
if hwaddress:
|
||||||
running_hwaddress = None
|
running_hwaddress = None
|
||||||
@ -360,12 +361,10 @@ class address(moduleBase):
|
|||||||
for l in ifaceobj.lowerifaces:
|
for l in ifaceobj.lowerifaces:
|
||||||
netlink.link_set_updown(l, "up")
|
netlink.link_set_updown(l, "up")
|
||||||
|
|
||||||
try:
|
|
||||||
# Handle special things on a bridge
|
# Handle special things on a bridge
|
||||||
self._process_bridge(ifaceobj, True)
|
self._process_bridge(ifaceobj, True)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.log_error('%s: %s' %(ifaceobj.name, str(e)), ifaceobj)
|
self.log_error('%s: %s' %(ifaceobj.name, str(e)), ifaceobj)
|
||||||
pass
|
|
||||||
|
|
||||||
if addr_method != "dhcp":
|
if addr_method != "dhcp":
|
||||||
gateways = ifaceobj.get_attr_value('gateway')
|
gateways = ifaceobj.get_attr_value('gateway')
|
||||||
|
@ -1214,7 +1214,10 @@ class bridge(moduleBase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if ifaceobj.addr_method == 'manual':
|
if ifaceobj.addr_method == 'manual':
|
||||||
|
try:
|
||||||
netlink.link_set_updown(ifaceobj.name, "up")
|
netlink.link_set_updown(ifaceobj.name, "up")
|
||||||
|
except Exception as e:
|
||||||
|
self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
|
||||||
if err:
|
if err:
|
||||||
raise Exception(errstr)
|
raise Exception(errstr)
|
||||||
|
|
||||||
@ -1229,7 +1232,7 @@ class bridge(moduleBase):
|
|||||||
map(lambda p: netlink.link_set_updown(p, "down"),
|
map(lambda p: netlink.link_set_updown(p, "down"),
|
||||||
ports)
|
ports)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.log_error(str(e))
|
self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
|
||||||
|
|
||||||
def _query_running_vidinfo_compat(self, ifaceobjrunning, ports):
|
def _query_running_vidinfo_compat(self, ifaceobjrunning, ports):
|
||||||
running_attrs = {}
|
running_attrs = {}
|
||||||
|
@ -146,7 +146,10 @@ class vlan(moduleBase):
|
|||||||
netlink.link_add_vlan(vlanrawdevice, ifaceobj.name, vlanid)
|
netlink.link_add_vlan(vlanrawdevice, ifaceobj.name, vlanid)
|
||||||
self._bridge_vid_add_del(ifaceobj, vlanrawdevice, vlanid)
|
self._bridge_vid_add_del(ifaceobj, vlanrawdevice, vlanid)
|
||||||
if ifaceobj.addr_method == 'manual':
|
if ifaceobj.addr_method == 'manual':
|
||||||
|
try:
|
||||||
netlink.link_set_updown(ifaceobj.name, "up")
|
netlink.link_set_updown(ifaceobj.name, "up")
|
||||||
|
except Exception as e:
|
||||||
|
self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
|
||||||
|
|
||||||
def _down(self, ifaceobj):
|
def _down(self, ifaceobj):
|
||||||
vlanid = self._get_vlan_id(ifaceobj)
|
vlanid = self._get_vlan_id(ifaceobj)
|
||||||
|
@ -129,7 +129,11 @@ class ifupdownMain(ifupdownBase):
|
|||||||
return
|
return
|
||||||
if not self.link_exists(ifaceobj.name):
|
if not self.link_exists(ifaceobj.name):
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
self.link_up(ifaceobj.name)
|
self.link_up(ifaceobj.name)
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error('%s: %s' % (ifaceobj.name, str(e)))
|
||||||
|
ifaceobj.set_status(ifaceStatus.ERROR)
|
||||||
|
|
||||||
def run_down(self, ifaceobj):
|
def run_down(self, ifaceobj):
|
||||||
if ((ifaceobj.link_kind & ifaceLinkKind.VRF) or
|
if ((ifaceobj.link_kind & ifaceLinkKind.VRF) or
|
||||||
@ -153,7 +157,11 @@ class ifupdownMain(ifupdownBase):
|
|||||||
return
|
return
|
||||||
if not self.link_exists(ifaceobj.name):
|
if not self.link_exists(ifaceobj.name):
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
self.link_down(ifaceobj.name)
|
self.link_down(ifaceobj.name)
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error('%s: %s' % (ifaceobj.name, str(e)))
|
||||||
|
ifaceobj.set_status(ifaceStatus.ERROR)
|
||||||
|
|
||||||
# ifupdown object interface operation handlers
|
# ifupdown object interface operation handlers
|
||||||
ops_handlers = OrderedDict([('up', run_up),
|
ops_handlers = OrderedDict([('up', run_up),
|
||||||
|
Loading…
Reference in New Issue
Block a user