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

Merge pull request #3 in CRMC/ifupdown2 from dev to release/cl-stable

* commit '1cf891d101dab5569129c7f9d61d60bc53b67ffd':
  Staging cl3u3 version for merge to stable and release
  ifupdownaddons: iproute2: warn when using keywords and better parsing vlanid in ip link show output
  addons: vrf: error on no master only when ALL interfaces are being brought up
This commit is contained in:
John Berezovik
2016-06-05 09:05:13 -07:00
3 changed files with 68 additions and 41 deletions

View File

@@ -365,7 +365,7 @@ class vrf(moduleBase):
master_exists = False master_exists = False
if master_exists: if master_exists:
rtnetlink_api.rtnl_api.link_set(ifacename, "up") rtnetlink_api.rtnl_api.link_set(ifacename, "up")
else: elif ifupdownflags.flags.ALL:
self.log_error('vrf %s not around, skipping vrf config' self.log_error('vrf %s not around, skipping vrf config'
%(vrfname), ifaceobj) %(vrfname), ifaceobj)
except Exception, e: except Exception, e:

6
debian/changelog vendored
View File

@@ -1,3 +1,9 @@
ifupdown2 (1.1-cl3u3) RELEASED; urgency=medium
* Closes: CM-11214. Interface configuration parsing error when keyword vlan is the interface name.
-- dev-support <dev-support@cumulusnetworks.com> Sun, 05 Jun 2016 08:55:50 -0700
ifupdown2 (1.1-cl3u2) RELEASED; urgency=medium ifupdown2 (1.1-cl3u2) RELEASED; urgency=medium
* Closes: CM-10478. checks for invalid address-virtual attributes * Closes: CM-10478. checks for invalid address-virtual attributes

View File

@@ -40,6 +40,17 @@ class iproute2(utilsBase):
return True return True
return False return False
def _get_vland_id(self, citems, i, warn):
try:
sub = citems[i:]
index = sub.index('id')
int(sub[index + 1])
return sub[index + 1]
except:
if warn:
raise Exception('invalid use of \'vlan\' keyword')
return None
def _link_fill(self, ifacename=None, refresh=False): def _link_fill(self, ifacename=None, refresh=False):
""" fills cache with link information """ fills cache with link information
@@ -47,6 +58,7 @@ class iproute2(utilsBase):
fill cache for all interfaces in the system fill cache for all interfaces in the system
""" """
warn = True
linkout = {} linkout = {}
if iproute2._cache_fill_done and not refresh: return if iproute2._cache_fill_done and not refresh: return
try: try:
@@ -75,46 +87,55 @@ class iproute2(utilsBase):
linkattrs['flags'] = flags linkattrs['flags'] = flags
linkattrs['ifflag'] = 'UP' if 'UP' in flags else 'DOWN' linkattrs['ifflag'] = 'UP' if 'UP' in flags else 'DOWN'
for i in range(0, len(citems)): for i in range(0, len(citems)):
if citems[i] == 'mtu': linkattrs['mtu'] = citems[i+1] try:
elif citems[i] == 'state': linkattrs['state'] = citems[i+1] if citems[i] == 'mtu':
elif citems[i] == 'link/ether': linkattrs['hwaddress'] = citems[i+1] linkattrs['mtu'] = citems[i + 1]
elif citems[i] == 'vlan': elif citems[i] == 'state':
vidx = citems.index('id') linkattrs['state'] = citems[i + 1]
linkattrs['linkinfo'] = {'vlanid' : citems[vidx+1]} elif citems[i] == 'link/ether':
linkattrs['kind'] = 'vlan' linkattrs['hwaddress'] = citems[i + 1]
elif citems[i] == 'dummy': elif citems[i] == 'vlan':
linkattrs['kind'] = 'dummy' vlanid = self._get_vland_id(citems, i, warn)
elif citems[i] == 'vxlan' and citems[i+1] == 'id': if vlanid:
linkattrs['kind'] = 'vxlan' linkattrs['linkinfo'] = {'vlanid': vlanid}
vattrs = {'vxlanid' : citems[i+2], linkattrs['kind'] = 'vlan'
'svcnode' : None, elif citems[i] == 'dummy':
'remote' : [], linkattrs['kind'] = 'dummy'
'ageing' : citems[i+2], elif citems[i] == 'vxlan' and citems[i + 1] == 'id':
'learning': 'on'} linkattrs['kind'] = 'vxlan'
for j in range(i+2, len(citems)): vattrs = {'vxlanid': citems[i + 2],
if citems[j] == 'local': 'svcnode': None,
vattrs['local'] = citems[j+1] 'remote': [],
elif citems[j] == 'remote': 'ageing': citems[i + 2],
vattrs['svcnode'] = citems[j+1] 'learning': 'on'}
elif citems[j] == 'ageing': for j in range(i + 2, len(citems)):
vattrs['ageing'] = citems[j+1] if citems[j] == 'local':
elif citems[j] == 'nolearning': vattrs['local'] = citems[j + 1]
vattrs['learning'] = 'off' elif citems[j] == 'remote':
# get vxlan peer nodes vattrs['svcnode'] = citems[j + 1]
peers = self.get_vxlan_peers(ifname, vattrs['svcnode']) elif citems[j] == 'ageing':
if peers: vattrs['ageing'] = citems[j + 1]
vattrs['remote'] = peers elif citems[j] == 'nolearning':
linkattrs['linkinfo'] = vattrs vattrs['learning'] = 'off'
break # get vxlan peer nodes
elif citems[i] == 'vrf' and citems[i+1] == 'table': peers = self.get_vxlan_peers(ifname, vattrs['svcnode'])
vattrs = {'table' : citems[i+2]} if peers:
linkattrs['linkinfo'] = vattrs vattrs['remote'] = peers
linkattrs['kind'] = 'vrf' linkattrs['linkinfo'] = vattrs
linkCache.vrfs[ifname] = vattrs break
break elif citems[i] == 'vrf' and citems[i + 1] == 'table':
elif citems[i] == 'vrf_slave': vattrs = {'table': citems[i + 2]}
linkattrs['kind'] = 'vrf_slave' linkattrs['linkinfo'] = vattrs
break linkattrs['kind'] = 'vrf'
linkCache.vrfs[ifname] = vattrs
break
elif citems[i] == 'vrf_slave':
linkattrs['kind'] = 'vrf_slave'
break
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)))
warn = False
#linkattrs['alias'] = self.read_file_oneline( #linkattrs['alias'] = self.read_file_oneline(
# '/sys/class/net/%s/ifalias' %ifname) # '/sys/class/net/%s/ifalias' %ifname)
linkout[ifname] = linkattrs linkout[ifname] = linkattrs