[PATCH] ifcfg-rh: deal with weird ifcfg properly



Dracut when faced with an ipv6 only setup during kickstart will generate a ifcfg
file that sets the ipv4 address things to null but sets BOOTPROTO=static.  This
makes network manager screw up because it expects an ipv4 address to be set.
Instead deal with this case by checking if we have any ipv4 addrs set, and if
not just disable ipv4.  This fixes our inability to kickstart in our ipv6 only
clusters.  Thanks,

Signed-off-by: Josef Bacik <jbacik fb com>
---
 src/settings/plugins/ifcfg-rh/reader.c                   |  5 ++++-
 .../tests/network-scripts/ifcfg-test-wired-ipv6-only-1   | 16 ++++++++++++++++
 src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c      | 11 ++++++-----
 3 files changed, 26 insertions(+), 6 deletions(-)
 create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv6-only-1

diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
index 215b2d5..564ed12 100644
--- a/src/settings/plugins/ifcfg-rh/reader.c
+++ b/src/settings/plugins/ifcfg-rh/reader.c
@@ -956,7 +956,10 @@ make_ip4_setting (shvarFile *ifcfg,
        } else if (!g_ascii_strcasecmp (value, "bootp") || !g_ascii_strcasecmp (value, "dhcp")) {
                method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
        } else if (!g_ascii_strcasecmp (value, "static")) {
-               method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
+               if (is_any_ip4_address_defined (ifcfg, NULL))
+                       method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
+               else
+                       method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
        } else if (!g_ascii_strcasecmp (value, "autoip")) {
                g_free (value);
                g_object_set (s_ip4,
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv6-only-1 
b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv6-only-1
new file mode 100644
index 0000000..95f8a8e
--- /dev/null
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv6-only-1
@@ -0,0 +1,16 @@
+IPADDR=
+GATEWAY=
+NETMASK=
+BOOTPROTO=static
+TYPE=Ethernet
+DEVICE=eth2
+HWADDR=00:11:22:33:44:ee
+ONBOOT=yes
+USERCTL=yes
+NM_CONTROLLED=yes
+PEERDNS=yes
+DNS1=1:2:3:4::a
+DOMAIN="lorem.com ipsum.org dolor.edu"
+IPV6INIT=yes
+IPV6_AUTOCONF=no
+IPV6ADDR="1001:abba::1234/56"
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c 
b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index 8f7bb16..2e8b68f 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -1685,9 +1685,10 @@ test_read_wired_ipv6_manual (void)
 }
 
 #define TEST_IFCFG_WIRED_IPV6_ONLY TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv6-only"
+#define TEST_IFCFG_WIRED_IPV6_ONLY_1 TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv6-only-1"
 
 static void
-test_read_wired_ipv6_only (void)
+test_read_wired_ipv6_only (const char *file, const char *expected_id)
 {
        NMConnection *connection;
        NMSettingConnection *s_con;
@@ -1697,17 +1698,16 @@ test_read_wired_ipv6_only (void)
        char *unmanaged = NULL;
        GError *error = NULL;
        const char *tmp;
-       const char *expected_id = "System test-wired-ipv6-only";
        NMIPAddress *ip6_addr;
        const char *method;
 
-       connection = connection_from_file_test (TEST_IFCFG_WIRED_IPV6_ONLY,
+       connection = connection_from_file_test (file,
                                                NULL,
                                                TYPE_ETHERNET,
                                                &unmanaged,
                                                &error);
        ASSERT (connection != NULL,
-               "wired-ipv6-only-read", "failed to read %s: %s", TEST_IFCFG_WIRED_IPV6_ONLY, error->message);
+               "wired-ipv6-only-read", "failed to read %s: %s", file, error->message);
 
        ASSERT (nm_connection_verify (connection, &error),
                "wired-ipv6-only-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_IPV6_ONLY, 
error->message);
@@ -12914,7 +12914,8 @@ int main (int argc, char **argv)
        test_read_wired_ipv4_manual (TEST_IFCFG_WIRED_IPV4_MANUAL_3, "System test-wired-ipv4-manual-3");
        test_read_wired_ipv4_manual (TEST_IFCFG_WIRED_IPV4_MANUAL_4, "System test-wired-ipv4-manual-4");
        test_read_wired_ipv6_manual ();
-       test_read_wired_ipv6_only ();
+       test_read_wired_ipv6_only (TEST_IFCFG_WIRED_IPV6_ONLY, "System test-wired-ipv6-only");
+       test_read_wired_ipv6_only (TEST_IFCFG_WIRED_IPV6_ONLY_1, "System test-wired-ipv6-only-1");
        test_read_wired_dhcp6_only ();
        test_read_onboot_no ();
        test_read_noip ();
-- 
2.1.0



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]