]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
lb-agent: ensure tap mtu is the same as physical device
authorDarragh O'Reilly <darragh.oreilly@hp.com>
Thu, 16 Apr 2015 18:21:03 +0000 (18:21 +0000)
committerDarragh O'Reilly <darragh.oreilly@hp.com>
Tue, 21 Apr 2015 06:27:11 +0000 (06:27 +0000)
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

neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py
neutron/tests/unit/plugins/linuxbridge/agent/test_linuxbridge_neutron_agent.py

index 7b1f2861500062369a0d3f6c6d279ab4a34c3d9f..fa7c4b906261784b5972a944dd03dbc71c2754c5 100644 (file)
@@ -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,
index bc6b59532dbaa0048835fa821b67173089ec0249..b7adf56b8216c46380f54590a57734c41aeeac96 100644 (file)
@@ -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",