mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Merge pull request #19 from BarbarossaTM/vxlan-physdev
Add support for setting phys-dev for VXLAN interfaces and fix check for vxlan-svcnodeip option.
This commit is contained in:
@@ -32,6 +32,9 @@ class vxlan(moduleBase):
|
|||||||
{'help' : 'vxlan remote ip',
|
{'help' : 'vxlan remote ip',
|
||||||
'validvals' : ['<ipv4>', '<ipv6>'],
|
'validvals' : ['<ipv4>', '<ipv6>'],
|
||||||
'example': ['vxlan-remoteip 172.16.22.127']},
|
'example': ['vxlan-remoteip 172.16.22.127']},
|
||||||
|
'vxlan-physdev' :
|
||||||
|
{'help' : 'vxlan physical device',
|
||||||
|
'example': ['vxlan-physdev eth1']},
|
||||||
'vxlan-learning' :
|
'vxlan-learning' :
|
||||||
{'help' : 'vxlan learning yes/no',
|
{'help' : 'vxlan learning yes/no',
|
||||||
'validvals' : ['yes', 'no', 'on', 'off'],
|
'validvals' : ['yes', 'no', 'on', 'off'],
|
||||||
@@ -59,6 +62,14 @@ class vxlan(moduleBase):
|
|||||||
self.log_warn('%s: multiple clagd-vxlan-anycast-ip lines, using first one'
|
self.log_warn('%s: multiple clagd-vxlan-anycast-ip lines, using first one'
|
||||||
% (ifaceobj.name,))
|
% (ifaceobj.name,))
|
||||||
vxlan._clagd_vxlan_anycast_ip = clagd_vxlan_list[0]
|
vxlan._clagd_vxlan_anycast_ip = clagd_vxlan_list[0]
|
||||||
|
|
||||||
|
|
||||||
|
# If we should use a specific underlay device for the VXLAN
|
||||||
|
# tunnel make sure this device is set up before the VXLAN iface.
|
||||||
|
physdev = ifaceobj.get_attr_value_first('vxlan-physdev')
|
||||||
|
if physdev:
|
||||||
|
return [ physdev ]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _is_vxlan_device(self, ifaceobj):
|
def _is_vxlan_device(self, ifaceobj):
|
||||||
@@ -72,6 +83,7 @@ class vxlan(moduleBase):
|
|||||||
anycastip = self._clagd_vxlan_anycast_ip
|
anycastip = self._clagd_vxlan_anycast_ip
|
||||||
group = ifaceobj.get_attr_value_first('vxlan-svcnodeip')
|
group = ifaceobj.get_attr_value_first('vxlan-svcnodeip')
|
||||||
local = ifaceobj.get_attr_value_first('vxlan-local-tunnelip')
|
local = ifaceobj.get_attr_value_first('vxlan-local-tunnelip')
|
||||||
|
physdev = ifaceobj.get_attr_value_first('vxlan-physdev')
|
||||||
ageing = ifaceobj.get_attr_value_first('vxlan-ageing')
|
ageing = ifaceobj.get_attr_value_first('vxlan-ageing')
|
||||||
learning = utils.get_onoff_bool(ifaceobj.get_attr_value_first('vxlan-learning'))
|
learning = utils.get_onoff_bool(ifaceobj.get_attr_value_first('vxlan-learning'))
|
||||||
|
|
||||||
@@ -89,7 +101,8 @@ class vxlan(moduleBase):
|
|||||||
local=local,
|
local=local,
|
||||||
learning=learning,
|
learning=learning,
|
||||||
ageing=ageing,
|
ageing=ageing,
|
||||||
group=group)
|
group=group,
|
||||||
|
physdev=physdev)
|
||||||
|
|
||||||
remoteips = ifaceobj.get_attr_value('vxlan-remoteip')
|
remoteips = ifaceobj.get_attr_value('vxlan-remoteip')
|
||||||
if not systemUtils.is_service_running(None, '/var/run/vxrd.pid'):
|
if not systemUtils.is_service_running(None, '/var/run/vxrd.pid'):
|
||||||
@@ -207,6 +220,11 @@ class vxlan(moduleBase):
|
|||||||
self._query_check_n_update(ifaceobj, ifaceobjcurr, 'vxlan-ageing',
|
self._query_check_n_update(ifaceobj, ifaceobjcurr, 'vxlan-ageing',
|
||||||
ageing, vxlanattrs.get('ageing'))
|
ageing, vxlanattrs.get('ageing'))
|
||||||
|
|
||||||
|
physdev = ifaceobj.get_attr_value_first('vxlan-physdev')
|
||||||
|
if physdev:
|
||||||
|
self._query_check_n_update(ifaceobj, ifaceobjcurr, 'vxlan-physdev',
|
||||||
|
physdev, vxlanattrs.get('physdev'))
|
||||||
|
|
||||||
def _query_running(self, ifaceobjrunning):
|
def _query_running(self, ifaceobjrunning):
|
||||||
vxlanattrs = self.ipcmd.get_vxlandev_attrs(ifaceobjrunning.name)
|
vxlanattrs = self.ipcmd.get_vxlandev_attrs(ifaceobjrunning.name)
|
||||||
if not vxlanattrs:
|
if not vxlanattrs:
|
||||||
|
@@ -92,24 +92,30 @@ class Netlink(utilsBase):
|
|||||||
% (ifacename, vlanid, str(e)))
|
% (ifacename, vlanid, str(e)))
|
||||||
|
|
||||||
def link_add_vxlan(self, ifacename, vxlanid, local=None, dstport=VXLAN_UDP_PORT,
|
def link_add_vxlan(self, ifacename, vxlanid, local=None, dstport=VXLAN_UDP_PORT,
|
||||||
group=None, learning='on', ageing=None):
|
group=None, learning='on', ageing=None, physdev=None):
|
||||||
cmd = 'ip link add %s type vxlan id %s dstport %s' % (ifacename,
|
cmd = 'ip link add %s type vxlan id %s dstport %s' % (ifacename,
|
||||||
vxlanid,
|
vxlanid,
|
||||||
dstport)
|
dstport)
|
||||||
|
|
||||||
|
|
||||||
cmd += ' local %s' % local if local else ''
|
cmd += ' local %s' % local if local else ''
|
||||||
cmd += ' ageing %s' % ageing if ageing else ''
|
cmd += ' ageing %s' % ageing if ageing else ''
|
||||||
cmd += ' remote %s' % group if group else ' noremote'
|
cmd += ' remote %s' % group if group else ' noremote'
|
||||||
cmd += ' nolearning' if learning == 'off' else ''
|
cmd += ' nolearning' if learning == 'off' else ''
|
||||||
|
cmd += ' dev %s' % physdev if physdev else ''
|
||||||
self.logger.info('%s: netlink: %s' % (ifacename, cmd))
|
self.logger.info('%s: netlink: %s' % (ifacename, cmd))
|
||||||
if ifupdownflags.flags.DRYRUN: return
|
if ifupdownflags.flags.DRYRUN: return
|
||||||
try:
|
try:
|
||||||
|
if physdev:
|
||||||
|
physdev = self.get_iface_index (physdev)
|
||||||
return self._nlmanager_api.link_add_vxlan(ifacename,
|
return self._nlmanager_api.link_add_vxlan(ifacename,
|
||||||
vxlanid,
|
vxlanid,
|
||||||
dstport=dstport,
|
dstport=dstport,
|
||||||
local=local,
|
local=local,
|
||||||
group=group,
|
group=group,
|
||||||
learning=learning,
|
learning=learning,
|
||||||
ageing=ageing)
|
ageing=ageing,
|
||||||
|
physdev=physdev)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception('netlink: %s: cannot create vxlan %s: %s'
|
raise Exception('netlink: %s: cannot create vxlan %s: %s'
|
||||||
% (ifacename, vxlanid, str(e)))
|
% (ifacename, vxlanid, str(e)))
|
||||||
|
@@ -132,18 +132,21 @@ class iproute2(utilsBase):
|
|||||||
linkattrs['kind'] = 'vxlan'
|
linkattrs['kind'] = 'vxlan'
|
||||||
vattrs = {'vxlanid': citems[i + 2],
|
vattrs = {'vxlanid': citems[i + 2],
|
||||||
'svcnode': None,
|
'svcnode': None,
|
||||||
|
'physdev': None,
|
||||||
'remote': [],
|
'remote': [],
|
||||||
'ageing': citems[i + 2],
|
'ageing': citems[i + 2],
|
||||||
'learning': 'on'}
|
'learning': 'on'}
|
||||||
for j in range(i + 2, len(citems)):
|
for j in range(i + 2, len(citems)):
|
||||||
if citems[j] == 'local':
|
if citems[j] == 'local':
|
||||||
vattrs['local'] = citems[j + 1]
|
vattrs['local'] = citems[j + 1]
|
||||||
elif citems[j] == 'remote':
|
elif citems[j] == 'group':
|
||||||
vattrs['svcnode'] = citems[j + 1]
|
vattrs['svcnode'] = citems[j + 1]
|
||||||
elif citems[j] == 'ageing':
|
elif citems[j] == 'ageing':
|
||||||
vattrs['ageing'] = citems[j + 1]
|
vattrs['ageing'] = citems[j + 1]
|
||||||
elif citems[j] == 'nolearning':
|
elif citems[j] == 'nolearning':
|
||||||
vattrs['learning'] = 'off'
|
vattrs['learning'] = 'off'
|
||||||
|
elif citems[j] == 'dev':
|
||||||
|
vattrs['physdev'] = citems[j + 1]
|
||||||
# get vxlan peer nodes if provisioned by user and not by vxrd
|
# get vxlan peer nodes if provisioned by user and not by vxrd
|
||||||
if not vxrd_running:
|
if not vxrd_running:
|
||||||
peers = self.get_vxlan_peers(ifname, vattrs['svcnode'])
|
peers = self.get_vxlan_peers(ifname, vattrs['svcnode'])
|
||||||
|
@@ -787,7 +787,7 @@ class NetlinkManager(object):
|
|||||||
return self.tx_nlpacket_get_response(nbr)
|
return self.tx_nlpacket_get_response(nbr)
|
||||||
|
|
||||||
def link_add_vxlan(self, ifname, vxlanid, dstport=None, local=None,
|
def link_add_vxlan(self, ifname, vxlanid, dstport=None, local=None,
|
||||||
group=None, learning='on', ageing=None):
|
group=None, learning='on', ageing=None, physdev=None):
|
||||||
|
|
||||||
debug = RTM_NEWLINK in self.debug
|
debug = RTM_NEWLINK in self.debug
|
||||||
|
|
||||||
@@ -798,6 +798,8 @@ class NetlinkManager(object):
|
|||||||
info_data[Link.IFLA_VXLAN_LOCAL] = local
|
info_data[Link.IFLA_VXLAN_LOCAL] = local
|
||||||
if group:
|
if group:
|
||||||
info_data[Link.IFLA_VXLAN_GROUP] = group
|
info_data[Link.IFLA_VXLAN_GROUP] = group
|
||||||
|
if physdev:
|
||||||
|
info_data[Link.IFLA_VXLAN_LINK] = int (physdev)
|
||||||
|
|
||||||
learning = 0 if learning == 'off' else 1
|
learning = 0 if learning == 'off' else 1
|
||||||
info_data[Link.IFLA_VXLAN_LEARNING] = learning
|
info_data[Link.IFLA_VXLAN_LEARNING] = learning
|
||||||
|
Reference in New Issue
Block a user