Blob Blame History Raw
From 12af09b779d70979516529c63633b7d296f82b47 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Thu, 3 Sep 2015 18:15:46 +0200
Subject: [PATCH] test: fix duplicate test names
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

New glib complains.

(cherry picked from commit 874f455d6d47c5a34ed9861a6710f4b78202e0d6)
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
---
 libnm-core/tests/test-general.c                    |  20 +--
 src/devices/wifi/tests/test-wifi-ap-utils.c        | 137 +++++++--------------
 .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c         |  14 +--
 3 files changed, 62 insertions(+), 109 deletions(-)

diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index e948365..a73604b 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -4637,18 +4637,18 @@ int main (int argc, char **argv)
 	g_test_add_func ("/core/general/test_setting_to_dbus_enum", test_setting_to_dbus_enum);
 	g_test_add_func ("/core/general/test_setting_compare_id", test_setting_compare_id);
 	g_test_add_func ("/core/general/test_setting_compare_timestamp", test_setting_compare_timestamp);
-#define ADD_FUNC(func, secret_flags, comp_flags, remove_secret) \
-	g_test_add_data_func_full ("/core/general/" G_STRINGIFY (func), \
+#define ADD_FUNC(name, func, secret_flags, comp_flags, remove_secret) \
+	g_test_add_data_func_full ("/core/general/" G_STRINGIFY (func) "_" name, \
 	                           test_data_compare_secrets_new (secret_flags, comp_flags, remove_secret), \
 	                           func, g_free)
-	ADD_FUNC (test_setting_compare_secrets, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS, TRUE);
-	ADD_FUNC (test_setting_compare_secrets, NM_SETTING_SECRET_FLAG_NOT_SAVED, NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS, TRUE);
-	ADD_FUNC (test_setting_compare_secrets, NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS, TRUE);
-	ADD_FUNC (test_setting_compare_secrets, NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_EXACT, FALSE);
-	ADD_FUNC (test_setting_compare_vpn_secrets, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS, TRUE);
-	ADD_FUNC (test_setting_compare_vpn_secrets, NM_SETTING_SECRET_FLAG_NOT_SAVED, NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS, TRUE);
-	ADD_FUNC (test_setting_compare_vpn_secrets, NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS, TRUE);
-	ADD_FUNC (test_setting_compare_vpn_secrets, NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_EXACT, FALSE);
+	ADD_FUNC ("agent_owned", test_setting_compare_secrets, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS, TRUE);
+	ADD_FUNC ("not_saved", test_setting_compare_secrets, NM_SETTING_SECRET_FLAG_NOT_SAVED, NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS, TRUE);
+	ADD_FUNC ("secrets", test_setting_compare_secrets, NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS, TRUE);
+	ADD_FUNC ("exact", test_setting_compare_secrets, NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_EXACT, FALSE);
+	ADD_FUNC ("agent_owned", test_setting_compare_vpn_secrets, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS, TRUE);
+	ADD_FUNC ("not_saved", test_setting_compare_vpn_secrets, NM_SETTING_SECRET_FLAG_NOT_SAVED, NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS, TRUE);
+	ADD_FUNC ("secrets", test_setting_compare_vpn_secrets, NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS, TRUE);
+	ADD_FUNC ("exact", test_setting_compare_vpn_secrets, NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_EXACT, FALSE);
 	g_test_add_func ("/core/general/test_setting_old_uuid", test_setting_old_uuid);
 
 	g_test_add_func ("/core/general/test_connection_to_dbus_setting_name", test_connection_to_dbus_setting_name);
diff --git a/src/devices/wifi/tests/test-wifi-ap-utils.c b/src/devices/wifi/tests/test-wifi-ap-utils.c
index 3c405e2..a5dc545 100644
--- a/src/devices/wifi/tests/test-wifi-ap-utils.c
+++ b/src/devices/wifi/tests/test-wifi-ap-utils.c
@@ -1364,10 +1364,10 @@ main (int argc, char **argv)
 	                      test_open_ap_leap_connection_1);
 	g_test_add_func ("/wifi/open_ap/leap_connection/2",
 	                 test_open_ap_leap_connection_2);
