When creating a VXLAN interface, a device is mandatory
"IPWrapper.add_vxlan" method must have "dev" parameter as possitional
argument. A VXLAN interface must be always created on top of an existing
network device:
https://www.kernel.org/doc/Documentation/networking/vxlan.txt
Closes-Bug: #1954316
Change-Id: Ia082f8531ffcc1599206124774599dcdb500274a
(cherry picked from commit 16a793af19
)
This commit is contained in:
parent
4434dc11d9
commit
1dc99e93fe
@ -278,13 +278,12 @@ class IPWrapper(SubProcessBase):
|
||||
vlan_id=vlan_id)
|
||||
return IPDevice(name, namespace=self.namespace)
|
||||
|
||||
def add_vxlan(self, name, vni, group=None, dev=None, ttl=None, tos=None,
|
||||
def add_vxlan(self, name, vni, dev, group=None, ttl=None, tos=None,
|
||||
local=None, srcport=None, dstport=None, proxy=False):
|
||||
kwargs = {'vxlan_id': vni}
|
||||
kwargs = {'vxlan_id': vni,
|
||||
'physical_interface': dev}
|
||||
if group:
|
||||
kwargs['vxlan_group'] = group
|
||||
if dev:
|
||||
kwargs['physical_interface'] = dev
|
||||
if ttl:
|
||||
kwargs['vxlan_ttl'] = ttl
|
||||
if tos:
|
||||
|
@ -77,8 +77,10 @@ def ovs_geneve_supported(from_ip='192.0.2.3', to_ip='192.0.2.4'):
|
||||
|
||||
def iproute2_vxlan_supported():
|
||||
ip = ip_lib.IPWrapper()
|
||||
name_dummy = common_utils.get_rand_device_name(prefix='vxlantest-')
|
||||
ip.add_dummy(name_dummy)
|
||||
name = common_utils.get_rand_device_name(prefix='vxlantest-')
|
||||
port = ip.add_vxlan(name, 3000)
|
||||
port = ip.add_vxlan(name, 3000, name_dummy)
|
||||
ip.del_veth(name)
|
||||
return name == port.name
|
||||
|
||||
|
@ -328,8 +328,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
|
||||
"VNI %(segmentation_id)s",
|
||||
{'interface': interface,
|
||||
'segmentation_id': segmentation_id})
|
||||
args = {'dev': self.local_int,
|
||||
'srcport': (cfg.CONF.VXLAN.udp_srcport_min,
|
||||
args = {'srcport': (cfg.CONF.VXLAN.udp_srcport_min,
|
||||
cfg.CONF.VXLAN.udp_srcport_max),
|
||||
'dstport': cfg.CONF.VXLAN.udp_dstport,
|
||||
'ttl': cfg.CONF.VXLAN.ttl}
|
||||
@ -355,7 +354,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
|
||||
|
||||
try:
|
||||
int_vxlan = self.ip.add_vxlan(interface, segmentation_id,
|
||||
**args)
|
||||
self.local_int, **args)
|
||||
except RuntimeError:
|
||||
with excutils.save_and_reraise_exception() as ctxt:
|
||||
# perform this check after an attempt rather than before
|
||||
|
@ -154,7 +154,7 @@ class FdbInterfaceTestCase(testscenarios.WithScenarios, base.BaseSudoTestCase):
|
||||
vni = random.randint(1, 2**24 - 1)
|
||||
ip_wrapper = ip_lib.IPWrapper(self.namespace)
|
||||
ip_wrapper.add_dummy(self.device)
|
||||
ip_wrapper.add_vxlan(self.device_vxlan, vni, dev=self.device)
|
||||
ip_wrapper.add_vxlan(self.device_vxlan, vni, self.device)
|
||||
ip_device = ip_lib.IPDevice(self.device, self.namespace)
|
||||
ip_device.link.set_up()
|
||||
ip_device.addr.add(self.ip)
|
||||
|
@ -238,9 +238,10 @@ class IpLibTestCase(IpLibTestFramework):
|
||||
attr = self.generate_device_details()
|
||||
ip = ip_lib.IPWrapper(namespace=attr.namespace)
|
||||
ip.netns.add(attr.namespace)
|
||||
ip.add_dummy('dummy_device')
|
||||
self.addCleanup(ip.netns.delete, attr.namespace)
|
||||
self.assertFalse(ip_lib.vxlan_in_use(9999, namespace=attr.namespace))
|
||||
device = ip.add_vxlan(attr.name, 9999)
|
||||
device = ip.add_vxlan(attr.name, 9999, 'dummy_device')
|
||||
self.addCleanup(self._safe_delete_device, device)
|
||||
self.assertTrue(ip_lib.vxlan_in_use(9999, namespace=attr.namespace))
|
||||
device.link.delete()
|
||||
|
@ -209,7 +209,7 @@ class TcFiltersTestCase(functional_base.BaseSudoTestCase):
|
||||
if i == 0:
|
||||
ip_wrapper.add_veth(self.device[0], self.device[1], self.ns[1])
|
||||
ip_wrapper.add_vxlan(self.device_vxlan[i], self.vxlan_id,
|
||||
dev=self.device[i])
|
||||
self.device[i])
|
||||
ip_device = ip_lib.IPDevice(self.device[i], ns)
|
||||
ip_device.link.set_up()
|
||||
ip_device.addr.add(self.ip[i])
|
||||
|
@ -382,9 +382,9 @@ class TestIpWrapper(base.BaseTestCase):
|
||||
'vxlan_proxy': True,
|
||||
'vxlan_port_range': ('1', '2')}
|
||||
|
||||
retval = ip_lib.IPWrapper().add_vxlan('vxlan0', 'vni0',
|
||||
retval = ip_lib.IPWrapper().add_vxlan('vxlan0', 'vni0', 'dev0',
|
||||
group='group0',
|
||||
dev='dev0', ttl='ttl0',
|
||||
ttl='ttl0',
|
||||
tos='tos0',
|
||||
local='local0', proxy=True,
|
||||
srcport=(1, 2))
|
||||
@ -434,9 +434,9 @@ class TestIpWrapper(base.BaseTestCase):
|
||||
'vxlan_port_range': ('1', '2'),
|
||||
'vxlan_port': 4789}
|
||||
|
||||
retval = ip_lib.IPWrapper().add_vxlan('vxlan0', 'vni0',
|
||||
retval = ip_lib.IPWrapper().add_vxlan('vxlan0', 'vni0', 'dev0',
|
||||
group='group0',
|
||||
dev='dev0', ttl='ttl0',
|
||||
ttl='ttl0',
|
||||
tos='tos0',
|
||||
local='local0', proxy=True,
|
||||
srcport=(1, 2),
|
||||
|
@ -396,22 +396,22 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
||||
retval = self.lbm.ensure_vxlan(seg_id, mtu=1450)
|
||||
self.assertEqual("vxlan-" + seg_id, retval)
|
||||
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
||||
self.lbm.local_int,
|
||||
group="224.0.0.1",
|
||||
srcport=(0, 0),
|
||||
dstport=None,
|
||||
ttl=None,
|
||||
dev=self.lbm.local_int)
|
||||
ttl=None)
|
||||
dv6_fn.assert_called_once_with()
|
||||
set_mtu_fn.assert_called_once_with(1450)
|
||||
cfg.CONF.set_override('l2_population', 'True', 'VXLAN')
|
||||
self.assertEqual("vxlan-" + seg_id,
|
||||
self.lbm.ensure_vxlan(seg_id))
|
||||
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
||||
self.lbm.local_int,
|
||||
group="224.0.0.1",
|
||||
srcport=(0, 0),
|
||||
dstport=None,
|
||||
ttl=None,
|
||||
dev=self.lbm.local_int,
|
||||
local=self.lbm.local_ip,
|
||||
proxy=expected_proxy)
|
||||
|
||||
@ -432,12 +432,12 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
||||
self.assertEqual("vxlan-" + seg_id,
|
||||
self.lbm.ensure_vxlan(seg_id))
|
||||
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
||||
self.lbm.local_int,
|
||||
group="224.0.0.1",
|
||||
srcport=(0, 0),
|
||||
dstport=None,
|
||||
ttl=None,
|
||||
tos='inherit',
|
||||
dev=self.lbm.local_int)
|
||||
tos='inherit')
|
||||
dv6_fn.assert_called_once_with()
|
||||
|
||||
def test_ensure_vxlan_mtu_too_big(self):
|
||||
@ -463,11 +463,11 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
||||
self.assertFalse(
|
||||
self.lbm.ensure_vxlan(seg_id, mtu=mtu))
|
||||
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
||||
self.lbm.local_int,
|
||||
group="224.0.0.1",
|
||||
srcport=(0, 0),
|
||||
dstport=None,
|
||||
ttl=None,
|
||||
dev=self.lbm.local_int)
|
||||
ttl=None)
|
||||
delete_dev.assert_called_once_with()
|
||||
dv6_fn.assert_not_called()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user