From 9750ab79c67f0f5b24cbbb9b7f2c499d4b911283 Mon Sep 17 00:00:00 2001 From: sridhargaddam Date: Mon, 3 Aug 2015 11:16:37 +0000 Subject: [PATCH] IPv6 display suitable message when MTU is invalid on iface IPv6 protocol requires a minimum MTU of 1280 bytes on the interface to configure an IPv6 address to the interface. This patch logs an appropriate error message and exits the agent if ipv6 is enabled and network_device_mtu is less than the minimum value. DocImpact Closes-Bug: #1475015 Change-Id: I13666de4e6f5f6775ad26342e513c3c17a003b8e --- neutron/agent/linux/interface.py | 12 ++++++++++++ neutron/common/constants.py | 1 + neutron/tests/unit/agent/common/test_utils.py | 1 + neutron/tests/unit/agent/linux/test_interface.py | 8 ++++++++ 4 files changed, 22 insertions(+) diff --git a/neutron/agent/linux/interface.py b/neutron/agent/linux/interface.py index 9207503e7..ebebb00d0 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 e9424b237..acea508f0 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 7c89b1e2b..a4cf66802 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 a46354a1a..3bd6b0ceb 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)]) -- 2.45.2