From ae45cd5732b8b75a5b2d35df555f46e11145eb85 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Tue, 23 Feb 2016 13:11:40 -0800 Subject: [PATCH] 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 --- neutron/common/config.py | 11 ++++++++++- neutron/plugins/common/utils.py | 12 ++++++++++++ neutron/plugins/ml2/config.py | 5 ----- neutron/plugins/ml2/drivers/helpers.py | 3 ++- .../tests/unit/plugins/ml2/drivers/test_type_flat.py | 8 ++++---- .../tests/unit/plugins/ml2/drivers/test_type_gre.py | 8 ++++---- .../tests/unit/plugins/ml2/drivers/test_type_vlan.py | 8 ++++---- .../unit/plugins/ml2/drivers/test_type_vxlan.py | 8 ++++---- neutron/tests/unit/plugins/ml2/test_plugin.py | 2 +- ...t_mtu_to_global_physnet_mtu-9cee5ff09557edeb.yaml | 11 +++++++++++ 10 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 releasenotes/notes/segment_mtu_to_global_physnet_mtu-9cee5ff09557edeb.yaml diff --git a/neutron/common/config.py b/neutron/common/config.py index c92106cd63e..b4452d33483 100644 --- a/neutron/common/config.py +++ b/neutron/common/config.py @@ -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 = [ diff --git a/neutron/plugins/common/utils.py b/neutron/plugins/common/utils.py index 7ec7ba5a2bf..6e9d9016094 100644 --- a/neutron/plugins/common/utils.py +++ b/neutron/plugins/common/utils.py @@ -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 diff --git a/neutron/plugins/ml2/config.py b/neutron/plugins/ml2/config.py index fb54c1d616b..b7fc1cb4ca0 100644 --- a/neutron/plugins/ml2/config.py +++ b/neutron/plugins/ml2/config.py @@ -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 " diff --git a/neutron/plugins/ml2/drivers/helpers.py b/neutron/plugins/ml2/drivers/helpers.py index 1e8b1fca01b..28e3320d7cb 100644 --- a/neutron/plugins/ml2/drivers/helpers.py +++ b/neutron/plugins/ml2/drivers/helpers.py @@ -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): diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py index 8dd87b931a6..bb3d2c7a219 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py @@ -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')) diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_gre.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_gre.py index 0471c68ec41..788e13a825c 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_gre.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_gre.py @@ -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')) diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py index 0444285d7dc..9735bd95f85 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py @@ -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')) diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_vxlan.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_vxlan.py index ac271095e30..cae9f6e516f 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_vxlan.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_vxlan.py @@ -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')) diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index 6176117acc4..dd5b500affe 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -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) diff --git a/releasenotes/notes/segment_mtu_to_global_physnet_mtu-9cee5ff09557edeb.yaml b/releasenotes/notes/segment_mtu_to_global_physnet_mtu-9cee5ff09557edeb.yaml new file mode 100644 index 00000000000..adb31614a9f --- /dev/null +++ b/releasenotes/notes/segment_mtu_to_global_physnet_mtu-9cee5ff09557edeb.yaml @@ -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.