From 6cf92011143eb55adda180ffac91886566fc7826 Mon Sep 17 00:00:00 2001 From: Darragh O'Reilly Date: Thu, 16 Apr 2015 18:21:03 +0000 Subject: [PATCH] lb-agent: ensure tap mtu is the same as physical device On compute-nodes, Nova creates the bridge with the tap before the physical is in the bridge. This causes the tap to have the default 1500 MTU which may be different to what is on the physical. With this patch the linuxbridge agent ensures that the MTU on the tap device is the same as what is on the physical device. Change-Id: Id1a4f662ec33ca0333c15eb210366bc850d0d54c Closes-Bug: 1443607 --- .../agent/linuxbridge_neutron_agent.py | 18 +++++++++++++----- .../agent/test_linuxbridge_neutron_agent.py | 13 +++++++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py index 7b1f28615..fa7c4b906 100644 --- a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -384,11 +384,14 @@ class LinuxBridgeManager(object): bridge_name = self.get_bridge_name(network_id) if network_type == p_const.TYPE_LOCAL: self.ensure_local_bridge(network_id) - elif not self.ensure_physical_in_bridge(network_id, - network_type, - physical_network, - segmentation_id): - return False + else: + phy_dev_name = self.ensure_physical_in_bridge(network_id, + network_type, + physical_network, + segmentation_id) + if not phy_dev_name: + return False + self.ensure_tap_mtu(tap_device_name, phy_dev_name) # Check if device needs to be added to bridge tap_device_in_bridge = self.get_bridge_for_tap_device(tap_device_name) @@ -407,6 +410,11 @@ class LinuxBridgeManager(object): "%(bridge_name)s", data) return True + def ensure_tap_mtu(self, tap_dev_name, phy_dev_name): + """Ensure the MTU on the tap is the same as the physical device.""" + phy_dev_mtu = ip_lib.IPDevice(phy_dev_name).link.mtu + ip_lib.IPDevice(tap_dev_name).link.set_mtu(phy_dev_mtu) + def add_interface(self, network_id, network_type, physical_network, segmentation_id, port_id): self.network_map[network_id] = NetworkSegment(network_type, diff --git a/neutron/tests/unit/plugins/linuxbridge/agent/test_linuxbridge_neutron_agent.py b/neutron/tests/unit/plugins/linuxbridge/agent/test_linuxbridge_neutron_agent.py index bc6b59532..b7adf56b8 100644 --- a/neutron/tests/unit/plugins/linuxbridge/agent/test_linuxbridge_neutron_agent.py +++ b/neutron/tests/unit/plugins/linuxbridge/agent/test_linuxbridge_neutron_agent.py @@ -672,14 +672,23 @@ class TestLinuxBridgeManager(base.BaseTestCase): "physnet1", None, "tap1")) - with mock.patch.object(self.lbm, - "ensure_physical_in_bridge") as ens_fn: + with contextlib.nested( + mock.patch.object(self.lbm, "ensure_physical_in_bridge"), + mock.patch.object(self.lbm, "ensure_tap_mtu"), + mock.patch.object(self.lbm, "get_bridge_for_tap_device") + ) as (ens_fn, en_mtu_fn, get_br): ens_fn.return_value = False self.assertFalse(self.lbm.add_tap_interface("123", p_const.TYPE_VLAN, "physnet1", "1", "tap1")) + ens_fn.return_value = "eth0.1" + get_br.return_value = "brq123" + self.lbm.add_tap_interface("123", p_const.TYPE_VLAN, + "physnet1", "1", "tap1") + en_mtu_fn.assert_called_once_with("tap1", "eth0.1") + def test_add_interface(self): with mock.patch.object(self.lbm, "add_tap_interface") as add_tap: self.lbm.add_interface("123", p_const.TYPE_VLAN, "physnet-1", -- 2.45.2