diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py index 05e651401cd..90266694b4d 100644 --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@ -276,9 +276,10 @@ 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: try: ip_version = common_utils.get_ip_version(group) @@ -289,8 +290,6 @@ class IPWrapper(SubProcessBase): except netaddr.core.AddrFormatError: err_msg = _("Invalid group address: %s") % group raise exceptions.InvalidInput(error_message=err_msg) - if dev: - kwargs['physical_interface'] = dev if ttl: kwargs['vxlan_ttl'] = ttl if tos: diff --git a/neutron/cmd/sanity/checks.py b/neutron/cmd/sanity/checks.py index ca6516767ed..a4894dfbe72 100644 --- a/neutron/cmd/sanity/checks.py +++ b/neutron/cmd/sanity/checks.py @@ -74,8 +74,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 diff --git a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py index a3d927f70d0..c7b6f5aa86d 100644 --- a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -329,8 +329,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} @@ -356,7 +355,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 diff --git a/neutron/tests/functional/agent/linux/test_bridge_lib.py b/neutron/tests/functional/agent/linux/test_bridge_lib.py index f9887e45262..2e6a46ff9f0 100644 --- a/neutron/tests/functional/agent/linux/test_bridge_lib.py +++ b/neutron/tests/functional/agent/linux/test_bridge_lib.py @@ -122,7 +122,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) diff --git a/neutron/tests/functional/agent/linux/test_ip_lib.py b/neutron/tests/functional/agent/linux/test_ip_lib.py index 60dd0015942..97ccd618a25 100644 --- a/neutron/tests/functional/agent/linux/test_ip_lib.py +++ b/neutron/tests/functional/agent/linux/test_ip_lib.py @@ -233,9 +233,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() diff --git a/neutron/tests/functional/agent/linux/test_tc_lib.py b/neutron/tests/functional/agent/linux/test_tc_lib.py index ee4d7f11121..cc110feffbc 100644 --- a/neutron/tests/functional/agent/linux/test_tc_lib.py +++ b/neutron/tests/functional/agent/linux/test_tc_lib.py @@ -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], self.ns[i]) ip_device.link.set_up() ip_device.addr.add(self.ip[i]) diff --git a/neutron/tests/unit/agent/linux/test_ip_lib.py b/neutron/tests/unit/agent/linux/test_ip_lib.py index 26b24503d97..23d96918487 100644 --- a/neutron/tests/unit/agent/linux/test_ip_lib.py +++ b/neutron/tests/unit/agent/linux/test_ip_lib.py @@ -385,10 +385,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=VXLAN4_GROUP_SAMPLE, - dev='dev0', ttl='ttl0', - tos='tos0', + ttl='ttl0', tos='tos0', local=VXLAN4_LOCAL_SAMPLE, proxy=True, srcport=(1, 2)) self.assertIsInstance(retval, ip_lib.IPDevice) @@ -486,10 +485,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=VXLAN4_GROUP_SAMPLE, - dev='dev0', ttl='ttl0', - tos='tos0', + ttl='ttl0', tos='tos0', local=VXLAN4_LOCAL_SAMPLE, proxy=True, srcport=(1, 2), dstport=4789) diff --git a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py index 9c300f9c61a..16ae7d660fd 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py @@ -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()