]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix inconsistency in DHCPv6 hosts and options generation
authorAlexey I. Froloff <raorn@raorn.name>
Wed, 30 Sep 2015 18:38:24 +0000 (21:38 +0300)
committerAlexey I. Froloff <raorn@raorn.name>
Tue, 13 Oct 2015 11:48:12 +0000 (14:48 +0300)
The DHCP agent is inconsistent in how it handles subnets whose
ipv6_address_mode is not slaac.  While the DHCP agent writes out both
DHCPv6 host entries and DHCPv6 options for ports scoped by the subnet
for dnsmasq to use, subnet specific options are not written.

This patch addresses this inconsistency by generating subnet specific
options when the subnet's ipv6_address_mode is not slaac.

Closes-Bug: #1501451

Change-Id: I372c93fa5667e955c7b81181daa2e66f47d85fdf

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

index 279d2ca7bed33f729075e45246eb363e26c6624d..2f3c87b6dd1be4dd20eaa0d10dbcb5c50b081f01 100644 (file)
@@ -756,10 +756,10 @@ class Dnsmasq(DhcpLocalProcess):
             subnet_to_interface_ip = self._make_subnet_interface_ip_map()
         isolated_subnets = self.get_isolated_subnets(self.network)
         for i, subnet in enumerate(self.network.subnets):
+            addr_mode = getattr(subnet, 'ipv6_address_mode', None)
             if (not subnet.enable_dhcp or
                 (subnet.ip_version == 6 and
-                 getattr(subnet, 'ipv6_address_mode', None)
-                 in [None, constants.IPV6_SLAAC])):
+                 addr_mode == constants.IPV6_SLAAC)):
                 continue
             if subnet.dns_nameservers:
                 options.append(
index 847d7a04f1ea4eb13c8a779433ab47ca57786f6e..3f29ca60c38dc37184374a740ff2c9b9874fb402 100644 (file)
@@ -1475,6 +1475,15 @@ class TestDnsmasq(TestBase):
 
         self.safe.assert_called_once_with('/foo/opts', expected)
 
+    def test_output_opts_file_ipv6_address_mode_unset(self):
+        fake_v6 = '2001:0200:feed:7ac0::1'
+        expected = (
+            'tag:tag0,option6:dns-server,%s\n'
+            'tag:tag0,option6:domain-search,openstacklocal').lstrip() % (
+                '[' + fake_v6 + ']')
+
+        self._test_output_opts_file(expected, FakeV6Network())
+
     @property
     def _test_no_dhcp_domain_alloc_data(self):
         exp_host_name = '/dhcp/cccccccc-cccc-cccc-cccc-cccccccccccc/host'