-	g_test_add_data_func ("/wifi/open_ap/wep_connection",
+	g_test_add_data_func ("/wifi/open_ap/wep_connection_true",
 	                      (gconstpointer) TRUE,
 	                      test_open_ap_wep_connection);
-	g_test_add_data_func ("/wifi/open_ap/wep_connection",
+	g_test_add_data_func ("/wifi/open_ap/wep_connection_false",
 	                      (gconstpointer) FALSE,
 	                      test_open_ap_wep_connection);
 
@@ -1441,104 +1441,57 @@ main (int argc, char **argv)
 	                      (gconstpointer) IDX_PRIV,
 	                      test_ap_wpa_eap_connection_5);
 
+#define ADD_FUNC(func) do { \
+		gchar *name_idx = g_strdup_printf ("/wifi/wpa_psk/" G_STRINGIFY (func) "/%ld", i); \
+		g_test_add_data_func (name_idx, (gconstpointer) i, func); \
+		g_free (name_idx); \
+	} while (0)
+
 	/* WPA-PSK tests */
 	for (i = IDX_WPA_PSK_PTKIP_GTKIP; i <= IDX_WPA_RSN_PSK_PCCMP_GCCMP; i++) {
-		g_test_add_data_func ("/wifi/wpa_psk/empty_connection",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_empty_connection);
-		g_test_add_data_func ("/wifi/wpa_psk/leap_connection/1",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_leap_connection_1);
-		g_test_add_data_func ("/wifi/wpa_psk/leap_connection/2",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_leap_connection_2);
-
-		g_test_add_data_func ("/wifi/wpa_psk/dynamic_wep_connection",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_dynamic_wep_connection);
-
-		g_test_add_data_func ("/wifi/wpa_psk/wpa_psk_connection/1",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_wpa_psk_connection_1);
-		g_test_add_data_func ("/wifi/wpa_psk/wpa_psk_connection/2",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_wpa_psk_connection_2);
-		g_test_add_data_func ("/wifi/wpa_psk/wpa_psk_connection/3",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_wpa_psk_connection_3);
-		g_test_add_data_func ("/wifi/wpa_psk/wpa_psk_connection/4",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_wpa_psk_connection_4);
-		g_test_add_data_func ("/wifi/wpa_psk/wpa_psk_connection/5",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_wpa_psk_connection_5);
-
-		g_test_add_data_func ("/wifi/wpa_psk/wpa_eap_connection/1",
-		                      (gconstpointer) i,
-		                      test_ap_wpa_eap_connection_1);
-		g_test_add_data_func ("/wifi/wpa_psk/wpa_eap_connection/2",
-		                      (gconstpointer) i,
-		                      test_ap_wpa_eap_connection_2);
-		g_test_add_data_func ("/wifi/wpa_psk/wpa_eap_connection/3",
-		                      (gconstpointer) i,
-		                      test_ap_wpa_eap_connection_3);
-		g_test_add_data_func ("/wifi/wpa_psk/wpa_eap_connection/4",
-		                      (gconstpointer) i,
-		                      test_ap_wpa_eap_connection_4);
-		g_test_add_data_func ("/wifi/wpa_psk/wpa_eap_connection/5",
-		                      (gconstpointer) i,
-		                      test_ap_wpa_eap_connection_5);
+		ADD_FUNC(test_wpa_ap_empty_connection);
+		ADD_FUNC(test_wpa_ap_leap_connection_1);
+		ADD_FUNC(test_wpa_ap_leap_connection_2);
+		ADD_FUNC(test_wpa_ap_dynamic_wep_connection);
+		ADD_FUNC(test_wpa_ap_wpa_psk_connection_1);
+		ADD_FUNC(test_wpa_ap_wpa_psk_connection_2);
+		ADD_FUNC(test_wpa_ap_wpa_psk_connection_3);
+		ADD_FUNC(test_wpa_ap_wpa_psk_connection_4);
+		ADD_FUNC(test_wpa_ap_wpa_psk_connection_5);
+		ADD_FUNC(test_ap_wpa_eap_connection_1);
+		ADD_FUNC(test_ap_wpa_eap_connection_2);
+		ADD_FUNC(test_ap_wpa_eap_connection_3);
+		ADD_FUNC(test_ap_wpa_eap_connection_4);
+		ADD_FUNC(test_ap_wpa_eap_connection_5);
 	}
 
