Use MTU value from Neutron in OVS/LB VIF wiring

This patch adds the MTU attached to a Neutron network to
the network model so the VIF plugging code can reference
the MTU and set the correct value for the Neutron network
it is attaching to.

Conflicts:
        nova/tests/unit/network/test_neutronv2.py
        nova/tests/unit/virt/libvirt/test_vif.py
        nova/virt/libvirt/vif.py

NOTE(mriedem): test_neutronv2 conflict is due to
830010b443 not being in
stable/liberty. vif conflict is due to
1bf6a8760f not being in
stable/liberty. test_vif conflict is due to 1bf6a8760
and c805293e77 not being
in stable/liberty.

Closes-Bug: #1549408
Change-Id: Ibd4de83e1af193eb2dcd997e6528d2fccaa2979a
(cherry picked from commit 69ec718b62)
This commit is contained in:
Kevin Benton 2016-02-22 18:35:48 -08:00 committed by Matt Riedemann
parent 638498f6e5
commit 80d9e63db3
5 changed files with 29 additions and 17 deletions

View File

@ -1342,7 +1342,7 @@ def _set_device_mtu(dev, mtu=None):
check_exit_code=[0, 2, 254])
def _create_veth_pair(dev1_name, dev2_name):
def _create_veth_pair(dev1_name, dev2_name, mtu=None):
"""Create a pair of veth devices with the specified names,
deleting any previous devices with those names.
"""
@ -1355,7 +1355,7 @@ def _create_veth_pair(dev1_name, dev2_name):
utils.execute('ip', 'link', 'set', dev, 'up', run_as_root=True)
utils.execute('ip', 'link', 'set', dev, 'promisc', 'on',
run_as_root=True)
_set_device_mtu(dev)
_set_device_mtu(dev, mtu)
def _ovs_vsctl(args):
@ -1368,7 +1368,7 @@ def _ovs_vsctl(args):
raise exception.AgentError(method=full_args)
def create_ovs_vif_port(bridge, dev, iface_id, mac, instance_id):
def create_ovs_vif_port(bridge, dev, iface_id, mac, instance_id, mtu=None):
_ovs_vsctl(['--', '--if-exists', 'del-port', dev, '--',
'add-port', bridge, dev,
'--', 'set', 'Interface', dev,
@ -1376,7 +1376,7 @@ def create_ovs_vif_port(bridge, dev, iface_id, mac, instance_id):
'external-ids:iface-status=active',
'external-ids:attached-mac=%s' % mac,
'external-ids:vm-uuid=%s' % instance_id])
_set_device_mtu(dev)
_set_device_mtu(dev, mtu)
def delete_ovs_vif_port(bridge, dev):

View File

@ -1602,10 +1602,12 @@ class API(base_api.NetworkAPI):
def _nw_info_build_network(self, port, networks, subnets):
network_name = None
network_mtu = None
for net in networks:
if port['network_id'] == net['id']:
network_name = net['name']
tenant_id = net['tenant_id']
network_mtu = net.get('mtu')
break
else:
tenant_id = port['tenant_id']
@ -1648,7 +1650,8 @@ class API(base_api.NetworkAPI):
bridge=bridge,
injected=CONF.flat_injected,
label=network_name,
tenant_id=tenant_id
tenant_id=tenant_id,
mtu=network_mtu
)
network['subnets'] = subnets
port_profile = port.get('binding:profile')

View File

@ -2391,7 +2391,8 @@ class TestNeutronv2(TestNeutronv2Base):
'binding:vif_type': vif_type,
}
fake_subnets = [model.Subnet(cidr='1.0.0.0/8')]
fake_nets = [{'id': 'net-id', 'name': 'foo', 'tenant_id': 'tenant'}]
fake_nets = [{'id': 'net-id', 'name': 'foo', 'tenant_id': 'tenant',
'mtu': 9000}]
api = neutronapi.API()
self.mox.ReplayAll()
neutronapi.get_client('fake')
@ -2401,6 +2402,7 @@ class TestNeutronv2(TestNeutronv2Base):
self.assertEqual(net['id'], 'net-id')
self.assertEqual(net['label'], 'foo')
self.assertEqual(net.get_meta('tenant_id'), 'tenant')
self.assertEqual(9000, net.get_meta('mtu'))
self.assertEqual(net.get_meta('injected'), CONF.flat_injected)
return net, iid

View File

