Add global_physnet_mtu and deprecate segment_mtu
Introduce the neutron-wide 'global_physnet_mtu' option that references the underlying physical network MTU. This also introduces a method in plugin.common.utils that all plugins should use to retrieve it. This value should be used to calculate the proper MTU for virtual network components. This patch also deprecate the 'segment_mtu' option specific to the ML2 plug-in and makes ML2 reference this new option. Closes-Bug: #1542475 Closes-Bug: #1542108 Change-Id: I6ffc8973c9b8f46cc19922ff04fdd2d23646b878
This commit is contained in:
parent
205e86a7f2
commit
ae45cd5732
@ -175,7 +175,16 @@ core_opts = [
|
||||
choices=('legacy', 'pecan'),
|
||||
help=_("This will choose the web framework in which to run "
|
||||
"the Neutron API server. 'pecan' is a new experiemental "
|
||||
"rewrite of the API server."))
|
||||
"rewrite of the API server.")),
|
||||
cfg.IntOpt('global_physnet_mtu', default=1500,
|
||||
deprecated_name='segment_mtu', deprecated_group='ml2',
|
||||
help=_('MTU of the underlying physical network. Neutron uses '
|
||||
'this value to calculate MTU for all virtual network '
|
||||
'components. For flat and VLAN networks, neutron uses '
|
||||
'this value without modification. For overlay networks '
|
||||
'such as VXLAN, neutron automatically subtracts the '
|
||||
'overlay protocol overhead from this value. Defaults '
|
||||
'to 1500, the standard value for Ethernet.'))
|
||||
]
|
||||
|
||||
core_cli_opts = [
|
||||
|
@ -18,6 +18,7 @@ Common utilities and helper functions for OpenStack Networking Plugins.
|
||||
|
||||
import hashlib
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
import webob.exc
|
||||
@ -32,6 +33,17 @@ INTERFACE_HASH_LEN = 6
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_deployment_physnet_mtu():
|
||||
"""Retrieves global physical network MTU setting.
|
||||
|
||||
Plugins should use this function to retrieve the MTU set by the operator
|
||||
that is equal to or less than the MTU of their nodes' physical interfaces.
|
||||
Note that it is the responsibility of the plugin to deduct the value of
|
||||
any encapsulation overhead required before advertising it to VMs.
|
||||
"""
|
||||
return cfg.CONF.global_physnet_mtu
|
||||
|
||||
|
||||
def is_valid_vlan_tag(vlan):
|
||||
return p_const.MIN_VLAN_TAG <= vlan <= p_const.MAX_VLAN_TAG
|
||||
|
||||
|
@ -52,11 +52,6 @@ ml2_opts = [
|
||||
'this feature and instances typically default to a '
|
||||
'1500 MTU. Only impacts instances, not neutron network '
|
||||
'components such as bridges and routers.')),
|
||||
cfg.IntOpt('segment_mtu', default=1500,
|
||||
help=_('The maximum permissible size of an unfragmented '
|
||||
'packet travelling a L2 network segment. The default '
|
||||
'value of 1500 is used as the segment MTU, to reflect '
|
||||
'standard Ethernet.')),
|
||||
cfg.ListOpt('physical_network_mtus',
|
||||
default=[],
|
||||
help=_("A list of mappings of physical networks to MTU "
|
||||
|
@ -21,6 +21,7 @@ from oslo_log import log
|
||||
|
||||
from neutron.common import exceptions as exc
|
||||
from neutron.common import utils
|
||||
from neutron.plugins.common import utils as p_utils
|
||||
from neutron.plugins.ml2 import driver_api as api
|
||||
|
||||
|
||||
@ -41,7 +42,7 @@ class BaseTypeDriver(api.TypeDriver):
|
||||
self.physnet_mtus = []
|
||||
|
||||
def get_mtu(self, physical_network=None):
|
||||
return cfg.CONF.ml2.segment_mtu
|
||||
return p_utils.get_deployment_physnet_mtu()
|
||||
|
||||
|
||||
class SegmentTypeDriver(BaseTypeDriver):
|
||||
|
@ -122,22 +122,22 @@ class FlatTypeTest(testlib_api.SqlTestCase):
|
||||
self.assertIsNone(observed)
|
||||
|
||||
def test_get_mtu(self):
|
||||
config.cfg.CONF.set_override('segment_mtu', 1475, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 1475)
|
||||
config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
|
||||
self.assertEqual(1450, self.driver.get_mtu('physnet1'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 1375, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 1375)
|
||||
config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
|
||||
self.assertEqual(1375, self.driver.get_mtu('physnet1'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 0, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 0)
|
||||
config.cfg.CONF.set_override('path_mtu', 1425, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
|
||||
self.assertEqual(1400, self.driver.get_mtu('physnet2'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 0, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 0)
|
||||
config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
|
||||
self.driver.physnet_mtus = {}
|
||||
self.assertEqual(0, self.driver.get_mtu('physnet1'))
|
||||
|
@ -56,25 +56,25 @@ class GreTypeTest(base_type_tunnel.TunnelTypeTestMixin,
|
||||
self.assertEqual(base_type_tunnel.HOST_TWO, endpoint['host'])
|
||||
|
||||
def test_get_mtu(self):
|
||||
config.cfg.CONF.set_override('segment_mtu', 1500, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 1500)
|
||||
config.cfg.CONF.set_override('path_mtu', 1475, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
|
||||
self.assertEqual(1475 - p_const.GRE_ENCAP_OVERHEAD,
|
||||
self.driver.get_mtu('physnet1'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 1425, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 1425)
|
||||
config.cfg.CONF.set_override('path_mtu', 1475, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1400, 'physnet2': 1400}
|
||||
self.assertEqual(1425 - p_const.GRE_ENCAP_OVERHEAD,
|
||||
self.driver.get_mtu('physnet1'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 0, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 0)
|
||||
config.cfg.CONF.set_override('path_mtu', 1475, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1425}
|
||||
self.assertEqual(1475 - p_const.GRE_ENCAP_OVERHEAD,
|
||||
self.driver.get_mtu('physnet2'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 0, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 0)
|
||||
config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
|
||||
self.driver.physnet_mtus = {}
|
||||
self.assertEqual(0, self.driver.get_mtu('physnet1'))
|
||||
|
@ -205,22 +205,22 @@ class VlanTypeTest(testlib_api.SqlTestCase):
|
||||
segment)
|
||||
|
||||
def test_get_mtu(self):
|
||||
config.cfg.CONF.set_override('segment_mtu', 1475, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 1475)
|
||||
config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
|
||||
self.assertEqual(1450, self.driver.get_mtu('physnet1'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 1375, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 1375)
|
||||
config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
|
||||
self.assertEqual(1375, self.driver.get_mtu('physnet1'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 0, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 0)
|
||||
config.cfg.CONF.set_override('path_mtu', 1400, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
|
||||
self.assertEqual(1450, self.driver.get_mtu('physnet1'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 0, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 0)
|
||||
config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
|
||||
self.driver.physnet_mtus = {}
|
||||
self.assertEqual(0, self.driver.get_mtu('physnet1'))
|
||||
|
@ -66,25 +66,25 @@ class VxlanTypeTest(base_type_tunnel.TunnelTypeTestMixin,
|
||||
self.assertEqual(base_type_tunnel.HOST_TWO, endpoint['host'])
|
||||
|
||||
def test_get_mtu(self):
|
||||
config.cfg.CONF.set_override('segment_mtu', 1500, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 1500)
|
||||
config.cfg.CONF.set_override('path_mtu', 1475, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1450, 'physnet2': 1400}
|
||||
self.assertEqual(1475 - p_const.VXLAN_ENCAP_OVERHEAD,
|
||||
self.driver.get_mtu('physnet1'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 1450, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 1450)
|
||||
config.cfg.CONF.set_override('path_mtu', 1475, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1400, 'physnet2': 1425}
|
||||
self.assertEqual(1450 - p_const.VXLAN_ENCAP_OVERHEAD,
|
||||
self.driver.get_mtu('physnet1'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 0, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 0)
|
||||
config.cfg.CONF.set_override('path_mtu', 1450, group='ml2')
|
||||
self.driver.physnet_mtus = {'physnet1': 1425, 'physnet2': 1400}
|
||||
self.assertEqual(1450 - p_const.VXLAN_ENCAP_OVERHEAD,
|
||||
self.driver.get_mtu('physnet1'))
|
||||
|
||||
config.cfg.CONF.set_override('segment_mtu', 0, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 0)
|
||||
config.cfg.CONF.set_override('path_mtu', 0, group='ml2')
|
||||
self.driver.physnet_mtus = {}
|
||||
self.assertEqual(0, self.driver.get_mtu('physnet1'))
|
||||
|
@ -378,7 +378,7 @@ class TestExternalNetwork(Ml2PluginV2TestCase):
|
||||
class TestMl2NetworksWithVlanTransparencyAndMTU(TestMl2NetworksV2):
|
||||
def setUp(self, plugin=None):
|
||||
config.cfg.CONF.set_override('path_mtu', 1000, group='ml2')
|
||||
config.cfg.CONF.set_override('segment_mtu', 1000, group='ml2')
|
||||
config.cfg.CONF.set_override('global_physnet_mtu', 1000)
|
||||
config.cfg.CONF.set_override('advertise_mtu', True)
|
||||
config.cfg.CONF.set_override('vlan_transparent', True)
|
||||
super(TestMl2NetworksWithVlanTransparencyAndMTU, self).setUp(plugin)
|
||||
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
deprecations:
|
||||
- The 'segment_mtu' option of the ML2 configuration has been
|
||||
deprecated and replaced with the 'global_physnet_mtu' option
|
||||
in the main Neutron configuration. This option is meant to
|
||||
be used by all plugins for an operator to reference their
|
||||
physical network's MTU, regardless of the backend plugin.
|
||||
Plugins should access this config option via the
|
||||
'get_deployment_physnet_mtu' method added to
|
||||
neutron.plugins.common.utils to avoid being broken on any
|
||||
potential renames in the future.
|
Loading…
Reference in New Issue
Block a user