+#undef ADD_FUNC
+#define ADD_FUNC(func) do { \
+		gchar *name_idx = g_strdup_printf ("/wifi/rsn_psk/" G_STRINGIFY (func) "/%ld", i); \
+		g_test_add_data_func (name_idx, (gconstpointer) i, func); \
+		g_free (name_idx); \
+	} while (0)
+
 	/* RSN-PSK tests */
 	for (i = IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP; i <= IDX_RSN_PSK_PTKIP_PCCMP_GTKIP; i++) {
-		g_test_add_data_func ("/wifi/rsn_psk/empty_connection",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_empty_connection);
-		g_test_add_data_func ("/wifi/rsn_psk/leap_connection/1",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_leap_connection_1);
-		g_test_add_data_func ("/wifi/rsn_psk/leap_connection/2",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_leap_connection_2);
-
-		g_test_add_data_func ("/wifi/rsn_psk/dynamic_wep_connection",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_dynamic_wep_connection);
-
-		g_test_add_data_func ("/wifi/rsn_psk/wpa_psk_connection/1",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_wpa_psk_connection_1);
-		g_test_add_data_func ("/wifi/rsn_psk/wpa_psk_connection/2",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_wpa_psk_connection_2);
-		g_test_add_data_func ("/wifi/rsn_psk/wpa_psk_connection/3",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_wpa_psk_connection_3);
-		g_test_add_data_func ("/wifi/rsn_psk/wpa_psk_connection/4",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_wpa_psk_connection_4);
-		g_test_add_data_func ("/wifi/rsn_psk/wpa_psk_connection/5",
-		                      (gconstpointer) i,
-		                      test_wpa_ap_wpa_psk_connection_5);
-
-		g_test_add_data_func ("/wifi/rsn_psk/wpa_eap_connection/1",
-		                      (gconstpointer) i,
-		                      test_ap_wpa_eap_connection_1);
-		g_test_add_data_func ("/wifi/rsn_psk/wpa_eap_connection/2",
-		                      (gconstpointer) i,
-		                      test_ap_wpa_eap_connection_2);
-		g_test_add_data_func ("/wifi/rsn_psk/wpa_eap_connection/3",
-		                      (gconstpointer) i,
-		                      test_ap_wpa_eap_connection_3);
-		g_test_add_data_func ("/wifi/rsn_psk/wpa_eap_connection/4",
-		                      (gconstpointer) i,
-		                      test_ap_wpa_eap_connection_4);
-		g_test_add_data_func ("/wifi/rsn_psk/wpa_eap_connection/5",
-		                      (gconstpointer) i,
-		                      test_ap_wpa_eap_connection_5);
+		ADD_FUNC(test_wpa_ap_empty_connection);
+		ADD_FUNC(test_wpa_ap_leap_connection_1);
+		ADD_FUNC(test_wpa_ap_leap_connection_2);
+		ADD_FUNC(test_wpa_ap_dynamic_wep_connection);
+		ADD_FUNC(test_wpa_ap_wpa_psk_connection_1);
+		ADD_FUNC(test_wpa_ap_wpa_psk_connection_2);
+		ADD_FUNC(test_wpa_ap_wpa_psk_connection_3);
+		ADD_FUNC(test_wpa_ap_wpa_psk_connection_4);
+		ADD_FUNC(test_wpa_ap_wpa_psk_connection_5);
+		ADD_FUNC(test_ap_wpa_eap_connection_1);
+		ADD_FUNC(test_ap_wpa_eap_connection_2);
+		ADD_FUNC(test_ap_wpa_eap_connection_3);
+		ADD_FUNC(test_ap_wpa_eap_connection_4);
+		ADD_FUNC(test_ap_wpa_eap_connection_5);
 	}
 
