]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
IPv6 display suitable message when MTU is invalid on iface
authorsridhargaddam <sridhar.gaddam@enovance.com>
Mon, 3 Aug 2015 11:16:37 +0000 (11:16 +0000)
committersridhargaddam <sridhar.gaddam@enovance.com>
Fri, 21 Aug 2015 07:09:18 +0000 (07:09 +0000)
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
neutron/common/constants.py
neutron/tests/unit/agent/common/test_utils.py
neutron/tests/unit/agent/linux/test_interface.py

index 9207503e7ac4dfcd79038d88f9d109b20747ac7b..ebebb00d0a67a4855794cd229db8ee80e45eacfb 100644 (file)
@@ -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,
index e9424b2378b477b1394e10605a36db6b303b41fe..acea508f09b6e6ea8ee87e98e0f63ded27d02e50 100644 (file)
@@ -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"
 
index 7c89b1e2b5e9bbb3e053a98127a2de0990f0a1c9..a4cf66802043948df9eb284235ddd027b1d503f5 100644 (file)
@@ -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):
index a46354a1a5c3ce935b37b41e24043ec35f4189cb..3bd6b0ceb94c04aa4c31ae2100d69f91135253bb 100644 (file)
@@ -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)])