Merge "IPv6 display suitable message when MTU is invalid on iface"
This commit is contained in:
commit
cc49b7d7d9
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
@ -414,6 +415,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)])
|
||||
|
|
Loading…
Reference in New Issue