+#undef ADD_FUNC
+
 	/* Scanned signal strength conversion tests */
 	g_test_add_func ("/wifi/strength/dbm",
 	                 test_strength_dbm);
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 f2f85d3..953b0c7 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -12604,12 +12604,12 @@ int main (int argc, char **argv)
 	test_read_wired_static (TEST_IFCFG_WIRED_STATIC, "System test-wired-static", TRUE);
 	test_read_wired_static (TEST_IFCFG_WIRED_STATIC_BOOTPROTO, "System test-wired-static-bootproto", FALSE);
 	test_read_wired_dhcp ();
-	g_test_add_func (TPATH "dhcp-plus-ip", test_read_wired_dhcp_plus_ip);
-	g_test_add_func (TPATH "shared-plus-ip", test_read_wired_shared_plus_ip);
-	g_test_add_func (TPATH "dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname);
-	g_test_add_func (TPATH "global-gateway", test_read_wired_global_gateway);
-	g_test_add_func (TPATH "obsolete-gateway-n", test_read_wired_obsolete_gateway_n);
-	g_test_add_func (TPATH "never-default", test_read_wired_never_default);
+	g_test_add_func (TPATH "read-dhcp-plus-ip", test_read_wired_dhcp_plus_ip);
+	g_test_add_func (TPATH "read-shared-plus-ip", test_read_wired_shared_plus_ip);
+	g_test_add_func (TPATH "read-dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname);
+	g_test_add_func (TPATH "read-global-gateway", test_read_wired_global_gateway);
+	g_test_add_func (TPATH "read-obsolete-gateway-n", test_read_wired_obsolete_gateway_n);
+	g_test_add_func (TPATH "read-never-default", test_read_wired_never_default);
 	test_read_wired_defroute_no ();
 	test_read_wired_defroute_no_gatewaydev_yes ();
 	g_test_add_func (TPATH "routes/read-static", test_read_wired_static_routes);
@@ -12679,7 +12679,7 @@ int main (int argc, char **argv)
 	test_write_wired_static_routes ();
 	test_read_write_static_routes_legacy ();
 	test_write_wired_dhcp ();
-	g_test_add_func (TPATH "dhcp-plus-ip", test_write_wired_dhcp_plus_ip);
+	g_test_add_func (TPATH "wired/write-dhcp-plus-ip", test_write_wired_dhcp_plus_ip);
 	test_write_wired_dhcp_8021x_peap_mschapv2 ();
 	test_write_wired_8021x_tls (NM_SETTING_802_1X_CK_SCHEME_PATH, NM_SETTING_SECRET_FLAG_AGENT_OWNED);
 	test_write_wired_8021x_tls (NM_SETTING_802_1X_CK_SCHEME_PATH, NM_SETTING_SECRET_FLAG_NOT_SAVED);
-- 
2.1.0


From 317b6cb880b6afbb11a6578bc3791cb6eba5f2e7 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Fri, 4 Sep 2015 12:49:54 +0200
Subject: [PATCH] tests: fix 32-bit build
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes: 874f455d6d47c5a34ed9861a6710f4b78202e0d6
(cherry picked from commit f71f9d5fcf5726f9be5ac0c97e7dbc26c3e57ecc)
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
---
 src/devices/wifi/tests/test-wifi-ap-utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/devices/wifi/tests/test-wifi-ap-utils.c b/src/devices/wifi/tests/test-wifi-ap-utils.c
index a5dc545..26e130c 100644
--- a/src/devices/wifi/tests/test-wifi-ap-utils.c
+++ b/src/devices/wifi/tests/test-wifi-ap-utils.c
@@ -1442,7 +1442,7 @@ main (int argc, char **argv)
 	                      test_ap_wpa_eap_connection_5);
 
 #define ADD_FUNC(func) do { \
-		gchar *name_idx = g_strdup_printf ("/wifi/wpa_psk/" G_STRINGIFY (func) "/%ld", i); \
+		gchar *name_idx = g_strdup_printf ("/wifi/wpa_psk/" G_STRINGIFY (func) "/%zd", i); \
 		g_test_add_data_func (name_idx, (gconstpointer) i, func); \
 		g_free (name_idx); \
 	} while (0)
@@ -1467,7 +1467,7 @@ main (int argc, char **argv)
 
 #undef ADD_FUNC
 #define ADD_FUNC(func) do { \
