[NetworkManager/f18] ifcfg-rh: write missing IPv6 setting as IPv6 with "auto" method (rh #830434)

Jirka Klimes jklimes at fedoraproject.org
Tue Dec 18 11:05:14 UTC 2012


commit 85245504b150d0786d69a146526aeec133dc0c2f
Author: Jiří Klimeš <jklimes at redhat.com>
Date:   Tue Dec 18 11:53:57 2012 +0100

    ifcfg-rh: write missing IPv6 setting as IPv6 with "auto" method (rh #830434)

 NetworkManager.spec               |    8 ++-
 rh830434-ifcfg-missing-ipv6.patch |  192 +++++++++++++++++++++++++++++++++++++
 2 files changed, 199 insertions(+), 1 deletions(-)
---
diff --git a/NetworkManager.spec b/NetworkManager.spec
index 6455484..59980e5 100644
--- a/NetworkManager.spec
+++ b/NetworkManager.spec
@@ -19,7 +19,7 @@ Name: NetworkManager
 Summary: Network connection manager and user applications
 Epoch: 1
 Version: 0.9.7.0
-Release: 10%{snapshot}%{?dist}
+Release: 11%{snapshot}%{?dist}
 Group: System Environment/Base
 License: GPLv2+
 URL: http://www.gnome.org/projects/NetworkManager/
@@ -33,6 +33,8 @@ Patch4: gvaluearray-crash.patch
 Patch5: udev-uninitialized-devices.patch
 Patch6: rh875085-set-hostname.patch
 Patch7: rh831735-etc-hostname.patch
+Patch8: rh830434-ifcfg-missing-ipv6.patch
+
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 Requires(post): chkconfig
@@ -162,6 +164,7 @@ NetworkManager functionality from applications that use glib.
 %patch5 -p1 -b .udev-uninitialized
 %patch6 -p1 -b .set-hostname
 %patch7 -p1 -b .etc-hostname
+%patch8 -p1 -b .ifcfg-missing-ipv6
 
 %build
 
@@ -365,6 +368,9 @@ exit 0
 %{_datadir}/gtk-doc/html/libnm-util/*
 
 %changelog
+* Tue Dec 18 2012 Jiří Klimeš <jklimes at redhat.com> - 0.9.7.0-11.git20121004
+- ifcfg-rh: write missing IPv6 setting as IPv6 with "auto" method (rh #830434)
+
 * Wed Dec  5 2012 Dan Winship <danw at redhat.com> - 0.9.7.0-10.git20121004
 - Build vapi files and add them to the devel package
 
diff --git a/rh830434-ifcfg-missing-ipv6.patch b/rh830434-ifcfg-missing-ipv6.patch
new file mode 100644
index 0000000..f3ea08c
--- /dev/null
+++ b/rh830434-ifcfg-missing-ipv6.patch
@@ -0,0 +1,192 @@
+From 954ce65e9968be45378b4f81f05387eac847b33f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes at redhat.com>
+Date: Mon, 17 Dec 2012 16:33:02 +0100
+Subject: [PATCH] ifcfg-rh: treat missing IPv6 setting as IPv6 "auto" method
+ (rh #830434)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+
+Signed-off-by: Jiří Klimeš <jklimes at redhat.com>
+---
+ .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c         | 119 +++++++++++++++++++++
+ src/settings/plugins/ifcfg-rh/writer.c             |  18 ++--
+ 2 files changed, 130 insertions(+), 7 deletions(-)
+
+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 2b8df27..fcad170 100644
+--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
++++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+@@ -12508,6 +12508,124 @@ test_write_vlan_only_vlanid (void)
+ 	g_object_unref (reread);
+ }
+ 
++static void
++test_write_ethernet_missing_ipv6 (void)
++{
++	NMConnection *connection;
++	NMConnection *reread;
++	NMSettingConnection *s_con;
++	NMSettingWired *s_wired;
++	NMSettingIP4Config *s_ip4;
++	NMSettingIP6Config *s_ip6;
++	char *uuid;
++	gboolean success;
++	GError *error = NULL;
++	char *testfile = NULL;
++	char *unmanaged = NULL;
++	char *keyfile = NULL;
++	char *routefile = NULL;
++	char *route6file = NULL;
++	gboolean ignore_error = FALSE;
++
++	connection = nm_connection_new ();
++	g_assert (connection);
++
++	/* Connection setting */
++	s_con = (NMSettingConnection *) nm_setting_connection_new ();
++	g_assert (s_con);
++	nm_connection_add_setting (connection, NM_SETTING (s_con));
++
++	uuid = nm_utils_uuid_generate ();
++	g_object_set (s_con,
++	              NM_SETTING_CONNECTION_ID, "Test Write Ethernet Without IPv6 Setting",
++	              NM_SETTING_CONNECTION_UUID, uuid,
++	              NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
++	              NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
++	              NULL);
++	g_free (uuid);
++
++	/* Wired setting */
++	s_wired = (NMSettingWired *) nm_setting_wired_new ();
++	g_assert (s_wired);
++	nm_connection_add_setting (connection, NM_SETTING (s_wired));
++
++	/* IP4 setting */
++	s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
++	g_assert (s_ip4);
++	nm_connection_add_setting (connection, NM_SETTING (s_ip4));
++	g_object_set (s_ip4,
++	              NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
++	              NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, "random-client-id-00:22:33",
++	              NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, TRUE,
++	              NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, TRUE,
++	              NULL);
++
++	/* IP6 setting */
++	/*
++	 * We intentionally don't add IPv6 setting here. ifcfg-rh plugin should regard
++	 * missing IPv6 as IPv6 with NM_SETTING_IP6_CONFIG_METHOD_AUTO method.
++	 */
++
++	ASSERT (nm_connection_verify (connection, &error) == TRUE,
++	        "ethernet-missing-ipv6", "failed to verify connection: %s",
++	        (error && error->message) ? error->message : "(unknown)");
++
++	/* Save the ifcfg */
++	success = writer_new_connection (connection,
++	                                 TEST_SCRATCH_DIR "/network-scripts/",
++	                                 &testfile,
++	                                 &error);
++	ASSERT (success == TRUE,
++	        "ethernet-missing-ipv6", "failed to write connection to disk: %s",
++	        (error && error->message) ? error->message : "(unknown)");
++
++	ASSERT (testfile != NULL,
++	        "ethernet-missing-ipv6", "didn't get ifcfg file path back after writing connection");
++
++	/* re-read the connection for comparison */
++	reread = connection_from_file (testfile,
++	                               NULL,
++	                               TYPE_ETHERNET,
++	                               NULL,
++	                               &unmanaged,
++	                               &keyfile,
++	                               &routefile,
++	                               &route6file,
++	                               &error,
++	                               &ignore_error);
++	unlink (testfile);
++
++	ASSERT (reread != NULL,
++	        "ethernet-missing-ipv6-reread", "failed to read %s: %s", testfile, error->message);
++
++	ASSERT (nm_connection_verify (reread, &error),
++	        "ethernet-missing-ipv6-reread-verify", "failed to verify %s: %s", testfile, error->message);
++
++	/*
++	 * We need to add IPv6 setting to the original connection now so that
++	 * the comparison can succeed. Missing IPv6 setting should have been
++	 * written out (and re-read) as Automatic IPv6.
++	 */
++	s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
++	g_assert (s_ip6);
++	nm_connection_add_setting (connection, NM_SETTING (s_ip6));
++	g_object_set (s_ip6,
++	              NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
++	              NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE,
++	              NULL);
++
++	ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
++	        "ethernet-missing-ipv6", "written and re-read connection weren't the same.");
++
++	g_free (testfile);
++	g_free (unmanaged);
++	g_free (keyfile);
++	g_free (routefile);
++	g_free (route6file);
++	g_object_unref (connection);
++	g_object_unref (reread);
++}
++
+ #define TEST_IFCFG_BOND_MAIN TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bond-main"
+ 
+ static void
+@@ -13403,6 +13521,7 @@ int main (int argc, char **argv)
+ 	test_write_infiniband ();
+ 	test_write_vlan ();
+ 	test_write_vlan_only_vlanid ();
++	test_write_ethernet_missing_ipv6 ();
+ 
+ 	/* iSCSI / ibft */
+ 	test_read_ibft_dhcp ();
+diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c
+index f0ee023..e258081 100644
+--- a/src/settings/plugins/ifcfg-rh/writer.c
++++ b/src/settings/plugins/ifcfg-rh/writer.c
+@@ -1897,9 +1897,15 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
+ 
+ 	s_ip6 = nm_connection_get_setting_ip6_config (connection);
+ 	if (!s_ip6) {
+-		g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+-		             "Missing '%s' setting", NM_SETTING_IP6_CONFIG_SETTING_NAME);
+-		return FALSE;
++		/* Treat missing IPv6 setting as a setting with method "auto" */
++		svSetValue (ifcfg, "IPV6INIT", "yes", FALSE);
++		svSetValue (ifcfg, "IPV6_AUTOCONF", "yes", FALSE);
++		svSetValue (ifcfg, "DHCPV6C", NULL, FALSE);
++		svSetValue (ifcfg, "IPV6_DEFROUTE", "yes", FALSE);
++		svSetValue (ifcfg, "IPV6_PEERDNS", "yes", FALSE);
++		svSetValue (ifcfg, "IPV6_PEERROUTES", "yes", FALSE);
++		svSetValue (ifcfg, "IPV6_FAILURE_FATAL", "no", FALSE);
++		return TRUE;
+ 	}
+ 
+ 	value = nm_setting_ip6_config_get_method (s_ip6);
+@@ -2210,10 +2216,8 @@ write_connection (NMConnection *connection,
+ 		if (!write_ip4_setting (connection, ifcfg, error))
+ 			goto out;
+ 
+-		if (nm_connection_get_setting_ip6_config (connection)) {
+-			if (!write_ip6_setting (connection, ifcfg, error))
+-				goto out;
+-		}
++		if (!write_ip6_setting (connection, ifcfg, error))
++			goto out;
+ 	}
+ 
+ 	write_connection_setting (s_con, ifcfg);
+-- 
+1.7.11.7
+


More information about the scm-commits mailing list