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 Conflicts: neutron/tests/functional/agent/linux/test_tc_lib.py Closes-Bug: #1954316 Change-Id: Ia082f8531ffcc1599206124774599dcdb500274a (cherry picked from commit16a793af19
) (cherry picked from commit1dc99e93fe
)
This commit is contained in:
parent
3810151ecc
commit
3a50b3e124
@ -276,9 +276,10 @@ class IPWrapper(SubProcessBase):
|
|||||||
vlan_id=vlan_id)
|
vlan_id=vlan_id)
|
||||||
return IPDevice(name, namespace=self.namespace)
|
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):
|
local=None, srcport=None, dstport=None, proxy=False):
|
||||||
kwargs = {'vxlan_id': vni}
|
kwargs = {'vxlan_id': vni,
|
||||||
|
'physical_interface': dev}
|
||||||
if group:
|
if group:
|
||||||
try:
|
try:
|
||||||
ip_version = common_utils.get_ip_version(group)
|
ip_version = common_utils.get_ip_version(group)
|
||||||
@ -289,8 +290,6 @@ class IPWrapper(SubProcessBase):
|
|||||||
except netaddr.core.AddrFormatError:
|
except netaddr.core.AddrFormatError:
|
||||||
err_msg = _("Invalid group address: %s") % group
|
err_msg = _("Invalid group address: %s") % group
|
||||||
raise exceptions.InvalidInput(error_message=err_msg)
|
raise exceptions.InvalidInput(error_message=err_msg)
|
||||||
if dev:
|
|
||||||
kwargs['physical_interface'] = dev
|
|
||||||
if ttl:
|
if ttl:
|
||||||
kwargs['vxlan_ttl'] = ttl
|
kwargs['vxlan_ttl'] = ttl
|
||||||
if tos:
|
if tos:
|
||||||
|
@ -74,8 +74,10 @@ def ovs_geneve_supported(from_ip='192.0.2.3', to_ip='192.0.2.4'):
|
|||||||
|
|
||||||
def iproute2_vxlan_supported():
|
def iproute2_vxlan_supported():
|
||||||
ip = ip_lib.IPWrapper()
|
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-')
|
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)
|
ip.del_veth(name)
|
||||||
return name == port.name
|
return name == port.name
|
||||||
|
|
||||||
|
@ -329,8 +329,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
|
|||||||
"VNI %(segmentation_id)s",
|
"VNI %(segmentation_id)s",
|
||||||
{'interface': interface,
|
{'interface': interface,
|
||||||
'segmentation_id': segmentation_id})
|
'segmentation_id': segmentation_id})
|
||||||
args = {'dev': self.local_int,
|
args = {'srcport': (cfg.CONF.VXLAN.udp_srcport_min,
|
||||||
'srcport': (cfg.CONF.VXLAN.udp_srcport_min,
|
|
||||||
cfg.CONF.VXLAN.udp_srcport_max),
|
cfg.CONF.VXLAN.udp_srcport_max),
|
||||||
'dstport': cfg.CONF.VXLAN.udp_dstport,
|
'dstport': cfg.CONF.VXLAN.udp_dstport,
|
||||||
'ttl': cfg.CONF.VXLAN.ttl}
|
'ttl': cfg.CONF.VXLAN.ttl}
|
||||||
@ -356,7 +355,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
int_vxlan = self.ip.add_vxlan(interface, segmentation_id,
|
int_vxlan = self.ip.add_vxlan(interface, segmentation_id,
|
||||||
**args)
|
self.local_int, **args)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
with excutils.save_and_reraise_exception() as ctxt:
|
with excutils.save_and_reraise_exception() as ctxt:
|
||||||
# perform this check after an attempt rather than before
|
# perform this check after an attempt rather than before
|
||||||
|
@ -122,7 +122,7 @@ class FdbInterfaceTestCase(testscenarios.WithScenarios, base.BaseSudoTestCase):
|
|||||||
vni = random.randint(1, 2**24 - 1)
|
vni = random.randint(1, 2**24 - 1)
|
||||||
ip_wrapper = ip_lib.IPWrapper(self.namespace)
|
ip_wrapper = ip_lib.IPWrapper(self.namespace)
|
||||||
ip_wrapper.add_dummy(self.device)
|
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 = ip_lib.IPDevice(self.device, self.namespace)
|
||||||
ip_device.link.set_up()
|
ip_device.link.set_up()
|
||||||
ip_device.addr.add(self.ip)
|
ip_device.addr.add(self.ip)
|
||||||
|
@ -233,9 +233,10 @@ class IpLibTestCase(IpLibTestFramework):
|
|||||||
attr = self.generate_device_details()
|
attr = self.generate_device_details()
|
||||||
ip = ip_lib.IPWrapper(namespace=attr.namespace)
|
ip = ip_lib.IPWrapper(namespace=attr.namespace)
|
||||||
ip.netns.add(attr.namespace)
|
ip.netns.add(attr.namespace)
|
||||||
|
ip.add_dummy('dummy_device')
|
||||||
self.addCleanup(ip.netns.delete, attr.namespace)
|
self.addCleanup(ip.netns.delete, attr.namespace)
|
||||||
self.assertFalse(ip_lib.vxlan_in_use(9999, namespace=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.addCleanup(self._safe_delete_device, device)
|
||||||
self.assertTrue(ip_lib.vxlan_in_use(9999, namespace=attr.namespace))
|
self.assertTrue(ip_lib.vxlan_in_use(9999, namespace=attr.namespace))
|
||||||
device.link.delete()
|
device.link.delete()
|
||||||
|
@ -209,7 +209,7 @@ class TcFiltersTestCase(functional_base.BaseSudoTestCase):
|
|||||||
if i == 0:
|
if i == 0:
|
||||||
ip_wrapper.add_veth(self.device[0], self.device[1], self.ns[1])
|
ip_wrapper.add_veth(self.device[0], self.device[1], self.ns[1])
|
||||||
ip_wrapper.add_vxlan(self.device_vxlan[i], self.vxlan_id,
|
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], self.ns[i])
|
ip_device = ip_lib.IPDevice(self.device[i], self.ns[i])
|
||||||
ip_device.link.set_up()
|
ip_device.link.set_up()
|
||||||
ip_device.addr.add(self.ip[i])
|
ip_device.addr.add(self.ip[i])
|
||||||
|
@ -385,10 +385,9 @@ class TestIpWrapper(base.BaseTestCase):
|
|||||||
'vxlan_proxy': True,
|
'vxlan_proxy': True,
|
||||||
'vxlan_port_range': ('1', '2')}
|
'vxlan_port_range': ('1', '2')}
|
||||||
|
|
||||||
retval = ip_lib.IPWrapper().add_vxlan('vxlan0', 'vni0',
|
retval = ip_lib.IPWrapper().add_vxlan('vxlan0', 'vni0', 'dev0',
|
||||||
group=VXLAN4_GROUP_SAMPLE,
|
group=VXLAN4_GROUP_SAMPLE,
|
||||||
dev='dev0', ttl='ttl0',
|
ttl='ttl0', tos='tos0',
|
||||||
tos='tos0',
|
|
||||||
local=VXLAN4_LOCAL_SAMPLE,
|
local=VXLAN4_LOCAL_SAMPLE,
|
||||||
proxy=True, srcport=(1, 2))
|
proxy=True, srcport=(1, 2))
|
||||||
self.assertIsInstance(retval, ip_lib.IPDevice)
|
self.assertIsInstance(retval, ip_lib.IPDevice)
|
||||||
@ -486,10 +485,9 @@ class TestIpWrapper(base.BaseTestCase):
|
|||||||
'vxlan_port_range': ('1', '2'),
|
'vxlan_port_range': ('1', '2'),
|
||||||
'vxlan_port': 4789}
|
'vxlan_port': 4789}
|
||||||
|
|
||||||
retval = ip_lib.IPWrapper().add_vxlan('vxlan0', 'vni0',
|
retval = ip_lib.IPWrapper().add_vxlan('vxlan0', 'vni0', 'dev0',
|
||||||
group=VXLAN4_GROUP_SAMPLE,
|
group=VXLAN4_GROUP_SAMPLE,
|
||||||
dev='dev0', ttl='ttl0',
|
ttl='ttl0', tos='tos0',
|
||||||
tos='tos0',
|
|
||||||
local=VXLAN4_LOCAL_SAMPLE,
|
local=VXLAN4_LOCAL_SAMPLE,
|
||||||
proxy=True, srcport=(1, 2),
|
proxy=True, srcport=(1, 2),
|
||||||
dstport=4789)
|
dstport=4789)
|
||||||
|
@ -396,22 +396,22 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
|||||||
retval = self.lbm.ensure_vxlan(seg_id, mtu=1450)
|
retval = self.lbm.ensure_vxlan(seg_id, mtu=1450)
|
||||||
self.assertEqual("vxlan-" + seg_id, retval)
|
self.assertEqual("vxlan-" + seg_id, retval)
|
||||||
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
||||||
|
self.lbm.local_int,
|
||||||
group="224.0.0.1",
|
group="224.0.0.1",
|
||||||
srcport=(0, 0),
|
srcport=(0, 0),
|
||||||
dstport=None,
|
dstport=None,
|
||||||
ttl=None,
|
ttl=None)
|
||||||
dev=self.lbm.local_int)
|
|
||||||
dv6_fn.assert_called_once_with()
|
dv6_fn.assert_called_once_with()
|
||||||
set_mtu_fn.assert_called_once_with(1450)
|
set_mtu_fn.assert_called_once_with(1450)
|
||||||
cfg.CONF.set_override('l2_population', 'True', 'VXLAN')
|
cfg.CONF.set_override('l2_population', 'True', 'VXLAN')
|
||||||
self.assertEqual("vxlan-" + seg_id,
|
self.assertEqual("vxlan-" + seg_id,
|
||||||
self.lbm.ensure_vxlan(seg_id))
|
self.lbm.ensure_vxlan(seg_id))
|
||||||
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
||||||
|
self.lbm.local_int,
|
||||||
group="224.0.0.1",
|
group="224.0.0.1",
|
||||||
srcport=(0, 0),
|
srcport=(0, 0),
|
||||||
dstport=None,
|
dstport=None,
|
||||||
ttl=None,
|
ttl=None,
|
||||||
dev=self.lbm.local_int,
|
|
||||||
local=self.lbm.local_ip,
|
local=self.lbm.local_ip,
|
||||||
proxy=expected_proxy)
|
proxy=expected_proxy)
|
||||||
|
|
||||||
@ -432,12 +432,12 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
|||||||
self.assertEqual("vxlan-" + seg_id,
|
self.assertEqual("vxlan-" + seg_id,
|
||||||
self.lbm.ensure_vxlan(seg_id))
|
self.lbm.ensure_vxlan(seg_id))
|
||||||
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
||||||
|
self.lbm.local_int,
|
||||||
group="224.0.0.1",
|
group="224.0.0.1",
|
||||||
srcport=(0, 0),
|
srcport=(0, 0),
|
||||||
dstport=None,
|
dstport=None,
|
||||||
ttl=None,
|
ttl=None,
|
||||||
tos='inherit',
|
tos='inherit')
|
||||||
dev=self.lbm.local_int)
|
|
||||||
dv6_fn.assert_called_once_with()
|
dv6_fn.assert_called_once_with()
|
||||||
|
|
||||||
def test_ensure_vxlan_mtu_too_big(self):
|
def test_ensure_vxlan_mtu_too_big(self):
|
||||||
@ -463,11 +463,11 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
|||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
self.lbm.ensure_vxlan(seg_id, mtu=mtu))
|
self.lbm.ensure_vxlan(seg_id, mtu=mtu))
|
||||||
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
add_vxlan_fn.assert_called_with("vxlan-" + seg_id, seg_id,
|
||||||
|
self.lbm.local_int,
|
||||||
group="224.0.0.1",
|
group="224.0.0.1",
|
||||||
srcport=(0, 0),
|
srcport=(0, 0),
|
||||||
dstport=None,
|
dstport=None,
|
||||||
ttl=None,
|
ttl=None)
|
||||||
dev=self.lbm.local_int)
|
|
||||||
delete_dev.assert_called_once_with()
|
delete_dev.assert_called_once_with()
|
||||||
dv6_fn.assert_not_called()
|
dv6_fn.assert_not_called()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user