-		gchar *name_idx = g_strdup_printf ("/wifi/rsn_psk/" G_STRINGIFY (func) "/%ld", i); \
+		gchar *name_idx = g_strdup_printf ("/wifi/rsn_psk/" G_STRINGIFY (func) "/%zd", i); \
 		g_test_add_data_func (name_idx, (gconstpointer) i, func); \
 		g_free (name_idx); \
 	} while (0)
-- 
2.1.0


From 827b49f0894168197096f3e2249b5f621b94617a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
Date: Tue, 15 Sep 2015 15:27:25 +0200
Subject: [PATCH 1/2] ifcfg-rh: (trivial) remove unused network_file parameter
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

(cherry picked from commit 64e3873faf290f07404745ec3b78348c4527bcd6)
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
---
 src/settings/plugins/ifcfg-rh/reader.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
index 72123e6..1c0f55c 100644
--- a/src/settings/plugins/ifcfg-rh/reader.c
+++ b/src/settings/plugins/ifcfg-rh/reader.c
@@ -346,7 +346,6 @@ is_any_ip4_address_defined (shvarFile *ifcfg, int *idx)
 /* Returns TRUE on missing address or valid address */
 static gboolean
 read_full_ip4_address (shvarFile *ifcfg,
-                       const char *network_file,
                        gint32 which,
                        NMIPAddress *base_addr,
                        NMIPAddress **out_address,
@@ -362,7 +361,6 @@ read_full_ip4_address (shvarFile *ifcfg,
 
 	g_return_val_if_fail (which >= -1, FALSE);
 	g_return_val_if_fail (ifcfg != NULL, FALSE);
-	g_return_val_if_fail (network_file != NULL, FALSE);
 	g_return_val_if_fail (out_address != NULL, FALSE);
 	g_return_val_if_fail (*out_address == NULL, FALSE);
 	if (error)
@@ -452,7 +450,6 @@ done:
 /* Returns TRUE on missing route or valid route */
 static gboolean
 read_one_ip4_route (shvarFile *ifcfg,
-                    const char *network_file,
                     guint32 which,
                     NMIPRoute **out_route,
                     GError **error)
@@ -463,7 +460,6 @@ read_one_ip4_route (shvarFile *ifcfg,
 	gboolean success = FALSE;
 
 	g_return_val_if_fail (ifcfg != NULL, FALSE);
-	g_return_val_if_fail (network_file != NULL, FALSE);
 	g_return_val_if_fail (out_route != NULL, FALSE);
 	g_return_val_if_fail (*out_route == NULL, FALSE);
 	if (error)
@@ -684,7 +680,6 @@ error:
 
 static gboolean
 parse_full_ip6_address (shvarFile *ifcfg,
-                        const char *network_file,
                         const char *addr_str,
                         int i,
                         NMIPAddress **out_address,
@@ -962,7 +957,7 @@ make_ip4_setting (shvarFile *ifcfg,
 		if (is_any_ip4_address_defined (ifcfg, &idx)) {
 			NMIPAddress *addr = NULL;
 
-			if (!read_full_ip4_address (ifcfg, network_file, idx, NULL, &addr, NULL, error))
+			if (!read_full_ip4_address (ifcfg, idx, NULL, &addr, NULL, error))
 				goto done;
 			if (!read_ip4_address (ifcfg, "GATEWAY", &gateway, error))
 				goto done;
@@ -1020,7 +1015,7 @@ make_ip4_setting (shvarFile *ifcfg,
 
 		/* gateway will only be set if still unset. Hence, we don't leak gateway
 		 * here by calling read_full_ip4_address() repeatedly */
-		if (!read_full_ip4_address (ifcfg, network_file, i, NULL, &addr, &gateway, error))
+		if (!read_full_ip4_address (ifcfg, i, NULL, &addr, &gateway, error))
 			goto done;
 
 		if (!addr) {
@@ -1108,7 +1103,7 @@ make_ip4_setting (shvarFile *ifcfg,
 			for (i = 0; i < 256; i++) {
 				NMIPRoute *route = NULL;
 
-				if (!read_one_ip4_route (route_ifcfg, network_file, i, &route, error)) {
+				if (!read_one_ip4_route (route_ifcfg, i, &route, error)) {
 					svCloseFile (route_ifcfg);
 					goto done;
 				}
@@ -1158,7 +1153,7 @@ done:
 }
 
 static void
-read_aliases (NMSettingIPConfig *s_ip4, const char *filename, const char *network_file)
+read_aliases (NMSettingIPConfig *s_ip4, const char *filename)
 {
 	GDir *dir;
 	char *dirname, *base;
@@ -1230,7 +1225,7 @@ read_aliases (NMSettingIPConfig *s_ip4, const char *filename, const char *networ
 			}
 
 			addr = NULL;
-			ok = read_full_ip4_address (parsed, network_file, -1, base_addr, &addr, NULL, &err);
+			ok = read_full_ip4_address (parsed, -1, base_addr, &addr, NULL, &err);
 			svCloseFile (parsed);
 			if (ok) {
 				nm_ip_address_set_attribute (addr, "label", g_variant_new_string (device));
@@ -1417,7 +1412,7 @@ make_ip6_setting (shvarFile *ifcfg,
 	for (iter = list, i = 0; iter && *iter; iter++, i++) {
 		NMIPAddress *addr = NULL;
 
-		if (!parse_full_ip6_address (ifcfg, network_file, *iter, i, &addr, error)) {
+		if (!parse_full_ip6_address (ifcfg, *iter, i, &addr, error)) {
 			g_strfreev (list);
 			goto error;
 		}
@@ -4884,7 +4879,7 @@ connection_from_file_full (const char *filename,
 		connection = NULL;
 		goto done;
 	} else {
-		read_aliases (NM_SETTING_IP_CONFIG (s_ip4), filename, network_file);
+		read_aliases (NM_SETTING_IP_CONFIG (s_ip4), filename);
 		nm_connection_add_setting (connection, s_ip4);
 	}
 
-- 
2.1.0


From 0aa99069ed8a241ca2ae8c9a156a8774132c9c7d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
Date: Tue, 15 Sep 2015 16:54:09 +0200
Subject: [PATCH 2/2] ifcfg-rh: ignore GATEWAY from network file for DHCP
 connections (rh #1262972)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The GATEWAY from /etc/sysconfig/network file is used as a default value when
no GATEWAY is in ifcfg file. However, we have to ignore that GATEWAY for
connections without static addresses. Otherwise such connections would be
invalid and would disappear after restart/reaload.

Some notes:
Putting GATEWAY into /etc/sysconfig/network is not recommended, because it
inherently belongs to the ifcfg file as it is a per-interface property.
The recommended practice is to specify GATEWAY in individual ifcfg files and
define DEFROUTE=no if the interface should not get the default route.
But we continue to read GATEWAY from /etc/sysconfig/network for compatibility
reasons.
See also
https://bugzilla.redhat.com/show_bug.cgi?id=896198#c25
https://bugzilla.redhat.com/show_bug.cgi?id=896198#c27

Fixes: f17699f4e3dacb9358a8503c8b15efe3cb852b48

https://bugzilla.redhat.com/show_bug.cgi?id=1262972

(cherry picked from commit ed85fcc711ca4ff6fa394e92ac33c5ead5c460f5)
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
---
 src/settings/plugins/ifcfg-rh/reader.c             |  7 ++++
 .../ifcfg-rh/tests/network-scripts/Makefile.am     |  2 +
 .../ifcfg-test-wired-global-gateway-ignore         |  8 ++++
 .../network-test-wired-global-gateway-ignore       |  1 +
 .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c         | 43 ++++++++++++++++++++++
 5 files changed, 61 insertions(+)
 create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-global-gateway-ignore
 create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/network-test-wired-global-gateway-ignore

diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
index 1c0f55c..5bba38f 100644
--- a/src/settings/plugins/ifcfg-rh/reader.c
+++ b/src/settings/plugins/ifcfg-rh/reader.c
@@ -1041,6 +1041,13 @@ make_ip4_setting (shvarFile *ifcfg,
 			svCloseFile (network_ifcfg);
 			if (!read_success)
 				goto done;
+
+			if (gateway && nm_setting_ip_config_get_num_addresses (s_ip4) == 0) {
+				gs_free char *f = g_path_get_basename (ifcfg->fileName);
+				PARSE_WARNING ("ignoring GATEWAY (/etc/sysconfig/network) for %s "
+				               "because the connection has no static addresses", f);
+				g_clear_pointer (&gateway, g_free);
+			}
 		}
 	}
 	g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway, NULL);
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am
index 7b5aaf1..63c10a3 100644
--- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am
@@ -14,6 +14,8 @@ EXTRA_DIST = \
 	ifcfg-test-wired-dhcp6-only \
 	ifcfg-test-wired-global-gateway \
 	network-test-wired-global-gateway \
+	ifcfg-test-wired-global-gateway-ignore \
+	network-test-wired-global-gateway-ignore \
 	ifcfg-test-wired-obsolete-gateway-n \
 	ifcfg-test-wired-never-default \
 	network-test-wired-never-default \
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-global-gateway-ignore b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-global-gateway-ignore
new file mode 100644
index 0000000..bb81399
--- /dev/null
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-global-gateway-ignore
@@ -0,0 +1,8 @@
+TYPE=Ethernet
+DEVICE=eth0
+HWADDR=00:11:22:33:44:ee
+BOOTPROTO=dhcp
+ONBOOT=yes
+USERCTL=yes
+IPV6INIT=no
+
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/network-test-wired-global-gateway-ignore b/src/settings/plugins/ifcfg-rh/tests/network-scripts/network-test-wired-global-gateway-ignore
new file mode 100644
index 0000000..7987d10
--- /dev/null
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/network-test-wired-global-gateway-ignore
@@ -0,0 +1 @@
+GATEWAY=192.168.1.2
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 953b0c7..f42dbf4 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -868,6 +868,48 @@ test_read_wired_global_gateway (void)
 	g_object_unref (connection);
 }
 
+/* Ignore GATEWAY from /etc/sysconfig/network for automatic connections */
+static void
+test_read_wired_global_gateway_ignore (void)
+{
+	NMConnection *connection;
+	NMSettingConnection *s_con;
+	NMSettingWired *s_wired;
+	NMSettingIPConfig *s_ip4;
+	GError *error = NULL;
+	char *unmanaged = NULL;
+
+	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
+	                       "*ignoring GATEWAY (/etc/sysconfig/network) for * because the connection has no static addresses");
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-global-gateway-ignore",
+	                                        TEST_IFCFG_DIR"/network-scripts/network-test-wired-global-gateway-ignore",
+	                                        TYPE_ETHERNET, &unmanaged, &error);
+	nmtst_assert_connection_verifies_without_normalization (connection);
+	g_assert (unmanaged == NULL);
+
+	/* ===== CONNECTION SETTING ===== */
+	s_con = nm_connection_get_setting_connection (connection);
+	g_assert (s_con);
+	g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System test-wired-global-gateway-ignore");
+
+	/* ===== WIRED SETTING ===== */
+	s_wired = nm_connection_get_setting_wired (connection);
+	g_assert (s_wired);
+
+	/* ===== IPv4 SETTING ===== */
+	s_ip4 = nm_connection_get_setting_ip4_config (connection);
+	g_assert (s_ip4);
+	g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
+
+	/* Addresses */
+	g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 0);
+
+	/* Gateway */
+	g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, NULL);
+
+	g_object_unref (connection);
+}
+
 static void
 test_read_wired_obsolete_gateway_n (void)
 {
@@ -12608,6 +12650,7 @@ int main (int argc, char **argv)
 	g_test_add_func (TPATH "read-shared-plus-ip", test_read_wired_shared_plus_ip);
 	g_test_add_func (TPATH "read-dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname);
 	g_test_add_func (TPATH "read-global-gateway", test_read_wired_global_gateway);
+	g_test_add_func (TPATH "read-global-gateway-ignore", test_read_wired_global_gateway_ignore);
 	g_test_add_func (TPATH "read-obsolete-gateway-n", test_read_wired_obsolete_gateway_n);
 	g_test_add_func (TPATH "read-never-default", test_read_wired_never_default);
 	test_read_wired_defroute_no ();
-- 
2.1.0