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
This commit is contained in:
Darragh O'Reilly 2015-04-16 18:21:03 +00:00
parent cc020dc930
commit 6cf9201114
2 changed files with 24 additions and 7 deletions

View 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,

View 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",