@ -59,7 +59,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
subnets=[subnet_bridge_4,
subnet_bridge_6],
bridge_interface='eth0',
vlan=99)
vlan=99, mtu=9000)
vif_bridge = network_model.VIF(id='vif-xxx-yyy-zzz',
address='ca:fe:de:ad:be:ef',
@ -89,7 +89,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
subnets=[subnet_bridge_4,
subnet_bridge_6],
bridge_interface=None,
vlan=99)
vlan=99, mtu=1000)
network_ivs = network_model.Network(id='network-id-xxx-yyy-zzz',
bridge='br0',
@ -312,7 +312,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
network_model.VIF_DETAILS_VHOSTUSER_SOCKET:
'/tmp/usv-xxx-yyy-zzz',
network_model.VIF_DETAILS_VHOSTUSER_OVS_PLUG: True},
ovs_interfaceid='aaa-bbb-ccc'
ovs_interfaceid='aaa-bbb-ccc', mtu=1500
)
vif_vhostuser_no_path = network_model.VIF(id='vif-xxx-yyy-zzz',
@ -665,7 +665,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
'device_exists': [mock.call('qbrvif-xxx-yyy'),
mock.call('qvovif-xxx-yyy')],
'_create_veth_pair': [mock.call('qvbvif-xxx-yyy',
'qvovif-xxx-yyy')],
'qvovif-xxx-yyy', 1000)],
'execute': [mock.call('brctl', 'addbr', 'qbrvif-xxx-yyy',
run_as_root=True),
mock.call('brctl', 'setfd', 'qbrvif-xxx-yyy', 0,
@ -679,7 +679,8 @@ class LibvirtVifTestCase(test.NoDBTestCase):
'create_ovs_vif_port': [mock.call('br0',
'qvovif-xxx-yyy', 'aaa-bbb-ccc',
'ca:fe:de:ad:be:ef',
'instance-uuid')]
'instance-uuid',
1000)]
}
# The disable_ipv6 call needs to be added in the middle, if required
if ipv6_exists:
@ -799,7 +800,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
'device_exists': [mock.call('qbrvif-xxx-yyy'),
mock.call('qvovif-xxx-yyy')],
'_create_veth_pair': [mock.call('qvbvif-xxx-yyy',
'qvovif-xxx-yyy')],
'qvovif-xxx-yyy', None)],
'execute': [mock.call('brctl', 'addbr', 'qbrvif-xxx-yyy',
run_as_root=True),
mock.call('brctl', 'setfd', 'qbrvif-xxx-yyy', 0,
@ -1315,7 +1316,8 @@ class LibvirtVifTestCase(test.NoDBTestCase):
'usv-xxx-yyy-zzz',
'aaa-bbb-ccc',
'ca:fe:de:ad:be:ef',
'instance-uuid')],
'instance-uuid',
9000)],
'ovs_set_vhostuser_port_type': [mock.call('usv-xxx-yyy-zzz')]
}
with contextlib.nested(

View File

@ -512,13 +512,15 @@ class LibvirtGenericVIFDriver(object):
check_exit_code=[0, 1])
if not linux_net.device_exists(v2_name):
linux_net._create_veth_pair(v1_name, v2_name)
mtu = vif['network'].get_meta('mtu')
linux_net._create_veth_pair(v1_name, v2_name, mtu)
utils.execute('ip', 'link', 'set', br_name, 'up', run_as_root=True)
utils.execute('brctl', 'addif', br_name, v1_name, run_as_root=True)
if port == 'ovs':
linux_net.create_ovs_vif_port(self.get_bridge_name(vif),
v2_name, iface_id,
vif['address'], instance.uuid)
vif['address'], instance.uuid,
mtu)
elif port == 'ivs':
linux_net.create_ivs_vif_port(v2_name, iface_id,
vif['address'], instance.uuid)
@ -660,7 +662,9 @@ class LibvirtGenericVIFDriver(object):
dev = self.get_vif_devname(vif)
mac = vif['details'].get(network_model.VIF_DETAILS_TAP_MAC_ADDRESS)
linux_net.create_tap_dev(dev, mac)
linux_net._set_device_mtu(dev)
network = vif.get('network')
mtu = network.get_meta('mtu') if network else None
linux_net._set_device_mtu(dev, mtu)
def plug_vhostuser(self, instance, vif):
ovs_plug = vif['details'].get(
@ -670,9 +674,10 @@ class LibvirtGenericVIFDriver(object):
iface_id = self.get_ovs_interfaceid(vif)
port_name = os.path.basename(
vif['details'][network_model.VIF_DETAILS_VHOSTUSER_SOCKET])
mtu = vif['network'].get_meta('mtu')
linux_net.create_ovs_vif_port(self.get_bridge_name(vif),
port_name, iface_id, vif['address'],
instance.uuid)
instance.uuid, mtu)
linux_net.ovs_set_vhostuser_port_type(port_name)
def plug_vrouter(self, instance, vif):