Apply network MTU changes to dhcp ports
This patch makes DHCP agent to update its ports' MTU when it's changed on core plugin side. Related-Bug: #1671634 Change-Id: Ie1e1ca6a5f908c1e5669ddb3988d49c57da4b9c4
This commit is contained in:
parent
cc69828ff0
commit
9df067f12d
|
@ -1414,6 +1414,11 @@ class DeviceManager(object):
|
|||
if ip_lib.ensure_device_is_ready(interface_name,
|
||||
namespace=network.namespace):
|
||||
LOG.debug('Reusing existing device: %s.', interface_name)
|
||||
# force mtu on the port for in case it was changed for the network
|
||||
mtu = getattr(network, 'mtu', 0)
|
||||
if mtu:
|
||||
self.driver.set_mtu(interface_name, mtu,
|
||||
namespace=network.namespace)
|
||||
else:
|
||||
try:
|
||||
self.plug(network, port, interface_name)
|
||||
|
|
|
@ -30,11 +30,14 @@ OPTS = [
|
|||
]
|
||||
|
||||
|
||||
def _get_namespace_name(id_, suffix=None):
|
||||
suffix = suffix or cfg.CONF.test_namespace_suffix
|
||||
return "%s%s%s" % (linux_dhcp.NS_PREFIX, id_, suffix)
|
||||
|
||||
|
||||
def NetModel_init(self, d):
|
||||
super(linux_dhcp.NetModel, self).__init__(d)
|
||||
|
||||
self._ns_name = "%s%s%s" % (
|
||||
linux_dhcp.NS_PREFIX, self.id, cfg.CONF.test_namespace_suffix)
|
||||
self._ns_name = _get_namespace_name(self.id)
|
||||
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -17,8 +17,10 @@ import random
|
|||
from neutron_lib import constants
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.common import utils as common_utils
|
||||
from neutron.tests.fullstack import base
|
||||
from neutron.tests.fullstack.cmd import dhcp_agent as cmd
|
||||
from neutron.tests.fullstack.resources import environment
|
||||
from neutron.tests.fullstack.resources import machine
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
@ -99,6 +101,25 @@ class TestDhcpAgentNoHA(BaseDhcpAgentTest):
|
|||
# And check if IP and gateway config is fine on FakeMachine
|
||||
self.vm.block_until_dhcp_config_done()
|
||||
|
||||
def test_mtu_update(self):
|
||||
self.vm.block_until_dhcp_config_done()
|
||||
|
||||
namespace = cmd._get_namespace_name(
|
||||
self.network['id'],
|
||||
suffix=self.environment.hosts[0].dhcp_agent.get_namespace_suffix())
|
||||
ip = ip_lib.IPWrapper(namespace)
|
||||
|
||||
devices = ip.get_devices()
|
||||
self.assertEqual(1, len(devices))
|
||||
|
||||
dhcp_dev = devices[0]
|
||||
mtu = dhcp_dev.link.mtu
|
||||
self.assertEqual(1450, mtu)
|
||||
|
||||
mtu -= 1
|
||||
self.safe_client.update_network(self.network['id'], mtu=mtu)
|
||||
common_utils.wait_until_true(lambda: dhcp_dev.link.mtu == mtu)
|
||||
|
||||
|
||||
class TestDhcpAgentHA(BaseDhcpAgentTest):
|
||||
|
||||
|
|
Loading…
Reference in New Issue