- ci-net-fix-ipv6_dhcpv6_stateful-stateless-slaac-configu.patch [bz#2046491] - Resolves: bz#2046491 (cloud-init enable both DHCPv4 and DHCPv6 when network type is ipv6_dhcpv6-stateful/ipv6_dhcpv6-stateless) - Resolves: RHEL-2325 ([RHEL8.9][cloud-init] Not inform user during upgrade that cloud-init generated config files are left )
132 lines
4.7 KiB
Diff
132 lines
4.7 KiB
Diff
From 293b0716532127a7a4e8923870adcffe2480347e Mon Sep 17 00:00:00 2001
|
|
From: Ani Sinha <anisinha@redhat.com>
|
|
Date: Thu, 7 Sep 2023 02:36:52 +0530
|
|
Subject: [PATCH 1/2] net: fix ipv6_dhcpv6_stateful/stateless/slaac
|
|
configuration for rhel (#4395)
|
|
|
|
RH-Author: Ani Sinha <None>
|
|
RH-MergeRequest: 109: net: fix ipv6_dhcpv6_stateful/stateless/slaac configuration for rhel (#4395)
|
|
RH-Bugzilla: 2046491
|
|
RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
|
|
RH-Commit: [1/1] e1774cc44c166bc94901c04fd5dabda006357f5e (anisinha/rhel-cloud-init)
|
|
|
|
When network type is ipv6_dhcpv6-stateful/stateless/slaac, cloud-init seems to
|
|
enable dhcp for both ipv4 and ipv6. Network manager prefers dhcp over ipv4 and
|
|
hence dhcp6 is not used to obtain the IP address. This is incorrect.
|
|
For only ipv6_dhcpv6-stateful/stateless/slaac networks, we should set:
|
|
|
|
ipv4.method = disabled // disables all ipv4 dhcp
|
|
|
|
For ifcfg files (sysconfig renderer), the corresponding changes should be:
|
|
BOOTPROTO = none // instead of dhcp so that dhcp4 is disabled.
|
|
|
|
Additionally, for only ipv6_dhcpv6_stateful, we should set:
|
|
ipv6.may-fail = no // dhcp6 must succeed.
|
|
|
|
which translates to the following ifcfg setting:
|
|
IPV6_FAILURE_FATAL = yes // so that dhcp6 should succeed.
|
|
|
|
This patch fixes this for rhel. The patch has been tested by Red Hat QE.
|
|
|
|
RHBZ: 2046491
|
|
fixes: f550c8765ca03d3 ("Adding BOOTPROTO = dhcp to render sysconfig dhcp6 stateful on RHEL (#685)")
|
|
|
|
Signed-off-by: Ani Sinha <anisinha@redhat.com>
|
|
(cherry picked from commit fd214a1243011275c5dffb92b481c235e4c7a1bf)
|
|
---
|
|
cloudinit/net/network_manager.py | 9 +++++++++
|
|
cloudinit/net/sysconfig.py | 6 +++---
|
|
tests/unittests/test_net.py | 9 ++++++++-
|
|
3 files changed, 20 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/cloudinit/net/network_manager.py b/cloudinit/net/network_manager.py
|
|
index 8047f796..7a32691e 100644
|
|
--- a/cloudinit/net/network_manager.py
|
|
+++ b/cloudinit/net/network_manager.py
|
|
@@ -105,6 +105,14 @@ class NMConnection:
|
|
if self.config[family]["method"] == "auto" and method == "manual":
|
|
return
|
|
|
|
+ if (
|
|
+ subnet_type == "ipv6_dhcpv6-stateful"
|
|
+ or subnet_type == "ipv6_dhcpv6-stateless"
|
|
+ or subnet_type == "ipv6_slaac"
|
|
+ ):
|
|
+ # set ipv4 method to 'disabled' to align with sysconfig renderer.
|
|
+ self._set_default("ipv4", "method", "disabled")
|
|
+
|
|
self.config[family]["method"] = method
|
|
self._set_default(family, "may-fail", "false")
|
|
|
|
@@ -342,6 +350,7 @@ class Renderer(renderer.Renderer):
|
|
|
|
def __init__(self, config=None):
|
|
self.connections = {}
|
|
+ self.config = config
|
|
|
|
def get_conn(self, con_id):
|
|
return self.connections[con_id]
|
|
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
|
|
index 421564ee..6385ff78 100644
|
|
--- a/cloudinit/net/sysconfig.py
|
|
+++ b/cloudinit/net/sysconfig.py
|
|
@@ -435,13 +435,13 @@ class Renderer(renderer.Renderer):
|
|
iface_cfg["BOOTPROTO"] = "dhcp6"
|
|
iface_cfg["DHCLIENT6_MODE"] = "managed"
|
|
# only if rhel AND dhcpv6 stateful
|
|
- elif (
|
|
- flavor == "rhel" and subnet_type == "ipv6_dhcpv6-stateful"
|
|
+ elif flavor == "rhel" and (
|
|
+ subnet_type == "ipv6_dhcpv6-stateful"
|
|
):
|
|
- iface_cfg["BOOTPROTO"] = "dhcp"
|
|
iface_cfg["DHCPV6C"] = True
|
|
iface_cfg["IPV6INIT"] = True
|
|
iface_cfg["IPV6_AUTOCONF"] = False
|
|
+ iface_cfg["IPV6_FAILURE_FATAL"] = True
|
|
else:
|
|
iface_cfg["IPV6INIT"] = True
|
|
# Configure network settings using DHCPv6
|
|
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
|
|
index aa4098b8..12b70587 100644
|
|
--- a/tests/unittests/test_net.py
|
|
+++ b/tests/unittests/test_net.py
|
|
@@ -1750,6 +1750,9 @@ NETWORK_CONFIGS = {
|
|
method=auto
|
|
may-fail=false
|
|
|
|
+ [ipv4]
|
|
+ method=disabled
|
|
+
|
|
"""
|
|
),
|
|
},
|
|
@@ -1860,6 +1863,9 @@ NETWORK_CONFIGS = {
|
|
method=auto
|
|
may-fail=false
|
|
|
|
+ [ipv4]
|
|
+ method=disabled
|
|
+
|
|
"""
|
|
),
|
|
},
|
|
@@ -1907,11 +1913,12 @@ NETWORK_CONFIGS = {
|
|
"expected_sysconfig_rhel": {
|
|
"ifcfg-iface0": textwrap.dedent(
|
|
"""\
|
|
- BOOTPROTO=dhcp
|
|
+ BOOTPROTO=none
|
|
DEVICE=iface0
|
|
DHCPV6C=yes
|
|
IPV6INIT=yes
|
|
IPV6_AUTOCONF=no
|
|
+ IPV6_FAILURE_FATAL=yes
|
|
IPV6_FORCE_ACCEPT_RA=yes
|
|
DEVICE=iface0
|
|
ONBOOT=yes
|
|
--
|
|
2.41.0
|
|
|