diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-07-09 03:19:20 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-07-09 03:19:20 +0000 |
commit | abf410460d5c887b804c97deeb56004ee68feef6 (patch) | |
tree | 71dd76930fa0bcc4fdf08585f5a83d0a5ebb03bb | |
parent | 2696814dd16d8e0ce494336a7c7923c8f6c17a6b (diff) | |
parent | 652f5ac7959eff6a8f2deb057ebf1307785ae35b (diff) | |
download | neutron-abf410460d5c887b804c97deeb56004ee68feef6.tar.gz |
Merge "ovs: set device MTU after it's moved into a namespace" into stable/liberty
-rw-r--r-- | neutron/agent/linux/interface.py | 13 | ||||
-rw-r--r-- | neutron/tests/functional/agent/linux/test_interface.py | 36 |
2 files changed, 45 insertions, 4 deletions
diff --git a/neutron/agent/linux/interface.py b/neutron/agent/linux/interface.py index 7cb5201ca2..76ccddee7f 100644 --- a/neutron/agent/linux/interface.py +++ b/neutron/agent/linux/interface.py @@ -342,6 +342,15 @@ class OVSInterfaceDriver(LinuxInterfaceDriver): ns_dev.link.set_address(mac_address) + # Add an interface created by ovs to the namespace. + if not self.conf.ovs_use_veth and namespace: + namespace_obj = ip.ensure_namespace(namespace) + namespace_obj.add_device_to_namespace(ns_dev) + + # NOTE(ihrachys): the order here is significant: we must set MTU after + # the device is moved into a namespace, otherwise OVS bridge does not + # allow to set MTU that is higher than the least of all device MTUs on + # the bridge mtu = self.conf.network_device_mtu or mtu if mtu: ns_dev.link.set_mtu(mtu) @@ -349,10 +358,6 @@ class OVSInterfaceDriver(LinuxInterfaceDriver): root_dev.link.set_mtu(mtu) else: LOG.warning(_LW("No MTU configured for port %s"), port_id) - # Add an interface created by ovs to the namespace. - if not self.conf.ovs_use_veth and namespace: - namespace_obj = ip.ensure_namespace(namespace) - namespace_obj.add_device_to_namespace(ns_dev) ns_dev.link.set_up() if self.conf.ovs_use_veth: diff --git a/neutron/tests/functional/agent/linux/test_interface.py b/neutron/tests/functional/agent/linux/test_interface.py index 588341ebfc..73443cb3df 100644 --- a/neutron/tests/functional/agent/linux/test_interface.py +++ b/neutron/tests/functional/agent/linux/test_interface.py @@ -56,3 +56,39 @@ class OVSInterfaceDriverTestCase(base.BaseOVSLinuxTestCase): namespace=namespace) self.assertIn(device_name, bridge.get_port_name_list()) self.assertTrue(ip_lib.device_exists(device_name, namespace)) + + def test_plug_with_namespace_sets_mtu_higher_than_bridge(self): + device_mtu = 1450 + + # Create a new OVS bridge + ovs_bridge = self.useFixture(net_helpers.OVSBridgeFixture()).bridge + self.assertFalse(ovs_bridge.get_port_name_list()) + + # Add a new linuxbridge port with reduced MTU to OVS bridge + lb_bridge = self.useFixture( + net_helpers.LinuxBridgeFixture()).bridge + lb_bridge_port = self.useFixture( + net_helpers.LinuxBridgePortFixture(lb_bridge)) + lb_bridge_port.port.link.set_mtu(device_mtu - 1) + ovs_bridge.add_port(lb_bridge_port.port.name) + + # Now plug a device with intended MTU that is higher than for the port + # above and validate that its MTU is not reduced to the least MTU on + # the bridge + device_name = tests_base.get_rand_name() + mac_address = utils.get_random_mac('fa:16:3e:00:00:00'.split(':')) + namespace = self.useFixture(net_helpers.NamespaceFixture()).name + self.interface.plug(network_id=uuidutils.generate_uuid(), + port_id=uuidutils.generate_uuid(), + device_name=device_name, + mac_address=mac_address, + bridge=ovs_bridge.br_name, + namespace=namespace, + mtu=device_mtu) + + self.assertIn(device_name, ovs_bridge.get_port_name_list()) + self.assertTrue(ip_lib.device_exists(device_name, namespace)) + self.assertEqual( + device_mtu, + ip_lib.IPDevice(device_name, namespace=namespace).link.mtu + ) |