diff --git a/neutron/agent/linux/interface.py b/neutron/agent/linux/interface.py index 9207503e7ac..ebebb00d0a6 100644 --- a/neutron/agent/linux/interface.py +++ b/neutron/agent/linux/interface.py @@ -25,6 +25,7 @@ from neutron.agent.linux import ip_lib from neutron.agent.linux import utils from neutron.common import constants as n_const from neutron.common import exceptions +from neutron.common import ipv6_utils from neutron.i18n import _LE, _LI @@ -51,6 +52,17 @@ class LinuxInterfaceDriver(object): def __init__(self, conf): self.conf = conf + if self.conf.network_device_mtu: + self._validate_network_device_mtu() + + def _validate_network_device_mtu(self): + if (ipv6_utils.is_enabled() and + self.conf.network_device_mtu < n_const.IPV6_MIN_MTU): + LOG.error(_LE("IPv6 protocol requires a minimum MTU of " + "%(min_mtu)s, while the configured value is " + "%(current_mtu)s"), {'min_mtu': n_const.IPV6_MIN_MTU, + 'current_mtu': self.conf.network_device_mtu}) + raise SystemExit(1) def init_l3(self, device_name, ip_cidrs, namespace=None, preserve_ips=[], gateway_ips=None, diff --git a/neutron/common/constants.py b/neutron/common/constants.py index e9424b2378b..acea508f09b 100644 --- a/neutron/common/constants.py +++ b/neutron/common/constants.py @@ -190,6 +190,7 @@ RPC_NAMESPACE_RESOURCES = None # Default network MTU value when not configured DEFAULT_NETWORK_MTU = 0 +IPV6_MIN_MTU = 1280 ROUTER_MARK_MASK = "0xffff" diff --git a/neutron/tests/unit/agent/common/test_utils.py b/neutron/tests/unit/agent/common/test_utils.py index 7c89b1e2b5e..a4cf6680204 100644 --- a/neutron/tests/unit/agent/common/test_utils.py +++ b/neutron/tests/unit/agent/common/test_utils.py @@ -27,6 +27,7 @@ class TestLoadInterfaceDriver(base.BaseTestCase): def setUp(self): super(TestLoadInterfaceDriver, self).setUp() self.conf = config.setup_conf() + self.conf.register_opts(interface.OPTS) config.register_interface_driver_opts_helper(self.conf) def test_load_interface_driver_not_set(self): diff --git a/neutron/tests/unit/agent/linux/test_interface.py b/neutron/tests/unit/agent/linux/test_interface.py index a46354a1a5c..3bd6b0ceb94 100644 --- a/neutron/tests/unit/agent/linux/test_interface.py +++ b/neutron/tests/unit/agent/linux/test_interface.py @@ -15,6 +15,7 @@ import mock from oslo_utils import uuidutils +import testtools from neutron.agent.common import config from neutron.agent.common import ovs_lib @@ -335,6 +336,13 @@ class TestOVSInterfaceDriver(TestBase): self.conf.set_override('network_device_mtu', 9000) self.assertEqual(self.conf.network_device_mtu, 9000) + def test_validate_min_ipv6_mtu(self): + self.conf.set_override('network_device_mtu', 1200) + with mock.patch('neutron.common.ipv6_utils.is_enabled') as ipv6_status: + with testtools.ExpectedException(SystemExit): + ipv6_status.return_value = True + BaseChild(self.conf) + def test_plug_mtu(self): self.conf.set_override('network_device_mtu', 9000) self._test_plug([mock.call().device().link.set_mtu(9000)])