]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Advertise mtu over dhcp
authorBradley Jones <jones.bradley@me.com>
Thu, 12 Feb 2015 11:51:18 +0000 (03:51 -0800)
committerBradley Jones <jones.bradley@me.com>
Tue, 17 Mar 2015 18:06:40 +0000 (18:06 +0000)
If advertise_mtu option is set in the config then set the dnsmasq config option
to advertise the mtu

Partially Implements: blueprint mtu-selection-and-advertisement

Change-Id: I5f3d4276fe36dfd89d242e9afe2d46e9cc7a8a28

neutron/agent/linux/dhcp.py
neutron/tests/unit/test_linux_dhcp.py

index 53752a8a319e2f5aa57f225f47520928647efbbc..99b42099b7d89cae51d4bb493b56ce8fbff55bdc 100644 (file)
@@ -20,6 +20,7 @@ import re
 import shutil
 
 import netaddr
+from oslo_config import cfg
 from oslo_log import log as logging
 from oslo_utils import importutils
 import six
@@ -349,6 +350,12 @@ class Dnsmasq(DhcpLocalProcess):
                                 cidr.prefixlen, lease))
                 possible_leases += cidr.size
 
+        if cfg.CONF.advertise_mtu:
+            mtu = self.network.mtu
+            # Do not advertise unknown mtu
+            if mtu > 0:
+                cmd.append('--dhcp-option-force=option:mtu,%d' % mtu)
+
         # Cap the limit because creating lots of subnets can inflate
         # this possible lease cap.
         cmd.append('--dhcp-lease-max=%d' %
index e4f943b9b6fcd1c8f6be0ba32db1292068990b0a..2647bd8bca7aa5502f4f4d22f31a1329b364d823 100644 (file)
@@ -860,6 +860,9 @@ class TestDnsmasq(TestBase):
                         lease_duration, seconds)])
                 possible_leases += netaddr.IPNetwork(s.cidr).size
 
+        if cfg.CONF.advertise_mtu:
+            expected.append('--dhcp-option-force=option:mtu,%s' % network.mtu)
+
         expected.append('--dhcp-lease-max=%d' % min(
             possible_leases, max_leases))
         expected.extend(extra_options)
@@ -946,6 +949,13 @@ class TestDnsmasq(TestBase):
         self._test_spawn(['--conf-file=', '--domain=openstacklocal',
                           '--dhcp-broadcast'])
 
+    def test_spawn_cfg_advertise_mtu(self):
+        cfg.CONF.set_override('advertise_mtu', True)
+        network = FakeV4Network()
+        network.mtu = 1500
+        self._test_spawn(['--conf-file=', '--domain=openstacklocal'],
+                         network)
+
     def _test_output_opts_file(self, expected, network, ipm_retval=None):
         with mock.patch.object(dhcp.Dnsmasq, 'get_conf_file_name') as conf_fn:
             conf_fn.return_value = '/foo/opts'