From 81c5e511f704861a08f2e3938edca97474d4c44c Mon Sep 17 00:00:00 2001 From: "Alexey I. Froloff" Date: Wed, 30 Sep 2015 21:38:24 +0300 Subject: [PATCH] Fix inconsistency in DHCPv6 hosts and options generation 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 | 4 ++-- neutron/tests/unit/agent/linux/test_dhcp.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index 279d2ca7b..2f3c87b6d 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -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( diff --git a/neutron/tests/unit/agent/linux/test_dhcp.py b/neutron/tests/unit/agent/linux/test_dhcp.py index 847d7a04f..3f29ca60c 100644 --- a/neutron/tests/unit/agent/linux/test_dhcp.py +++ b/neutron/tests/unit/agent/linux/test_dhcp.py @@ -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' -- 2.45.2