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
This commit is contained in:
parent
40576ae09c
commit
9750ab79c6
@ -25,6 +25,7 @@ from neutron.agent.linux import ip_lib
|
|||||||
from neutron.agent.linux import utils
|
from neutron.agent.linux import utils
|
||||||
from neutron.common import constants as n_const
|
from neutron.common import constants as n_const
|
||||||
from neutron.common import exceptions
|
from neutron.common import exceptions
|
||||||
|
from neutron.common import ipv6_utils
|
||||||
from neutron.i18n import _LE, _LI
|
from neutron.i18n import _LE, _LI
|
||||||
|
|
||||||
|
|
||||||
@ -51,6 +52,17 @@ class LinuxInterfaceDriver(object):
|
|||||||
|
|
||||||
def __init__(self, conf):
|
def __init__(self, conf):
|
||||||
self.conf = 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,
|
def init_l3(self, device_name, ip_cidrs, namespace=None,
|
||||||
preserve_ips=[], gateway_ips=None,
|
preserve_ips=[], gateway_ips=None,
|
||||||
|
@ -190,6 +190,7 @@ RPC_NAMESPACE_RESOURCES = None
|
|||||||
|
|
||||||
# Default network MTU value when not configured
|
# Default network MTU value when not configured
|
||||||
DEFAULT_NETWORK_MTU = 0
|
DEFAULT_NETWORK_MTU = 0
|
||||||
|
IPV6_MIN_MTU = 1280
|
||||||
|
|
||||||
ROUTER_MARK_MASK = "0xffff"
|
ROUTER_MARK_MASK = "0xffff"
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ class TestLoadInterfaceDriver(base.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestLoadInterfaceDriver, self).setUp()
|
super(TestLoadInterfaceDriver, self).setUp()
|
||||||
self.conf = config.setup_conf()
|
self.conf = config.setup_conf()
|
||||||
|
self.conf.register_opts(interface.OPTS)
|
||||||
config.register_interface_driver_opts_helper(self.conf)
|
config.register_interface_driver_opts_helper(self.conf)
|
||||||
|
|
||||||
def test_load_interface_driver_not_set(self):
|
def test_load_interface_driver_not_set(self):
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
import testtools
|
||||||
|
|
||||||
from neutron.agent.common import config
|
from neutron.agent.common import config
|
||||||
from neutron.agent.common import ovs_lib
|
from neutron.agent.common import ovs_lib
|
||||||
@ -335,6 +336,13 @@ class TestOVSInterfaceDriver(TestBase):
|
|||||||
self.conf.set_override('network_device_mtu', 9000)
|
self.conf.set_override('network_device_mtu', 9000)
|
||||||
self.assertEqual(self.conf.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):
|
def test_plug_mtu(self):
|
||||||
self.conf.set_override('network_device_mtu', 9000)
|
self.conf.set_override('network_device_mtu', 9000)
|
||||||
self._test_plug([mock.call().device().link.set_mtu(9000)])
|
self._test_plug([mock.call().device().link.set_mtu(9000)])
|
||||||
|
Loading…
Reference in New Issue
Block a user