From 78708835d045b0d7aacf3dfde0784fe3d6467878 Mon Sep 17 00:00:00 2001
From: Julia Kreger <juliaashleykreger@gmail.com>
Date: Sun, 2 Dec 2018 08:08:32 -0800
Subject: [PATCH] Fix IPv6 Option Passing

Turns out that adding option6 was incorrect... and neutron
does it incorrectly as well. Removing from ironic, as neutron
does the completely wrong thing when a field number is used with
dnsmasq and ipv6.

Change-Id: Icf88419925abb9b9f10f31aa3a66daea5afe3bb4
Related-Change: I87c15908087111367358043f7a63dd02dd9d16ac
Task: 28218
Story: 2004501
---
 ironic/common/pxe_utils.py                       | 12 +++++++-----
 ironic/tests/unit/common/test_pxe_utils.py       |  6 +++---
 .../fix-ipv6-option6-tag-549093681dcf940c.yaml   | 16 ++++++++++++++++
 3 files changed, 26 insertions(+), 8 deletions(-)
 create mode 100644 releasenotes/notes/fix-ipv6-option6-tag-549093681dcf940c.yaml

diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py
index 55e602a2cd..ad34f43056 100644
--- a/ironic/common/pxe_utils.py
+++ b/ironic/common/pxe_utils.py
@@ -441,11 +441,7 @@ def dhcp_options_for_instance(task, ipxe_enabled=False, url_boot=False):
     else:
         # NOTE(TheJulia): Booting with v6 means it is always
         # a URL reply.
-        if dhcp_provider_name == 'neutron':
-            # dnsmasq requires ipv6 options be explicitly flagged. :(
-            boot_file_param = "option6:{}".format(DHCPV6_BOOTFILE_NAME)
-        else:
-            boot_file_param = DHCPV6_BOOTFILE_NAME
+        boot_file_param = DHCPV6_BOOTFILE_NAME
         url_boot = True
     # NOTE(TheJulia): The ip_version value config from the PXE config is
     # guarded in the configuration, so there is no real sense in having
@@ -454,6 +450,12 @@ def dhcp_options_for_instance(task, ipxe_enabled=False, url_boot=False):
     boot_file = _dhcp_option_file_or_url(task, url_boot)
 
     if ipxe_enabled:
+        # TODO(TheJulia): DHCPv6 through dnsmasq + ipxe matching simply
+        # does not work as the dhcp client is tracked via a different
+        # identity mechanism in the exchange. This means if we really
+        # want ipv6 + ipxe, we should be prepared to build a custom
+        # iso with ipxe inside. Likely this is more secure and better
+        # aligns with some of the mega-scale ironic operators.
         script_name = os.path.basename(CONF.pxe.ipxe_boot_script)
         # TODO(TheJulia): We should make this smarter to handle unwrapped v6
         # addresses, since the format is http://[ff80::1]:80/boot.ipxe.
diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py
index 12a80edabd..5d99f06105 100644
--- a/ironic/tests/unit/common/test_pxe_utils.py
+++ b/ironic/tests/unit/common/test_pxe_utils.py
@@ -728,7 +728,7 @@ class TestPXEUtils(db_base.DbTestCase):
             # options are not imported, although they may be supported
             # by vendors. The apparent proper option is to return a
             # URL in the field https://tools.ietf.org/html/rfc5970#section-3
-            expected_info = [{'opt_name': 'option6:59',
+            expected_info = [{'opt_name': '59',
                               'opt_value': 'tftp://[ff80::1]/fake-bootfile',
                               'ip_version': ip_version}]
         elif ip_version == 4:
@@ -857,10 +857,10 @@ class TestPXEUtils(db_base.DbTestCase):
         self.config(dhcp_provider='neutron', group='dhcp')
         if ip_version == 6:
             # Boot URL variable set from prior test of isc parameters.
-            expected_info = [{'opt_name': 'tag:!ipxe,option6:59',
+            expected_info = [{'opt_name': 'tag:!ipxe,59',
                               'opt_value': 'tftp://[ff80::1]/fake-bootfile',
                               'ip_version': ip_version},
-                             {'opt_name': 'tag:ipxe,option6:59',
+                             {'opt_name': 'tag:ipxe,59',
                               'opt_value': expected_boot_script_url,
                               'ip_version': ip_version}]
         elif ip_version == 4:
diff --git a/releasenotes/notes/fix-ipv6-option6-tag-549093681dcf940c.yaml b/releasenotes/notes/fix-ipv6-option6-tag-549093681dcf940c.yaml
new file mode 100644
index 0000000000..4b59c614da
--- /dev/null
+++ b/releasenotes/notes/fix-ipv6-option6-tag-549093681dcf940c.yaml
@@ -0,0 +1,16 @@
+---
+issues:
+  - |
+    Support for IPv6 and iPXE is restricted and is unlikely to work in default
+    scenarios and configurations without external intervention. This is due to
+    the way DHCPv6 and dnsmasq operate. At present this issue is being tracked
+    in story `2005402 <https://storyboard.openstack.org/#!/story/2004502>`_.
+fixes:
+  - |
+    Fixes an issue introduced during the Stein development cycle in an attempt
+    to fix IPv6 support where the networking service was also prepending the
+    DHCP option indicator to the number. A fix has been been submitted to the
+    Networking service to address this issue, and the prepending code has been
+    removed from ironic. See story
+    `2004501 <https://storyboard.openstack.org/#!/story/2004501>`_ for more
+    information.