summary refs log tree commit diff
path: root/src/settings/plugins/ifcfg-rh
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings/plugins/ifcfg-rh')
-rw-r--r--src/settings/plugins/ifcfg-rh/Makefile.in30
-rw-r--r--src/settings/plugins/ifcfg-rh/common.h4
-rw-r--r--src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c217
-rw-r--r--src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h8
-rw-r--r--src/settings/plugins/ifcfg-rh/plugin.c561
-rw-r--r--src/settings/plugins/ifcfg-rh/reader.c203
-rw-r--r--src/settings/plugins/ifcfg-rh/reader.h17
-rw-r--r--src/settings/plugins/ifcfg-rh/shvar.c16
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/Makefile.am1
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/Makefile.in32
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am3
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in27
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bond-mode-numeric5
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main2
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-open2
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcp-plus-ip6
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-12
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-23
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-obsolete-gateway-n13
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-shared-plus-ip19
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c2
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c2561
-rw-r--r--src/settings/plugins/ifcfg-rh/utils.c24
-rw-r--r--src/settings/plugins/ifcfg-rh/utils.h8
-rw-r--r--src/settings/plugins/ifcfg-rh/writer.c40
25 files changed, 1578 insertions, 2228 deletions
diff --git a/src/settings/plugins/ifcfg-rh/Makefile.in b/src/settings/plugins/ifcfg-rh/Makefile.in
index 5d396273..89511983 100644
--- a/src/settings/plugins/ifcfg-rh/Makefile.in
+++ b/src/settings/plugins/ifcfg-rh/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -16,7 +16,17 @@
 
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -80,8 +90,6 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = src/settings/plugins/ifcfg-rh
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/build-aux/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \
 	$(top_srcdir)/m4/compiler_warnings.m4 \
@@ -98,6 +106,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \
 	$(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -228,6 +237,8 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in \
+	$(top_srcdir)/build-aux/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -279,7 +290,6 @@ CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
 CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
-DATADIRNAME = @DATADIRNAME@
 DBUS_CFLAGS = @DBUS_CFLAGS@
 DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@
 DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@
@@ -314,6 +324,7 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
 GNUTLS_LIBS = @GNUTLS_LIBS@
 GREP = @GREP@
 GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@
 GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
 GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
 GTKDOC_MKPDF = @GTKDOC_MKPDF@
@@ -579,7 +590,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -668,14 +678,14 @@ distclean-compile:
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
 
 .c.obj:
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .c.lo:
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -998,6 +1008,8 @@ uninstall-am: uninstall-dbusserviceDATA uninstall-pkglibLTLIBRARIES
 	tags tags-am uninstall uninstall-am uninstall-dbusserviceDATA \
 	uninstall-pkglibLTLIBRARIES
 
+.PRECIOUS: Makefile
+
 
 @GNOME_CODE_COVERAGE_RULES@
 
diff --git a/src/settings/plugins/ifcfg-rh/common.h b/src/settings/plugins/ifcfg-rh/common.h
index d78f3752..0ec355ee 100644
--- a/src/settings/plugins/ifcfg-rh/common.h
+++ b/src/settings/plugins/ifcfg-rh/common.h
@@ -26,7 +26,9 @@
 #define IFCFG_TAG "ifcfg-"
 #define KEYS_TAG "keys-"
 #define ROUTE_TAG "route-"
+#define RULE_TAG "rule-"
 #define ROUTE6_TAG "route6-"
+#define RULE6_TAG "rule6-"
 
 #define BAK_TAG ".bak"
 #define TILDE_TAG "~"
@@ -39,7 +41,7 @@
 #define IFCFG_DIR SYSCONFDIR"/sysconfig/network-scripts"
 
 #define IFCFG_PLUGIN_NAME "ifcfg-rh"
-#define IFCFG_PLUGIN_INFO "(c) 2007 - 2013 Red Hat, Inc.  To report bugs please use the NetworkManager mailing list."
+#define IFCFG_PLUGIN_INFO "(c) 2007 - 2015 Red Hat, Inc.  To report bugs please use the NetworkManager mailing list."
 
 #define TYPE_ETHERNET   "Ethernet"
 #define TYPE_WIRELESS   "Wireless"
diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
index 7596cbd5..94d22258 100644
--- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
+++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
@@ -33,6 +33,8 @@
 #include <nm-setting-pppoe.h>
 #include <nm-setting-wireless-security.h>
 #include <nm-setting-8021x.h>
+#include <nm-platform.h>
+#include <nm-logging.h>
 
 #include "common.h"
 #include "nm-config.h"
@@ -49,7 +51,6 @@ G_DEFINE_TYPE (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SETTINGS_CONNECTI
 typedef struct {
 	gulong ih_event_id;
 
-	char *path;
 	int file_wd;
 
 	char *keyfile;
@@ -63,6 +64,9 @@ typedef struct {
 
 	char *unmanaged_spec;
 	char *unrecognized_spec;
+
+	gulong devtimeout_link_changed_handler;
+	guint devtimeout_timeout_id;
 } NMIfcfgConnectionPrivate;
 
 enum {
@@ -80,6 +84,101 @@ enum {
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
+static gboolean
+devtimeout_ready (gpointer user_data)
+{
+	NMIfcfgConnection *self = user_data;
+	NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self);
+
+	priv->devtimeout_timeout_id = 0;
+	nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), TRUE);
+	return FALSE;
+}
+
+static void
+link_changed (NMPlatform *platform, int ifindex, NMPlatformLink *link,
+              NMPlatformSignalChangeType change_type, NMPlatformReason reason,
+              NMConnection *self)
+{
+	NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self);
+	const char *ifname;
+
+	ifname = nm_connection_get_interface_name (self);
+	if (g_strcmp0 (link->name, ifname) != 0)
+		return;
+
+	/* Shouldn't happen, but... */
+	if (change_type == NM_PLATFORM_SIGNAL_REMOVED)
+		return;
+
+	nm_log_info (LOGD_SETTINGS, "Device %s appeared; connection '%s' now ready",
+	             ifname, nm_connection_get_id (self));
+
+	g_signal_handler_disconnect (platform, priv->devtimeout_link_changed_handler);
+	priv->devtimeout_link_changed_handler = 0;
+	g_source_remove (priv->devtimeout_timeout_id);
+
+	/* Don't declare the connection ready right away, since NMManager may not have
+	 * started processing the device yet.
+	 */
+	priv->devtimeout_timeout_id = g_idle_add (devtimeout_ready, self);
+}
+
+static gboolean
+devtimeout_expired (gpointer user_data)
+{
+	NMIfcfgConnection *self = user_data;
+	NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self);
+
+	nm_log_info (LOGD_SETTINGS, "Device for connection '%s' did not appear before timeout",
+	             nm_connection_get_id (NM_CONNECTION (self)));
+
+	g_signal_handler_disconnect (nm_platform_get (), priv->devtimeout_link_changed_handler);
+	priv->devtimeout_link_changed_handler = 0;
+	priv->devtimeout_timeout_id = 0;
+
+	nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), TRUE);
+	return FALSE;
+}
+
+static void
+nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self)
+{
+	NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self);
+	NMSettingConnection *s_con;
+	const char *ifname;
+	const char *filename;
+	guint devtimeout;
+
+	s_con = nm_connection_get_setting_connection (NM_CONNECTION (self));
+
+	if (!nm_setting_connection_get_autoconnect (s_con))
+		return;
+	ifname = nm_setting_connection_get_interface_name (s_con);
+	if (!ifname)
+		return;
+	filename = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (self));
+	if (!filename)
+		return;
+	devtimeout = devtimeout_from_file (filename);
+	if (!devtimeout)
+		return;
+
+	if (nm_platform_link_get_ifindex (ifname) != 0)
+		return;
+
+	/* ONBOOT=yes, DEVICE and DEVTIMEOUT are set, but device is not present */
+	nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), FALSE);
+
+	nm_log_info (LOGD_SETTINGS, "Waiting %u seconds for %s to appear for connection '%s'",
+	             devtimeout, ifname, nm_connection_get_id (NM_CONNECTION (self)));
+
+	priv->devtimeout_link_changed_handler =
+		g_signal_connect (nm_platform_get (), NM_PLATFORM_SIGNAL_LINK_CHANGED,
+		                  G_CALLBACK (link_changed), self);
+	priv->devtimeout_timeout_id = g_timeout_add_seconds (devtimeout, devtimeout_expired, self);
+}
+
 static void
 files_changed_cb (NMInotifyHelper *ih,
                   struct inotify_event *evt,
@@ -102,8 +201,7 @@ files_changed_cb (NMInotifyHelper *ih,
 NMIfcfgConnection *
 nm_ifcfg_connection_new (NMConnection *source,
                          const char *full_path,
-                         GError **error,
-                         gboolean *ignore_error)
+                         GError **error)
 {
 	GObject *object;
 	NMConnection *tmp;
@@ -117,18 +215,9 @@ nm_ifcfg_connection_new (NMConnection *source,
 	if (source)
 		tmp = g_object_ref (source);
 	else {
-		char *keyfile = NULL, *routefile = NULL, *route6file = NULL;
-
-		tmp = connection_from_file (full_path, NULL, NULL,
+		tmp = connection_from_file (full_path,
 		                            &unhandled_spec,
-		                            &keyfile,
-		                            &routefile,
-		                            &route6file,
-		                            error,
-		                            ignore_error);
-		g_free (keyfile);
-		g_free (routefile);
-		g_free (route6file);
+		                            error);
 		if (!tmp)
 			return NULL;
 
@@ -142,6 +231,7 @@ nm_ifcfg_connection_new (NMConnection *source,
 		unrecognized_spec = unhandled_spec + strlen ("unrecognized:");
 
 	object = (GObject *) g_object_new (NM_TYPE_IFCFG_CONNECTION,
+	                                   NM_SETTINGS_CONNECTION_FILENAME, full_path,
 	                                   NM_IFCFG_CONNECTION_UNMANAGED_SPEC, unmanaged_spec,
 	                                   NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, unrecognized_spec,
 	                                   NULL);
@@ -149,11 +239,10 @@ nm_ifcfg_connection_new (NMConnection *source,
 	if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
 	                                             tmp,
 	                                             update_unsaved,
-	                                             error)) {
-		/* Set the path and start monitoring */
-		if (full_path)
-			nm_ifcfg_connection_set_path (NM_IFCFG_CONNECTION (object), full_path);
-	} else
+	                                             NULL,
+	                                             error))
+		nm_ifcfg_connection_check_devtimeout (NM_IFCFG_CONNECTION (object));
+	else
 		g_clear_object (&object);
 
 	g_object_unref (tmp);
@@ -161,14 +250,6 @@ nm_ifcfg_connection_new (NMConnection *source,
 	return (NMIfcfgConnection *) object;
 }
 
-const char *
-nm_ifcfg_connection_get_path (NMIfcfgConnection *self)
-{
-	g_return_val_if_fail (NM_IS_IFCFG_CONNECTION (self), NULL);
-
-	return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->path;
-}
-
 static void
 path_watch_stop (NMIfcfgConnection *self)
 {
@@ -209,17 +290,21 @@ path_watch_stop (NMIfcfgConnection *self)
 	}
 }
 
-void
-nm_ifcfg_connection_set_path (NMIfcfgConnection *self, const char *ifcfg_path)
+static void
+filename_changed (GObject *object,
+                  GParamSpec *pspec,
+                  gpointer user_data)
 {
+	NMIfcfgConnection *self = NM_IFCFG_CONNECTION (object);
 	NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self);
-
-	g_return_if_fail (ifcfg_path != NULL);
+	const char *ifcfg_path;
 
 	path_watch_stop (self);
-	g_free (priv->path);
 
-	priv->path = g_strdup (ifcfg_path);
+	ifcfg_path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (self));
+	if (!ifcfg_path)
+		return;
+
 	priv->keyfile = utils_get_keys_path (ifcfg_path);
 	priv->routefile = utils_get_route_path (ifcfg_path);
 	priv->route6file = utils_get_route6_path (ifcfg_path);
@@ -252,6 +337,28 @@ nm_ifcfg_connection_get_unrecognized_spec (NMIfcfgConnection *self)
 }
 
 static void
+replace_and_commit (NMSettingsConnection *connection,
+                    NMConnection *new_connection,
+                    NMSettingsConnectionCommitFunc callback,
+                    gpointer user_data)
+{
+	const char *filename;
+	GError *error = NULL;
+
+	filename = nm_settings_connection_get_filename (connection);
+	if (filename && utils_has_complex_routes (filename)) {
+		if (callback) {
+			error = g_error_new_literal (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
+			                             "Cannot modify a connection that has an associated 'rule-' or 'rule6-' file");
+			callback (connection, error, user_data);
+			g_clear_error (&error);
+		}
+	}
+
+	NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->replace_and_commit (connection, new_connection, callback, user_data);
+}
+
+static void
 commit_changes (NMSettingsConnection *connection,
                 NMSettingsConnectionCommitFunc callback,
                 gpointer user_data)
@@ -261,16 +368,15 @@ commit_changes (NMSettingsConnection *connection,
 	NMConnection *reread;
 	gboolean same = FALSE, success = FALSE;
 	char *ifcfg_path = NULL;
+	const char *filename;
 
 	/* To ensure we don't rewrite files that are only changed from other
 	 * processes on-disk, read the existing connection back in and only rewrite
 	 * it if it's really changed.
 	 */
-	if (priv->path) {
-		reread = connection_from_file (priv->path, NULL, NULL,
-		                               NULL, NULL, NULL, NULL,
-		                               &error, NULL);
-		g_clear_error (&error);
+	filename = nm_settings_connection_get_filename (connection);
+	if (filename) {
+		reread = connection_from_file (filename, NULL, NULL);
 		if (reread) {
 			same = nm_connection_compare (NM_CONNECTION (connection),
 			                              reread,
@@ -288,7 +394,7 @@ commit_changes (NMSettingsConnection *connection,
 
 		success = writer_update_connection (NM_CONNECTION (connection),
 		                                    IFCFG_DIR,
-		                                    priv->path,
+		                                    filename,
 		                                    priv->keyfile,
 		                                    &error);
 	} else {
@@ -297,7 +403,7 @@ commit_changes (NMSettingsConnection *connection,
 		                                 &ifcfg_path,
 		                                 &error);
 		if (success) {
-			nm_ifcfg_connection_set_path (NM_IFCFG_CONNECTION (connection), ifcfg_path);
+			nm_settings_connection_set_filename (connection, ifcfg_path);
 			g_free (ifcfg_path);
 		}
 	}
@@ -318,14 +424,15 @@ do_delete (NMSettingsConnection *connection,
 	       gpointer user_data)
 {
 	NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection);
+	const char *filename;
 
-	if (priv->path) {
-		g_unlink (priv->path);
+	filename = nm_settings_connection_get_filename (connection);
+	if (filename) {
+		g_unlink (filename);
 		if (priv->keyfile)
 			g_unlink (priv->keyfile);
 		if (priv->routefile)
 			g_unlink (priv->routefile);
-
 		if (priv->route6file)
 			g_unlink (priv->route6file);
 	}
@@ -338,6 +445,8 @@ do_delete (NMSettingsConnection *connection,
 static void
 nm_ifcfg_connection_init (NMIfcfgConnection *connection)
 {
+	g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_FILENAME,
+	                  G_CALLBACK (filename_changed), NULL);
 }
 
 static void
@@ -381,17 +490,21 @@ get_property (GObject *object, guint prop_id,
 static void
 dispose (GObject *object)
 {
-	path_watch_stop (NM_IFCFG_CONNECTION (object));
+	NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (object);
 
-	G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->dispose (object);
-}
+	path_watch_stop (NM_IFCFG_CONNECTION (object));
 
-static void
-finalize (GObject *object)
-{
-	g_free (NM_IFCFG_CONNECTION_GET_PRIVATE (object)->path);
+	if (priv->devtimeout_link_changed_handler) {
+		g_signal_handler_disconnect (nm_platform_get (),
+		                             priv->devtimeout_link_changed_handler);
+		priv->devtimeout_link_changed_handler = 0;
+	}
+	if (priv->devtimeout_timeout_id) {
+		g_source_remove (priv->devtimeout_timeout_id);
+		priv->devtimeout_timeout_id = 0;
+	}
 
-	G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->finalize (object);
+	G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->dispose (object);
 }
 
 static void
@@ -406,8 +519,8 @@ nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class)
 	object_class->set_property = set_property;
 	object_class->get_property = get_property;
 	object_class->dispose      = dispose;
-	object_class->finalize     = finalize;
 	settings_class->delete = do_delete;
+	settings_class->replace_and_commit = replace_and_commit;
 	settings_class->commit_changes = commit_changes;
 
 	/* Properties */
diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h
index 37eacaf0..328e58f5 100644
--- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h
+++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.h
@@ -48,13 +48,7 @@ GType nm_ifcfg_connection_get_type (void);
 
 NMIfcfgConnection *nm_ifcfg_connection_new (NMConnection *source,
                                             const char *full_path,
-                                            GError **error,
-                                            gboolean *ignore_error);
-
-const char *nm_ifcfg_connection_get_path (NMIfcfgConnection *self);
-
-void        nm_ifcfg_connection_set_path (NMIfcfgConnection *self,
-                                          const char *ifcfg_path);
+                                            GError **error);
 
 const char *nm_ifcfg_connection_get_unmanaged_spec (NMIfcfgConnection *self);
 const char *nm_ifcfg_connection_get_unrecognized_spec (NMIfcfgConnection *self);
diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c
index 2dced56b..b7efa864 100644
--- a/src/settings/plugins/ifcfg-rh/plugin.c
+++ b/src/settings/plugins/ifcfg-rh/plugin.c
@@ -58,10 +58,31 @@
 #include "reader.h"
 #include "writer.h"
 #include "utils.h"
+#include "gsystem-local-alloc.h"
 
 #define DBUS_SERVICE_NAME "com.redhat.ifcfgrh1"
 #define DBUS_OBJECT_PATH "/com/redhat/ifcfgrh1"
 
+
+#define _LOG_DEFAULT_DOMAIN  LOGD_SETTINGS
+
+#define _LOG(level, domain, ...) \
+    G_STMT_START { \
+        nm_log ((level), (domain), \
+                "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
+                "ifcfg-rh: " \
+                _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+    } G_STMT_END
+
+#define _LOGT(...)      _LOG (LOGL_TRACE, _LOG_DEFAULT_DOMAIN, __VA_ARGS__)
+#define _LOGD(...)      _LOG (LOGL_DEBUG, _LOG_DEFAULT_DOMAIN, __VA_ARGS__)
+#define _LOGI(...)      _LOG (LOGL_INFO,  _LOG_DEFAULT_DOMAIN, __VA_ARGS__)
+#define _LOGW(...)      _LOG (LOGL_WARN,  _LOG_DEFAULT_DOMAIN, __VA_ARGS__)
+#define _LOGE(...)      _LOG (LOGL_ERR,   _LOG_DEFAULT_DOMAIN, __VA_ARGS__)
+
+#define ERR_GET_MSG(err) (((err) && (err)->message) ? (err)->message : "(unknown)")
+
+
 static gboolean impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
                                                 const char *in_ifcfg,
                                                 const char **out_uuid,
@@ -70,10 +91,13 @@ static gboolean impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
 
 #include "nm-ifcfg-rh-glue.h"
 
-static void connection_new_or_changed (SCPluginIfcfg *plugin,
-                                       const char *path,
-                                       NMIfcfgConnection *existing,
-                                       char **out_old_path);
+static NMIfcfgConnection *update_connection (SCPluginIfcfg *plugin,
+                                             NMConnection *source,
+                                             const char *full_path,
+                                             NMIfcfgConnection *connection,
+                                             gboolean protect_existing_connection,
+                                             GHashTable *protected_connections,
+                                             GError **error);
 
 static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class);
 
@@ -104,13 +128,22 @@ typedef struct {
 static void
 connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data)
 {
-	SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data);
+	SCPluginIfcfg *self = SC_PLUGIN_IFCFG (user_data);
+	SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
 	const char *path;
 
-	path = nm_ifcfg_connection_get_path (connection);
+	path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection));
 	g_return_if_fail (path != NULL);
 
-	connection_new_or_changed (plugin, path, connection, NULL);
+
+	if (!priv->ifcfg_monitor) {
+		_LOGD ("connection_ifcfg_changed("NM_IFCFG_CONNECTION_LOG_FMTD"): %s", NM_IFCFG_CONNECTION_LOG_ARGD (connection), "ignore event");
+		return;
+	}
+
+	_LOGD ("connection_ifcfg_changed("NM_IFCFG_CONNECTION_LOG_FMTD"): %s", NM_IFCFG_CONNECTION_LOG_ARGD (connection), "reload");
+
+	update_connection (self, NULL, path, connection, TRUE, NULL, NULL);
 }
 
 static void
@@ -120,69 +153,6 @@ connection_removed_cb (NMSettingsConnection *obj, gpointer user_data)
 	                     nm_connection_get_uuid (NM_CONNECTION (obj)));
 }
 
-static NMIfcfgConnection *
-_internal_new_connection (SCPluginIfcfg *self,
-                          const char *path,
-                          NMConnection *source,
-                          GError **error)
-{
-	SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
-	NMIfcfgConnection *connection;
-	const char *cid;
-	GError *local = NULL;
-	gboolean ignore_error = FALSE;
-
-	if (!source)
-		nm_log_info (LOGD_SETTINGS, "parsing %s ... ", path);
-
-	connection = nm_ifcfg_connection_new (source, path, &local, &ignore_error);
-	if (!connection) {
-		if (!ignore_error)
-			nm_log_warn (LOGD_SETTINGS, "    %s", (local && local->message) ? local->message : "(unknown)");
-		if (local)
-			g_propagate_error (error, local);
-		else
-			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
-			             "(unknown)");
-		return NULL;
-	}
-
-	cid = nm_connection_get_id (NM_CONNECTION (connection));
-	g_assert (cid);
-
-	g_hash_table_insert (priv->connections,
-	                     g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))),
-	                     connection);
-	nm_log_info (LOGD_SETTINGS, "    read connection '%s'", cid);
-	g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED,
-	                  G_CALLBACK (connection_removed_cb),
-	                  self);
-
-	if (nm_ifcfg_connection_get_unmanaged_spec (connection)) {
-		const char *spec;
-		const char *device_id;
-
-		spec = nm_ifcfg_connection_get_unmanaged_spec (connection);
-		device_id = strchr (spec, ':');
-		if (device_id)
-			device_id++;
-		else
-			device_id = spec;
-		nm_log_warn (LOGD_SETTINGS, "    Ignoring connection '%s' / device '%s' due to NM_CONTROLLED=no.",
-		             cid, device_id);
-	} else if (nm_ifcfg_connection_get_unrecognized_spec (connection)) {
-		nm_log_warn (LOGD_SETTINGS, "    Ignoring connection '%s' of unrecognized type.", cid);
-	}
-
-	/* watch changes of ifcfg hardlinks */
-	g_signal_connect (G_OBJECT (connection), "ifcfg-changed",
-	                  G_CALLBACK (connection_ifcfg_changed), self);
-
-	return connection;
-}
-
-/* Monitoring */
-
 static void
 remove_connection (SCPluginIfcfg *self, NMIfcfgConnection *connection)
 {
@@ -192,6 +162,8 @@ remove_connection (SCPluginIfcfg *self, NMIfcfgConnection *connection)
 	g_return_if_fail (self != NULL);
 	g_return_if_fail (connection != NULL);
 
+	_LOGI ("remove "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection));
+
 	unmanaged = !!nm_ifcfg_connection_get_unmanaged_spec (connection);
 	unrecognized = !!nm_ifcfg_connection_get_unrecognized_spec (connection);
 
@@ -212,160 +184,233 @@ find_by_path (SCPluginIfcfg *self, const char *path)
 {
 	SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
 	GHashTableIter iter;
-	NMIfcfgConnection *candidate = NULL;
+	NMSettingsConnection *candidate = NULL;
 
 	g_return_val_if_fail (path != NULL, NULL);
 
 	g_hash_table_iter_init (&iter, priv->connections);
 	while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) {
-		if (g_strcmp0 (path, nm_ifcfg_connection_get_path (candidate)) == 0)
-			return candidate;
+		if (g_strcmp0 (path, nm_settings_connection_get_filename (candidate)) == 0)
+			return NM_IFCFG_CONNECTION (candidate);
 	}
 	return NULL;
 }
 
 static NMIfcfgConnection *
-find_by_uuid_from_path (SCPluginIfcfg *self, const char *path)
+update_connection (SCPluginIfcfg *self,
+                   NMConnection *source,
+                   const char *full_path,
+                   NMIfcfgConnection *connection,
+                   gboolean protect_existing_connection,
+                   GHashTable *protected_connections,
+                   GError **error)
 {
 	SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
-	char *uuid;
-
-	g_return_val_if_fail (path != NULL, NULL);
+	NMIfcfgConnection *connection_new;
+	NMIfcfgConnection *connection_by_uuid;
+	GError *local = NULL;
+	const char *new_unmanaged = NULL, *old_unmanaged = NULL;
+	const char *new_unrecognized = NULL, *old_unrecognized = NULL;
+	gboolean unmanaged_changed = FALSE, unrecognized_changed = FALSE;
+	const char *uuid;
 
-	uuid = uuid_from_file (path);
-	if (uuid)
-		return g_hash_table_lookup (priv->connections, uuid);
-	else
+	g_return_val_if_fail (!source || NM_IS_CONNECTION (source), NULL);
+	g_return_val_if_fail (full_path || source, NULL);
+
+	if (full_path)
+		_LOGD ("loading from file \"%s\"...", full_path);
+
+	/* Create a NMIfcfgConnection instance, either by reading from @full_path or
+	 * based on @source. */
+	connection_new = nm_ifcfg_connection_new (source, full_path, error);
+	if (!connection_new) {
+		/* Unexpected failure. Probably the file is invalid? */
+		if (   connection
+		    && !protect_existing_connection
+		    && (!protected_connections || !g_hash_table_contains (protected_connections, connection)))
+			remove_connection (self, connection);
 		return NULL;
-}
+	}
 
-static void
-connection_new_or_changed (SCPluginIfcfg *self,
-                           const char *path,
-                           NMIfcfgConnection *existing,
-                           char **out_old_path)
-{
-	SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
-	NMIfcfgConnection *new;
-	GError *error = NULL;
-	gboolean ignore_error = FALSE;
-	const char *new_unmanaged = NULL, *old_unmanaged = NULL;
-	const char *new_unrecognized = NULL, *old_unrecognized = NULL;
-	gboolean unmanaged_changed, unrecognized_changed;
+	uuid = nm_connection_get_uuid (NM_CONNECTION (connection_new));
+	connection_by_uuid = g_hash_table_lookup (priv->connections, uuid);
 
-	g_return_if_fail (self != NULL);
-	g_return_if_fail (path != NULL);
+	if (   connection
+	    && connection != connection_by_uuid) {
 
-	if (out_old_path)
-		*out_old_path = NULL;
-
-	if (!existing) {
-		/* See if it's a rename */
-		existing = find_by_uuid_from_path (self, path);
-		if (existing) {
-			const char *old_path = nm_ifcfg_connection_get_path (existing);
-			nm_log_info (LOGD_SETTINGS, "renaming %s -> %s", old_path, path);
-			if (out_old_path)
-				*out_old_path = g_strdup (old_path);
-			nm_ifcfg_connection_set_path (existing, path);
-		}
-	}
+		if (   (protect_existing_connection && connection_by_uuid != NULL)
+		    || (protected_connections && g_hash_table_contains (protected_connections, connection))) {
+			NMIfcfgConnection *conflicting = (protect_existing_connection && connection_by_uuid != NULL) ? connection_by_uuid : connection;
 
-	if (!existing) {
-		/* New connection */
-		new = _internal_new_connection (self, path, NULL, NULL);
-		if (new) {
-			if (nm_ifcfg_connection_get_unmanaged_spec (new))
-				g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
-			else if (nm_ifcfg_connection_get_unrecognized_spec (new))
-				g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED);
+			if (source)
+				_LOGW ("cannot update protected connection "NM_IFCFG_CONNECTION_LOG_FMT" due to conflicting UUID %s", NM_IFCFG_CONNECTION_LOG_ARG (conflicting), uuid);
 			else
-				g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new);
+				_LOGW ("cannot load %s due to conflicting UUID for "NM_IFCFG_CONNECTION_LOG_FMT, full_path, NM_IFCFG_CONNECTION_LOG_ARG (conflicting));
+			g_object_unref (connection_new);
+			g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
+			                     "Cannot update protected connection due to conflicting UUID");
+			return NULL;
 		}
-		return;
-	}
-
-	new = (NMIfcfgConnection *) nm_ifcfg_connection_new (NULL, path, &error, &ignore_error);
-	if (!new) {
-		/* errors reading connection; remove it */
-		if (!ignore_error)
-			nm_log_warn (LOGD_SETTINGS, "    %s", (error && error->message) ? error->message : "(unknown)");
-		g_clear_error (&error);
 
-		nm_log_info (LOGD_SETTINGS, "removed %s.", path);
-		remove_connection (self, existing);
-		return;
+		/* The new connection has a different UUID then the original one that we
+		 * are about to update. Remove @connection. */
+		remove_connection (self, connection);
 	}
 
-	/* Successfully read connection changes */
+	/* Check if the found connection with the same UUID is not protected from updating. */
+	if (   connection_by_uuid
+	    && (   (!connection && protect_existing_connection)
+	        || (protected_connections && g_hash_table_contains (protected_connections, connection_by_uuid)))) {
+		if (source)
+			_LOGW ("cannot update connection due to conflicting UUID for "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_by_uuid));
+		else
+			_LOGW ("cannot load %s due to conflicting UUID for "NM_IFCFG_CONNECTION_LOG_FMT, full_path, NM_IFCFG_CONNECTION_LOG_ARG (connection_by_uuid));
+		g_object_unref (connection_new);
+		g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
+		                      "Skip updating protected connection during reload");
+		return NULL;
+	}
 
-	old_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (NM_IFCFG_CONNECTION (existing));
-	new_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (NM_IFCFG_CONNECTION (new));
+	/* Evaluate unmanaged/unrecognized flags. */
+	if (connection_by_uuid)
+		old_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (connection_by_uuid);
+	new_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (connection_new);
 	unmanaged_changed = g_strcmp0 (old_unmanaged, new_unmanaged);
 
-	old_unrecognized = nm_ifcfg_connection_get_unrecognized_spec (NM_IFCFG_CONNECTION (existing));
-	new_unrecognized = nm_ifcfg_connection_get_unrecognized_spec (NM_IFCFG_CONNECTION (new));
+	if (connection_by_uuid)
+		old_unrecognized = nm_ifcfg_connection_get_unrecognized_spec (connection_by_uuid);
+	new_unrecognized = nm_ifcfg_connection_get_unrecognized_spec (connection_new);
 	unrecognized_changed = g_strcmp0 (old_unrecognized, new_unrecognized);
 
-	if (   !unmanaged_changed
-	    && !unrecognized_changed
-	    && nm_connection_compare (NM_CONNECTION (existing),
-	                              NM_CONNECTION (new),
-	                              NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS |
-	                                  NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) {
-		g_object_unref (new);
-		return;
-	}
+	if (connection_by_uuid) {
+		const char *old_path;
+
+		old_path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid));
+
+		if (   !unmanaged_changed
+		    && !unrecognized_changed
+		    && nm_connection_compare (NM_CONNECTION (connection_by_uuid),
+		                              NM_CONNECTION (connection_new),
+		                              NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS |
+		                              NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) {
+			if (old_path && g_strcmp0 (old_path, full_path) != 0)
+				_LOGI ("rename \"%s\" to "NM_IFCFG_CONNECTION_LOG_FMT" without other changes", nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid)), NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
+		} else {
+
+			/*******************************************************
+			 * UPDATE
+			 *******************************************************/
+
+			if (source)
+				_LOGI ("update "NM_IFCFG_CONNECTION_LOG_FMT" from %s", NM_IFCFG_CONNECTION_LOG_ARG (connection_new), NM_IFCFG_CONNECTION_LOG_PATH (old_path));
+			else if (!g_strcmp0 (old_path, nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_new))))
+				_LOGI ("update "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
+			else if (old_path)
+				_LOGI ("rename \"%s\" to "NM_IFCFG_CONNECTION_LOG_FMT, old_path, NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
+			else
+				_LOGI ("update and persist "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
+
+			g_object_set (connection_by_uuid,
+			              NM_IFCFG_CONNECTION_UNMANAGED_SPEC, new_unmanaged,
+			              NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, new_unrecognized,
+			              NULL);
+
+			if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection_by_uuid),
+			                                              NM_CONNECTION (connection_new),
+			                                              FALSE,  /* don't set Unsaved */
+			                                              "ifcfg-update",
+			                                              &local)) {
+				/* Shouldn't ever get here as 'connection_new' was verified by the reader already
+				 * and the UUID did not change. */
+				g_assert_not_reached ();
+			}
+			g_assert_no_error (local);
+
+			if (new_unmanaged || new_unrecognized) {
+				if (!old_unmanaged && !old_unrecognized) {
+					g_object_ref (connection_by_uuid);
+					/* Unexport the connection by telling the settings service it's
+					 * been removed.
+					 */
+					nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection_by_uuid));
+					/* Remove the path so that claim_connection() doesn't complain later when
+					 * interface gets managed and connection is re-added. */
+					nm_connection_set_path (NM_CONNECTION (connection_by_uuid), NULL);
+
+					/* signal_remove() will end up removing the connection from our hash,
+					 * so add it back now.
+					 */
+					g_hash_table_insert (priv->connections,
+					                     g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection_by_uuid))),
+					                     connection_by_uuid);
+				}
+			} else {
+				if (old_unmanaged /* && !new_unmanaged */) {
+					_LOGI ("Managing connection "NM_IFCFG_CONNECTION_LOG_FMT" and its device because NM_CONTROLLED was true.",
+					       NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
+					g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_by_uuid);
+				} else if (old_unrecognized /* && !new_unrecognized */) {
+					_LOGI ("Managing connection "NM_IFCFG_CONNECTION_LOG_FMT" because it is now a recognized type.",
+					       NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
+					g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_by_uuid);
+				}
+			}
 
-	nm_log_info (LOGD_SETTINGS, "updating %s", path);
-	g_object_set (existing,
-	              NM_IFCFG_CONNECTION_UNMANAGED_SPEC, new_unmanaged,
-	              NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, new_unrecognized,
-	              NULL);
-
-	if (new_unmanaged || new_unrecognized) {
-		if (!old_unmanaged && !old_unrecognized) {
-			g_object_ref (existing);
-			/* Unexport the connection by telling the settings service it's
-			 * been removed.
-			 */
-			nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (existing));
-			/* Remove the path so that claim_connection() doesn't complain later when
-			 * interface gets managed and connection is re-added. */
-			nm_connection_set_path (NM_CONNECTION (existing), NULL);
-
-			/* signal_remove() will end up removing the connection from our hash,
-			 * so add it back now.
-			 */
-			g_hash_table_insert (priv->connections,
-			                     g_strdup (nm_connection_get_uuid (NM_CONNECTION (existing))),
-			                     existing);
+			if (unmanaged_changed)
+				g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
+			if (unrecognized_changed)
+				g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED);
 		}
+		nm_settings_connection_set_filename (NM_SETTINGS_CONNECTION (connection_by_uuid), full_path);
+		g_object_unref (connection_new);
+		return connection_by_uuid;
 	} else {
-		const char *cid = nm_connection_get_id (NM_CONNECTION (new));
-
-		if (old_unmanaged /* && !new_unmanaged */) {
-			nm_log_info (LOGD_SETTINGS, "Managing connection '%s' and its device because NM_CONTROLLED was true.", cid);
-			g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, existing);
-		} else if (old_unrecognized /* && !new_unrecognized */) {
-			nm_log_info (LOGD_SETTINGS, "Managing connection '%s' because it is now a recognized type.", cid);
-			g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, existing);
-		}
 
-		if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (existing),
-		                                              NM_CONNECTION (new),
-		                                              FALSE,  /* don't set Unsaved */
-		                                              &error)) {
-			/* Shouldn't ever get here as 'new' was verified by the reader already */
-			g_assert_no_error (error);
+		/*******************************************************
+		 * ADD
+		 *******************************************************/
+
+		if (source)
+			_LOGI ("add connection "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
+		else
+			_LOGI ("new connection "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
+		g_hash_table_insert (priv->connections, g_strdup (uuid), connection_new);
+
+		g_signal_connect (connection_new, NM_SETTINGS_CONNECTION_REMOVED,
+		                  G_CALLBACK (connection_removed_cb),
+		                  self);
+
+		if (nm_ifcfg_connection_get_unmanaged_spec (connection_new)) {
+			const char *spec;
+			const char *device_id;
+
+			spec = nm_ifcfg_connection_get_unmanaged_spec (connection_new);
+			device_id = strchr (spec, ':');
+			if (device_id)
+				device_id++;
+			else
+				device_id = spec;
+			_LOGW ("Ignoring connection "NM_IFCFG_CONNECTION_LOG_FMT" / device '%s' due to NM_CONTROLLED=no.",
+			       NM_IFCFG_CONNECTION_LOG_ARG (connection_new), device_id);
+		} else if (nm_ifcfg_connection_get_unrecognized_spec (connection_new))
+			_LOGW ("Ignoring connection "NM_IFCFG_CONNECTION_LOG_FMT" of unrecognized type.", NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
+
+		/* watch changes of ifcfg hardlinks */
+		g_signal_connect (G_OBJECT (connection_new), "ifcfg-changed",
+		                  G_CALLBACK (connection_ifcfg_changed), self);
+
+		if (!source) {
+			/* Only raise the signal if we were called without source, i.e. if we read the connection from file.
+			 * Otherwise, we were called by add_connection() which does not expect the signal. */
+			if (nm_ifcfg_connection_get_unmanaged_spec (connection_new))
+				g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
+			else if (nm_ifcfg_connection_get_unrecognized_spec (connection_new))
+				g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED);
+			else
+				g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_new);
 		}
+		return connection_new;
 	}
-	g_object_unref (new);
-
-	if (unmanaged_changed)
-		g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
-	if (unrecognized_changed)
-		g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED);
 }
 
 static void
@@ -385,6 +430,8 @@ ifcfg_dir_changed (GFileMonitor *monitor,
 		return;
 	}
 
+	_LOGD ("ifcfg_dir_changed(%s) = %d", path, event_type);
+
 	base = g_file_get_basename (file);
 	if (utils_is_ifcfg_alias_file (base, NULL)) {
 		/* Alias file changed. Get the base ifcfg file from it */
@@ -397,14 +444,13 @@ ifcfg_dir_changed (GFileMonitor *monitor,
 		connection = find_by_path (plugin, ifcfg_path);
 		switch (event_type) {
 		case G_FILE_MONITOR_EVENT_DELETED:
-			nm_log_info (LOGD_SETTINGS, "removed %s.", ifcfg_path);
 			if (connection)
 				remove_connection (plugin, connection);
 			break;
 		case G_FILE_MONITOR_EVENT_CREATED:
 		case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
 			/* Update or new */
-			connection_new_or_changed (plugin, ifcfg_path, connection, NULL);
+			update_connection (plugin, NULL, ifcfg_path, connection, TRUE, NULL, NULL);
 			break;
 		default:
 			break;
@@ -433,6 +479,43 @@ setup_ifcfg_monitoring (SCPluginIfcfg *plugin)
 	}
 }
 
+static GHashTable *
+_paths_from_connections (GHashTable *connections)
+{
+	GHashTableIter iter;
+	NMIfcfgConnection *connection;
+	GHashTable *paths = g_hash_table_new (g_str_hash, g_str_equal);
+
+	g_hash_table_iter_init (&iter, connections);
+	while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) {
+		const char *path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection));
+
+		if (path)
+			g_hash_table_add (paths, (void *) path);
+	}
+	return paths;
+}
+
+static int
+_sort_paths (const char **f1, const char **f2, GHashTable *paths)
+{
+	struct stat st;
+	gboolean c1, c2;
+	gint64 m1, m2;
+
+	c1 = !!g_hash_table_contains (paths, *f1);
+	c2 = !!g_hash_table_contains (paths, *f2);
+	if (c1 != c2)
+		return c1 ? -1 : 1;
+
+	m1 = stat (*f1, &st) == 0 ? (gint64) st.st_mtime : G_MININT64;
+	m2 = stat (*f2, &st) == 0 ? (gint64) st.st_mtime : G_MININT64;
+	if (m1 != m2)
+		return m1 > m2 ? -1 : 1;
+
+	return strcmp (*f1, *f2);
+}
+
 static void
 read_connections (SCPluginIfcfg *plugin)
 {
@@ -440,28 +523,26 @@ read_connections (SCPluginIfcfg *plugin)
 	GDir *dir;
 	GError *err = NULL;
 	const char *item;
-	GHashTable *oldconns;
+	GHashTable *alive_connections;
 	GHashTableIter iter;
-	gpointer key, value;
 	NMIfcfgConnection *connection;
+	GPtrArray *dead_connections = NULL;
+	guint i;
+	GPtrArray *filenames;
+	GHashTable *paths;
 
 	dir = g_dir_open (IFCFG_DIR, 0, &err);
 	if (!dir) {
-		nm_log_warn (LOGD_SETTINGS, "Could not read directory '%s': %s", IFCFG_DIR, err->message);
+		_LOGW ("Could not read directory '%s': %s", IFCFG_DIR, err->message);
 		g_error_free (err);
 		return;
 	}
 
-	oldconns = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-	g_hash_table_iter_init (&iter, priv->connections);
-	while (g_hash_table_iter_next (&iter, NULL, &value)) {
-		const char *ifcfg_path = nm_ifcfg_connection_get_path (value);
-		if (ifcfg_path)
-			g_hash_table_insert (oldconns, g_strdup (ifcfg_path), value);
-	}
+	alive_connections = g_hash_table_new (NULL, NULL);
 
+	filenames = g_ptr_array_new_with_free_func (g_free);
 	while ((item = g_dir_read_name (dir))) {
-		char *full_path, *old_path;
+		char *full_path;
 
 		if (utils_should_ignore_file (item, TRUE))
 			continue;
@@ -470,31 +551,45 @@ read_connections (SCPluginIfcfg *plugin)
 
 		full_path = g_build_filename (IFCFG_DIR, item, NULL);
 		if (!utils_get_ifcfg_name (full_path, TRUE))
-			goto next;
+			g_free (full_path);
+		else
+			g_ptr_array_add (filenames, full_path);
+	}
+	g_dir_close (dir);
 
-		connection = g_hash_table_lookup (oldconns, full_path);
-		g_hash_table_remove (oldconns, full_path);
-		connection_new_or_changed (plugin, full_path, connection, &old_path);
+	/* While reloading, we don't replace connections that we already loaded while
+	 * iterating over the files.
+	 *
+	 * To have sensible, reproducible behavior, sort the paths by last modification
+	 * time prefering older files.
+	 */
+	paths = _paths_from_connections (priv->connections);
+	g_ptr_array_sort_with_data (filenames, (GCompareDataFunc) _sort_paths, paths);
+	g_hash_table_destroy (paths);
+
+	for (i = 0; i < filenames->len; i++) {
+		connection = update_connection (plugin, NULL, filenames->pdata[i], NULL, FALSE, alive_connections, NULL);
+		if (connection)
+			g_hash_table_add (alive_connections, connection);
+	}
+	g_ptr_array_free (filenames, TRUE);
 
-		if (old_path) {
-			g_hash_table_remove (oldconns, old_path);
-			g_free (old_path);
+	g_hash_table_iter_init (&iter, priv->connections);
+	while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) {
+		if (   !g_hash_table_contains (alive_connections, connection)
+		    && nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection))) {
+			if (!dead_connections)
+				dead_connections = g_ptr_array_new ();
+			g_ptr_array_add (dead_connections, connection);
 		}
-
-	next:
-		g_free (full_path);
 	}
+	g_hash_table_destroy (alive_connections);
 
-	g_dir_close (dir);
-
-	g_hash_table_iter_init (&iter, oldconns);
-	while (g_hash_table_iter_next (&iter, &key, &value)) {
-		nm_log_info (LOGD_SETTINGS, "removed %s.", (char *)key);
-		g_hash_table_iter_remove (&iter);
-		remove_connection (plugin, value);
+	if (dead_connections) {
+		for (i = 0; i < dead_connections->len; i++)
+			remove_connection (plugin, dead_connections->pdata[i]);
+		g_ptr_array_free (dead_connections, TRUE);
 	}
-
-	g_hash_table_destroy (oldconns);
 }
 
 static GSList *
@@ -540,7 +635,7 @@ load_connection (NMSystemConfigInterface *config,
 		return FALSE;
 
 	connection = find_by_path (plugin, filename);
-	connection_new_or_changed (plugin, filename, connection, NULL);
+	update_connection (plugin, NULL, filename, connection, TRUE, NULL, NULL);
 	if (!connection)
 		connection = find_by_path (plugin, filename);
 
@@ -605,8 +700,7 @@ add_connection (NMSystemConfigInterface *config,
                 GError **error)
 {
 	SCPluginIfcfg *self = SC_PLUGIN_IFCFG (config);
-	NMIfcfgConnection *added = NULL;
-	char *path = NULL;
+	gs_free char *path = NULL;
 
 	/* Ensure we reject attempts to add the connection long before we're
 	 * asked to write it to disk.
@@ -618,10 +712,7 @@ add_connection (NMSystemConfigInterface *config,
 		if (!writer_new_connection (connection, IFCFG_DIR, &path, error))
 			return NULL;
 	}
-
-	added = _internal_new_connection (self, path, connection, error);
-	g_free (path);
-	return (NMSettingsConnection *) added;
+	return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error));
 }
 
 #define SC_NETWORK_FILE "/etc/sysconfig/network"
@@ -641,7 +732,7 @@ plugin_get_hostname (SCPluginIfcfg *plugin)
 
 	network = svOpenFile (SC_NETWORK_FILE, NULL);
 	if (!network) {
-		nm_log_warn (LOGD_SETTINGS, "Could not get hostname: failed to read " SC_NETWORK_FILE);
+		_LOGW ("Could not get hostname: failed to read " SC_NETWORK_FILE);
 		return NULL;
 	}
 
@@ -693,7 +784,7 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname)
 #endif
 
 	if (!ret) {
-		nm_log_warn (LOGD_SETTINGS, "Could not save hostname: failed to create/open " HOSTNAME_FILE);
+		_LOGW ("Could not save hostname: failed to create/open " HOSTNAME_FILE);
 		g_free (hostname_eol);
 		return FALSE;
 	}
@@ -862,7 +953,7 @@ sc_plugin_ifcfg_init (SCPluginIfcfg *plugin)
 
 	priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
 	if (!priv->bus) {
-		nm_log_warn (LOGD_SETTINGS, "Couldn't connect to D-Bus: %s", error->message);
+		_LOGW ("Couldn't connect to D-Bus: %s", error->message);
 		g_clear_error (&error);
 	} else {
 		DBusConnection *tmp;
@@ -883,10 +974,10 @@ sc_plugin_ifcfg_init (SCPluginIfcfg *plugin)
 		                        G_TYPE_INVALID,
 		                        G_TYPE_UINT, &result,
 		                        G_TYPE_INVALID)) {
-			nm_log_warn (LOGD_SETTINGS, "Couldn't acquire D-Bus service: %s", error->message);
+			_LOGW ("Couldn't acquire D-Bus service: %s", error->message);
 			g_clear_error (&error);
 		} else if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
-			nm_log_warn (LOGD_SETTINGS, "Couldn't acquire ifcfgrh1 D-Bus service (already taken)");
+			_LOGW ("Couldn't acquire ifcfgrh1 D-Bus service (already taken)");
 		} else
 			success = TRUE;
 	}
@@ -1048,7 +1139,7 @@ nm_system_config_factory (void)
 			dbus_g_connection_register_g_object (priv->bus,
 			                                     DBUS_OBJECT_PATH,
 			                                     G_OBJECT (singleton));
-		nm_log_info (LOGD_SETTINGS, "Acquired D-Bus service %s", DBUS_SERVICE_NAME);
+		_LOGI ("Acquired D-Bus service %s", DBUS_SERVICE_NAME);
 	} else
 		g_object_ref (singleton);
 
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
index 145a0a39..41439f61 100644
--- a/src/settings/plugins/ifcfg-rh/reader.c
+++ b/src/settings/plugins/ifcfg-rh/reader.c
@@ -56,6 +56,7 @@
 #include "nm-posix-signals.h"
 #include "NetworkManagerUtils.h"
 #include "nm-logging.h"
+#include "gsystem-local-alloc.h"
 
 #include "common.h"
 #include "shvar.h"
@@ -292,9 +293,11 @@ get_numbered_tag (char *tag_name, int which)
 }
 
 static gboolean
-is_any_ip4_address_defined (shvarFile *ifcfg)
+is_any_ip4_address_defined (shvarFile *ifcfg, int *idx)
 {
-	int i;
+	int i, ignore, *ret_idx;;
+
+	ret_idx = idx ? idx : &ignore;
 
 	for (i = -1; i <= 2; i++) {
 		char *tag;
@@ -305,6 +308,7 @@ is_any_ip4_address_defined (shvarFile *ifcfg)
 		g_free (tag);
 		if (value) {
 			g_free (value);
+			*ret_idx = i;
 			return TRUE;
 		}
 
@@ -313,6 +317,7 @@ is_any_ip4_address_defined (shvarFile *ifcfg)
 		g_free(tag);
 		if (value) {
 			g_free (value);
+			*ret_idx = i;
 			return TRUE;
 		}
 
@@ -321,6 +326,7 @@ is_any_ip4_address_defined (shvarFile *ifcfg)
 		g_free(tag);
 		if (value) {
 			g_free (value);
+			*ret_idx = i;
 			return TRUE;
 		}
 	}
@@ -534,8 +540,6 @@ read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError *
 	char **lines = NULL, **iter;
 	GRegex *regex_to1, *regex_to2, *regex_via, *regex_metric;
 	GMatchInfo *match_info;
-	NMIPRoute *route = NULL;
-	char *dest = NULL, *prefix = NULL, *next_hop = NULL, *metric = NULL;
 	gint64 prefix_int, metric_int;
 	gboolean success = FALSE;
 
@@ -567,6 +571,9 @@ read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError *
 	/* Iterate through file lines */
 	lines = g_strsplit_set (contents, "\n\r", -1);
 	for (iter = lines; iter && *iter; iter++) {
+		gs_free char *next_hop = NULL, *dest = NULL;
+		char *prefix, *metric;
+		NMIPRoute *route;
 
 		/* Skip empty lines */
 		if (g_regex_match_simple (pattern_empty, *iter, 0, 0))
@@ -586,11 +593,10 @@ read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError *
 		}
 		dest = g_match_info_fetch (match_info, 1);
 		if (!strcmp (dest, "default"))
-			strcpy (dest, "0.0.0.0");
+			strcpy (dest,  "0.0.0.0");
 		if (!nm_utils_ipaddr_valid (AF_INET, dest)) {
 			g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 			             "Invalid IP4 route destination address '%s'", dest);
-			g_free (dest);
 			g_match_info_free (match_info);
 			goto error;
 		}
@@ -605,7 +611,6 @@ read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError *
 			if (errno || prefix_int <= 0 || prefix_int > 32) {
 				g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				             "Invalid IP4 route destination prefix '%s'", prefix);
-				g_free (dest);
 				g_free (prefix);
 				goto error;
 			}
@@ -621,13 +626,10 @@ read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError *
 				             "Invalid IP4 route gateway address '%s'",
 				             next_hop);
 				g_match_info_free (match_info);
-				g_free (dest);
-				g_free (next_hop);
 				goto error;
 			}
 		} else {
 			/* we don't make distinction between missing GATEWAY IP and 0.0.0.0 */
-			next_hop = NULL;
 		}
 		g_match_info_free (match_info);
 
@@ -642,8 +644,6 @@ read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError *
 				g_match_info_free (match_info);
 				g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
 				             "Invalid IP4 route metric '%s'", metric);
-				g_free (dest);
-				g_free (next_hop);
 				g_free (metric);
 				goto error;
 			}
@@ -652,13 +652,11 @@ read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError *
 		g_match_info_free (match_info);
 
 		route = nm_ip_route_new (AF_INET, dest, prefix_int, next_hop, metric_int, error);
-		if (!route) {
-			g_free (dest);
-			g_free (next_hop);
+		if (!route)
 			goto error;
-		}
 		if (!nm_setting_ip_config_add_route (s_ip4, route))
 			PARSE_WARNING ("duplicate IP4 route");
+		nm_ip_route_unref (route);
 	}
 
 	success = TRUE;
@@ -666,8 +664,6 @@ read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError *
 error:
 	g_free (contents);
 	g_strfreev (lines);
-	if (route)
-		nm_ip_route_unref (route);
 	g_regex_unref (regex_to1);
 	g_regex_unref (regex_to2);
 	g_regex_unref (regex_via);
@@ -743,7 +739,6 @@ read_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error
 	char **lines = NULL, **iter;
 	GRegex *regex_to1, *regex_to2, *regex_via, *regex_metric;
 	GMatchInfo *match_info;
-	NMIPRoute *route = NULL;
 	char *dest = NULL, *prefix = NULL, *next_hop = NULL, *metric = NULL;
 	gint64 prefix_int, metric_int;
 	gboolean success = FALSE;
@@ -776,6 +771,7 @@ read_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error
 	/* Iterate through file lines */
 	lines = g_strsplit_set (contents, "\n\r", -1);
 	for (iter = lines; iter && *iter; iter++) {
+		NMIPRoute *route;
 
 		/* Skip empty lines */
 		if (g_regex_match_simple (pattern_empty, *iter, 0, 0))
@@ -865,6 +861,7 @@ read_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error
 			goto error;
 		if (!nm_setting_ip_config_add_route (s_ip6, route))
 			PARSE_WARNING ("duplicate IP6 route");
+		nm_ip_route_unref (route);
 	}
 
 	success = TRUE;
@@ -872,8 +869,6 @@ read_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error
 error:
 	g_free (contents);
 	g_strfreev (lines);
-	if (route)
-		nm_ip_route_unref (route);
 	g_regex_unref (regex_to1);
 	g_regex_unref (regex_to2);
 	g_regex_unref (regex_via);
@@ -892,7 +887,7 @@ make_ip4_setting (shvarFile *ifcfg,
 	char *value = NULL;
 	char *route_path = NULL;
 	char *method;
-	char *gateway = NULL;
+	gs_free char *gateway = NULL;
 	gint32 i;
 	shvarFile *network_ifcfg;
 	shvarFile *route_ifcfg;
@@ -930,7 +925,7 @@ make_ip4_setting (shvarFile *ifcfg,
 	value = svGetValue (ifcfg, "BOOTPROTO", FALSE);
 
 	if (!value || !*value || !g_ascii_strcasecmp (value, "none")) {
-		if (is_any_ip4_address_defined (ifcfg))
+		if (is_any_ip4_address_defined (ifcfg, NULL))
 			method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
 		else
 			method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
@@ -946,11 +941,25 @@ make_ip4_setting (shvarFile *ifcfg,
 		              NULL);
 		return NM_SETTING (s_ip4);
 	} else if (!g_ascii_strcasecmp (value, "shared")) {
+		int idx;
+
 		g_free (value);
 		g_object_set (s_ip4,
 		              NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_SHARED,
 		              NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default,
 		              NULL);
+		/* 1 IP address is allowed for shared connections. Read it. */
+		if (is_any_ip4_address_defined (ifcfg, &idx)) {
+			NMIPAddress *addr = NULL;
+
+			if (!read_full_ip4_address (ifcfg, network_file, idx, NULL, &addr, NULL, error))
+				goto done;
+			if (!read_ip4_address (ifcfg, "GATEWAY", &gateway, error))
+				goto done;
+			(void) nm_setting_ip_config_add_address (s_ip4, addr);
+			nm_ip_address_unref (addr);
+			g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway, NULL);
+		}
 		return NM_SETTING (s_ip4);
 	} else {
 		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
@@ -966,6 +975,8 @@ make_ip4_setting (shvarFile *ifcfg,
 	              NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svTrueValue (ifcfg, "PEERROUTES", TRUE),
 	              NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default,
 	              NM_SETTING_IP_CONFIG_MAY_FAIL, !svTrueValue (ifcfg, "IPV4_FAILURE_FATAL", FALSE),
+	              NM_SETTING_IP_CONFIG_ROUTE_METRIC, svGetValueInt64 (ifcfg, "IPV4_ROUTE_METRIC", 10,
+	                                                                  -1, G_MAXUINT32, -1),
 	              NULL);
 
 	if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0)
@@ -997,6 +1008,8 @@ make_ip4_setting (shvarFile *ifcfg,
 	for (i = -1; i < 256; i++) {
 		NMIPAddress *addr = NULL;
 
+		/* 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))
 			goto done;
 
@@ -1075,14 +1088,10 @@ make_ip4_setting (shvarFile *ifcfg,
 
 	/* Static routes  - route-<name> file */
 	route_path = utils_get_route_path (ifcfg->fileName);
-	if (!route_path) {
-		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
-		             "Could not get route file path for '%s'", ifcfg->fileName);
-		goto done;
-	}
 
-	/* First test new/legacy syntax */
-	if (utils_has_route_file_new_syntax (route_path)) {
+	if (utils_has_complex_routes (route_path)) {
+		PARSE_WARNING ("'rule-' or 'rule6-' file is present; you will need to use a dispatcher script to apply these routes");
+	} else if (utils_has_route_file_new_syntax (route_path)) {
 		/* Parse route file in new syntax */
 		route_ifcfg = utils_get_route_ifcfg (ifcfg->fileName, FALSE);
 		if (route_ifcfg) {
@@ -1107,6 +1116,7 @@ make_ip4_setting (shvarFile *ifcfg,
 		if (!read_route_file_legacy (route_path, s_ip4, error))
 			goto done;
 	}
+	g_free (route_path);
 
 	/* Legacy value NM used for a while but is incorrect (rh #459370) */
 	if (!nm_setting_ip_config_get_num_dns_searches (s_ip4)) {
@@ -1132,7 +1142,6 @@ make_ip4_setting (shvarFile *ifcfg,
 	return NM_SETTING (s_ip4);
 
 done:
-	g_free (gateway);
 	g_free (route_path);
 	g_object_unref (s_ip4);
 	return NULL;
@@ -1362,6 +1371,8 @@ make_ip6_setting (shvarFile *ifcfg,
 	              NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svTrueValue (ifcfg, "IPV6_PEERROUTES", TRUE),
 	              NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default,
 	              NM_SETTING_IP_CONFIG_MAY_FAIL, !svTrueValue (ifcfg, "IPV6_FAILURE_FATAL", FALSE),
+	              NM_SETTING_IP_CONFIG_ROUTE_METRIC, svGetValueInt64 (ifcfg, "IPV6_ROUTE_METRIC", 10,
+	                                                                  -1, G_MAXUINT32, -1),
 	              NM_SETTING_IP6_CONFIG_IP6_PRIVACY, ip6_privacy_val,
 	              NULL);
 
@@ -1467,18 +1478,15 @@ make_ip6_setting (shvarFile *ifcfg,
 
 	/* DNS searches ('DOMAIN' key) are read by make_ip4_setting() and included in NMSettingIPConfig */
 
-	/* Read static routes from route6-<interface> file */
-	route6_path = utils_get_route6_path (ifcfg->fileName);
-	if (!route6_path) {
-		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
-		             "Could not get route6 file path for '%s'", ifcfg->fileName);
-		goto error;
-	}
+	if (!utils_has_complex_routes (ifcfg->fileName)) {
+		/* Read static routes from route6-<interface> file */
+		route6_path = utils_get_route6_path (ifcfg->fileName);
+		if (!read_route6_file (route6_path, s_ip6, error))
+			goto error;
 
-	if (!read_route6_file (route6_path, s_ip6, error))
-		goto error;
+		g_free (route6_path);
+	}
 
-	g_free (route6_path);
 	return NM_SETTING (s_ip6);
 
 error:
@@ -3061,7 +3069,8 @@ make_wpa_setting (shvarFile *ifcfg,
 			if (psk) {
 				g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_PSK, psk, NULL);
 				g_free (psk);
-			}
+			} else if (error)
+				goto error;
 		}
 
 		if (adhoc)
@@ -3174,6 +3183,8 @@ make_wireless_security_setting (shvarFile *ifcfg,
 {
 	NMSetting *wsec;
 
+	g_return_val_if_fail (error && !*error, NULL);
+
 	if (!adhoc) {
 		wsec = make_leap_setting (ifcfg, file, error);
 		if (wsec)
@@ -3425,11 +3436,11 @@ wireless_connection_from_ifcfg (const char *file,
 	char *printable_ssid = NULL;
 	const char *mode;
 	gboolean adhoc = FALSE;
+	GError *local = NULL;
 
 	g_return_val_if_fail (file != NULL, NULL);
 	g_return_val_if_fail (ifcfg != NULL, NULL);
-	g_return_val_if_fail (error != NULL, NULL);
-	g_return_val_if_fail (*error == NULL, NULL);
+	g_return_val_if_fail (!error || !*error, NULL);
 
 	connection = nm_simple_connection_new ();
 
@@ -3453,10 +3464,11 @@ wireless_connection_from_ifcfg (const char *file,
 		adhoc = TRUE;
 
 	/* Wireless security */
-	security_setting = make_wireless_security_setting (ifcfg, file, ssid, adhoc, &s_8021x, error);
-	if (*error) {
+	security_setting = make_wireless_security_setting (ifcfg, file, ssid, adhoc, &s_8021x, &local);
+	if (local) {
 		g_free (printable_ssid);
 		g_object_unref (connection);
+		g_propagate_error (error, local);
 		return NULL;
 	}
 	if (security_setting) {
@@ -3838,7 +3850,8 @@ handle_bond_option (NMSettingBond *s_bond,
 	}
 
 	if (!nm_setting_bond_add_option (s_bond, key, sanitized ? sanitized : value))
-		PARSE_WARNING ("invalid bonding option '%s'", key);
+		PARSE_WARNING ("invalid bonding option '%s' = %s",
+		               key, sanitized ? sanitized : value);
 	g_free (sanitized);
 }
 
@@ -4443,6 +4456,7 @@ make_vlan_setting (shvarFile *ifcfg,
 		goto error;
 	}
 	g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, parent, NULL);
+	g_clear_pointer (&parent, g_free);
 
 	if (svTrueValue (ifcfg, "REORDER_HDR", FALSE))
 		vlan_flags |= NM_VLAN_FLAG_REORDER_HEADERS;
@@ -4461,6 +4475,8 @@ make_vlan_setting (shvarFile *ifcfg,
 	parse_prio_map_list (s_vlan, ifcfg, "VLAN_INGRESS_PRIORITY_MAP", NM_VLAN_INGRESS_MAP);
 	parse_prio_map_list (s_vlan, ifcfg, "VLAN_EGRESS_PRIORITY_MAP", NM_VLAN_EGRESS_MAP);
 
+	g_free (iface_name);
+
 	return (NMSetting *) s_vlan;
 
 error:
@@ -4624,32 +4640,24 @@ check_dns_search_domains (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6)
 	}
 }
 
-NMConnection *
-connection_from_file (const char *filename,
-                      const char *network_file,  /* for unit tests only */
-                      const char *test_type,     /* for unit tests only */
-                      char **out_unhandled,
-                      char **out_keyfile,
-                      char **out_routefile,
-                      char **out_route6file,
-                      GError **error,
-                      gboolean *out_ignore_error)
+static NMConnection *
+connection_from_file_full (const char *filename,
+                           const char *network_file,  /* for unit tests only */
+                           const char *test_type,     /* for unit tests only */
+                           char **out_unhandled,
+                           GError **error,
+                           gboolean *out_ignore_error)
 {
 	NMConnection *connection = NULL;
 	shvarFile *parsed;
-	char *type, *devtype, *bootproto;
+	gs_free char *type = NULL;
+	char *devtype, *bootproto;
 	NMSetting *s_ip4, *s_ip6, *s_port, *s_dcb = NULL;
 	const char *ifcfg_name = NULL;
 
 	g_return_val_if_fail (filename != NULL, NULL);
 	if (out_unhandled)
 		g_return_val_if_fail (*out_unhandled == NULL, NULL);
-	if (out_keyfile)
-		g_return_val_if_fail (*out_keyfile == NULL, NULL);
-	if (out_routefile)
-		g_return_val_if_fail (*out_routefile == NULL, NULL);
-	if (out_route6file)
-		g_return_val_if_fail (*out_route6file == NULL, NULL);
 
 	/* Non-NULL only for unit tests; normally use /etc/sysconfig/network */
 	if (!network_file)
@@ -4685,8 +4693,7 @@ connection_from_file (const char *filename,
 		g_free (bootproto);
 		goto done;
 	}
-
-	type = NULL;
+	g_free (bootproto);
 
 	devtype = svGetValue (parsed, "DEVICETYPE", FALSE);
 	if (devtype) {
@@ -4775,7 +4782,6 @@ connection_from_file (const char *filename,
 			PARSE_WARNING ("connection type was unrecognized but device was not uniquely identified; device may be managed");
 		goto done;
 	}
-	g_free (type);
 
 	if (!connection)
 		goto done;
@@ -4827,15 +4833,64 @@ connection_from_file (const char *filename,
 		connection = NULL;
 	}
 
-	if (out_keyfile)
-		*out_keyfile = utils_get_keys_path (filename);
-	if (out_routefile)
-		*out_routefile = utils_get_route_path (filename);
-	if (out_route6file)
-		*out_route6file = utils_get_route6_path (filename);
-
 done:
 	svCloseFile (parsed);
 	return connection;
 }
 
+NMConnection *
+connection_from_file (const char *filename,
+                      char **out_unhandled,
+                      GError **error)
+{
+	gboolean ignore_error = FALSE;
+	NMConnection *conn;
+
+	conn = connection_from_file_full (filename, NULL, NULL,
+	                                  out_unhandled,
+	                                  error,
+	                                  &ignore_error);
+	if (error && *error && !ignore_error)
+		PARSE_WARNING ("%s", (*error)->message);
+	return conn;
+}
+
+NMConnection *
+connection_from_file_test (const char *filename,
+                           const char *network_file,
+                           const char *test_type,
+                           char **out_unhandled,
+                           GError **error)
+{
+	return connection_from_file_full (filename,
+	                                  network_file,
+	                                  test_type,
+	                                  out_unhandled,
+	                                  error,
+	                                  NULL);
+}
+
+guint
+devtimeout_from_file (const char *filename)
+{
+	shvarFile *ifcfg;
+	char *devtimeout_str;
+	guint devtimeout;
+
+	g_return_val_if_fail (filename != NULL, 0);
+
+	ifcfg = svOpenFile (filename, NULL);
+	if (!ifcfg)
+		return 0;
+
+	devtimeout_str = svGetValue (ifcfg, "DEVTIMEOUT", FALSE);
+	if (devtimeout_str) {
+		devtimeout = nm_utils_ascii_str_to_int64 (devtimeout_str, 10, 0, G_MAXUINT, 0);
+		g_free (devtimeout_str);
+	} else
+		devtimeout = 0;
+
+	svCloseFile (ifcfg);
+
+	return devtimeout;
+}
diff --git a/src/settings/plugins/ifcfg-rh/reader.h b/src/settings/plugins/ifcfg-rh/reader.h
index c23e5870..70e9ce4e 100644
--- a/src/settings/plugins/ifcfg-rh/reader.h
+++ b/src/settings/plugins/ifcfg-rh/reader.h
@@ -27,15 +27,18 @@
 #include "shvar.h"
 
 NMConnection *connection_from_file (const char *filename,
-                                    const char *network_file,  /* for unit tests only */
-                                    const char *test_type,     /* for unit tests only */
                                     char **out_unhandled,
-                                    char **out_keyfile,
-                                    char **out_routefile,
-                                    char **out_route6file,
-                                    GError **error,
-                                    gboolean *out_ignore_error);
+                                    GError **error);
 
 char *uuid_from_file (const char *filename);
 
+guint devtimeout_from_file (const char *filename);
+
+/* for test-ifcfg-rh */
+NMConnection *connection_from_file_test (const char *filename,
+                                         const char *network_file,
+                                         const char *test_type,
+                                         char **out_unhandled,
+                                         GError **error);
+
 #endif  /* __READER_H__ */
diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c
index 6c9769b2..5f3d173b 100644
--- a/src/settings/plugins/ifcfg-rh/shvar.c
+++ b/src/settings/plugins/ifcfg-rh/shvar.c
@@ -372,10 +372,12 @@ svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim)
 		if (oldval) {
 			/* delete line */
 			s->lineList = g_list_remove_link (s->lineList, s->current);
+			g_free (s->current->data);
 			g_list_free_1 (s->current);
 			s->modified = TRUE;
 		}
-		goto bail; /* do not need keyValue */
+		g_free (keyValue);
+		goto end;
 	}
 
 	if (!oldval) {
@@ -387,21 +389,19 @@ svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim)
 
 	if (strcmp (oldval, newval) != 0) {
 		/* change line */
-		if (s->current)
+		if (s->current) {
+			g_free (s->current->data);
 			s->current->data = keyValue;
-		else
+		} else
 			s->lineList = g_list_append (s->lineList, keyValue);
 		s->modified = TRUE;
-	}
+	} else
+		g_free (keyValue);
 
  end:
 	g_free (newval);
 	g_free (oldval);
 	return;
-
- bail:
-	g_free (keyValue);
-	goto end;
 }
 
 /* Write the current contents iff modified.  Returns FALSE on error
diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/Makefile.am
index 5a17ed9b..a3f6a052 100644
--- a/src/settings/plugins/ifcfg-rh/tests/Makefile.am
+++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.am
@@ -47,6 +47,7 @@ test_ifcfg_rh_utils_SOURCES = \
 test_ifcfg_rh_utils_LDADD = \
 	$(top_builddir)/src/libNetworkManager.la
 
+@VALGRIND_RULES@
 TESTS = test-ifcfg-rh-utils test-ifcfg-rh
 
 endif
diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/Makefile.in
index f34e759d..d3c838a7 100644
--- a/src/settings/plugins/ifcfg-rh/tests/Makefile.in
+++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,17 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -83,8 +93,6 @@ host_triplet = @host@
 @ENABLE_TESTS_TRUE@TESTS = test-ifcfg-rh-utils$(EXEEXT) \
 @ENABLE_TESTS_TRUE@	test-ifcfg-rh$(EXEEXT)
 subdir = src/settings/plugins/ifcfg-rh/tests
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/build-aux/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \
 	$(top_srcdir)/m4/compiler_warnings.m4 \
@@ -101,6 +109,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \
 	$(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -226,6 +235,8 @@ am__tty_colors = { \
   fi; \
 }
 DIST_SUBDIRS = network-scripts
+am__DIST_COMMON = $(srcdir)/Makefile.in \
+	$(top_srcdir)/build-aux/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -277,7 +288,6 @@ CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
 CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
-DATADIRNAME = @DATADIRNAME@
 DBUS_CFLAGS = @DBUS_CFLAGS@
 DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@
 DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@
@@ -312,6 +322,7 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
 GNUTLS_LIBS = @GNUTLS_LIBS@
 GREP = @GREP@
 GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@
 GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
 GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
 GTKDOC_MKPDF = @GTKDOC_MKPDF@
@@ -570,7 +581,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -624,14 +634,14 @@ distclean-compile:
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
 
 .c.obj:
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .c.lo:
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -1073,9 +1083,13 @@ uninstall-am:
 	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
 	uninstall-am
 
+.PRECIOUS: Makefile
+
 
 @ENABLE_TESTS_TRUE@@GNOME_CODE_COVERAGE_RULES@
 
+@ENABLE_TESTS_TRUE@@VALGRIND_RULES@
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
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 8941da3a..a20a78d9 100644
--- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am
@@ -9,10 +9,12 @@ EXTRA_DIST = \
 	ifcfg-test-wired-static-bootproto \
 	ifcfg-test-wired-dhcp \
 	ifcfg-test-wired-dhcp-plus-ip \
+	ifcfg-test-wired-shared-plus-ip \
 	ifcfg-test-wired-dhcp-send-hostname \
 	ifcfg-test-wired-dhcp6-only \
 	ifcfg-test-wired-global-gateway \
 	network-test-wired-global-gateway \
+	ifcfg-test-wired-obsolete-gateway-n \
 	ifcfg-test-wired-never-default \
 	network-test-wired-never-default \
 	ifcfg-test-wired-defroute-no \
@@ -106,6 +108,7 @@ EXTRA_DIST = \
 	ifcfg-test-bond-main \
 	ifcfg-test-bond-slave \
 	ifcfg-test-bond-slave-ib \
+	ifcfg-test-bond-mode-numeric \
 	ifcfg-test-dcb \
 	ifcfg-test-dcb-default-app-priorities \
 	ifcfg-test-dcb-bad-booleans \
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in
index aac646f8..58798f77 100644
--- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -78,7 +88,6 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = src/settings/plugins/ifcfg-rh/tests/network-scripts
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \
 	$(top_srcdir)/m4/compiler_warnings.m4 \
@@ -95,6 +104,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \
 	$(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -119,6 +129,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ALL_LINGUAS = @ALL_LINGUAS@
@@ -145,7 +156,6 @@ CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
 CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
-DATADIRNAME = @DATADIRNAME@
 DBUS_CFLAGS = @DBUS_CFLAGS@
 DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@
 DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@
@@ -180,6 +190,7 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
 GNUTLS_LIBS = @GNUTLS_LIBS@
 GREP = @GREP@
 GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@
 GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
 GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
 GTKDOC_MKPDF = @GTKDOC_MKPDF@
@@ -391,10 +402,12 @@ EXTRA_DIST = \
 	ifcfg-test-wired-static-bootproto \
 	ifcfg-test-wired-dhcp \
 	ifcfg-test-wired-dhcp-plus-ip \
+	ifcfg-test-wired-shared-plus-ip \
 	ifcfg-test-wired-dhcp-send-hostname \
 	ifcfg-test-wired-dhcp6-only \
 	ifcfg-test-wired-global-gateway \
 	network-test-wired-global-gateway \
+	ifcfg-test-wired-obsolete-gateway-n \
 	ifcfg-test-wired-never-default \
 	network-test-wired-never-default \
 	ifcfg-test-wired-defroute-no \
@@ -488,6 +501,7 @@ EXTRA_DIST = \
 	ifcfg-test-bond-main \
 	ifcfg-test-bond-slave \
 	ifcfg-test-bond-slave-ib \
+	ifcfg-test-bond-mode-numeric \
 	ifcfg-test-dcb \
 	ifcfg-test-dcb-default-app-priorities \
 	ifcfg-test-dcb-bad-booleans \
@@ -532,7 +546,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -712,6 +725,8 @@ uninstall-am:
 	mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
 	uninstall-am
 
+.PRECIOUS: Makefile
+
 
 dist-hook:
 	@for f in $(ALIAS_FILES); do \
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bond-mode-numeric b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bond-mode-numeric
new file mode 100644
index 00000000..9989f58b
--- /dev/null
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bond-mode-numeric
@@ -0,0 +1,5 @@
+DEVICE=bond0
+ONBOOT=no
+TYPE=Bond
+BOOTPROTO=dhcp
+BONDING_OPTS="mode=4 miimon=100"
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main
index 8507628e..ee7a8dc6 100644
--- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main
@@ -3,6 +3,6 @@ ONBOOT=no
 TYPE=Bridge
 BOOTPROTO=dhcp
 STP=on
-DELAY=0
+DELAY=2
 BRIDGING_OPTS="priority=32744 hello_time=7 max_age=39 ageing_time=235352"
 MACADDR=00:16:41:11:22:33
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-open b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-open
index 48db45b2..b089103d 100644
--- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-open
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-open
@@ -12,3 +12,5 @@ ONBOOT=yes
 USERCTL=yes
 PEERDNS=yes
 IPV6INIT=no
+IPV4_ROUTE_METRIC=104
+IPV6_ROUTE_METRIC=106
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcp-plus-ip b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcp-plus-ip
index f0c022a9..af254f9c 100644
--- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcp-plus-ip
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-dhcp-plus-ip
@@ -15,11 +15,11 @@ DNS3=1:2:3:4::a
 DNS4=1:2:3:4::b
 
 # additional IPs
-IPADDR0=1.2.3.4
-PREFIX0=24
-GATEWAY0=1.1.1.1
+IPADDR=1.2.3.4
+PREFIX=24
 IPADDR1=9.8.7.6
 PREFIX1=16
+GATEWAY=1.1.1.1
 
 IPV6ADDR="1001:abba::1234/56"
 IPV6ADDR_SECONDARIES="2001:abba::2234/64 3001:abba::3234/96"
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-1 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-1
index cad0f6cf..1bc3d524 100644
--- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-1
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-1
@@ -5,8 +5,8 @@ HWADDR=00:11:22:33:44:ee
 BOOTPROTO=none
 IPADDR0=1.2.3.4
 PREFIX0=24
-GATEWAY0=1.1.1.1
 IPADDR1=9.8.7.6
 PREFIX1=16
 IPADDR2=3.3.3.3
 PREFIX2=8
+GATEWAY=1.1.1.1
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-2 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-2
index ad9290a4..d7273e36 100644
--- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-2
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-2
@@ -5,10 +5,7 @@ HWADDR=00:11:22:33:44:ee
 BOOTPROTO=none
 IPADDR=1.2.3.4
 PREFIX=24
-GATEWAY=1.1.1.1
 IPADDR2=9.8.7.6
 PREFIX2=16
-GATEWAY2=5.5.5.5
 IPADDR3=3.3.3.3
 PREFIX3=8
-GATEWAY3=7.7.7.7
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-obsolete-gateway-n b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-obsolete-gateway-n
new file mode 100644
index 00000000..2190a995
--- /dev/null
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-obsolete-gateway-n
@@ -0,0 +1,13 @@
+# GATEWAY<N> is obsolete, but we read it for backwards compatibility
+
+TYPE=Ethernet
+DEVICE=eth0
+HWADDR=00:11:22:33:44:ee
+BOOTPROTO=none
+ONBOOT=yes
+
+# manual IP
+IPADDR1=1.2.3.4
+PREFIX1=24
+GATEWAY1=1.1.1.1
+
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-shared-plus-ip b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-shared-plus-ip
new file mode 100644
index 00000000..5098aef7
--- /dev/null
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-shared-plus-ip
@@ -0,0 +1,19 @@
+# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile)
+TYPE=Ethernet
+DEVICE=eth0
+HWADDR=00:11:22:33:44:ee
+BOOTPROTO=shared
+ONBOOT=no
+IPV6INIT=yes
+
+# additional IPs
+IPADDR=10.20.30.5
+PREFIX=24
+GATEWAY=1.1.1.1
+
+# these are ignored for shared method
+IPADDR1=6.7.8.9
+PREFIX1=16
+IPADDR2=3.3.3.3
+PREFIX2=24
+
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c
index d82a3270..13f1126e 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c
@@ -121,7 +121,7 @@ int main (int argc, char **argv)
 {
 	char *base;
 
-	nmtst_init (&argc, &argv, TRUE);
+	nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT");
 
 	/* The tests */
 	test_get_ifcfg_name ("get-ifcfg-name-bad", "/foo/bar/adfasdfadf", FALSE, NULL);
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 4a6940d0..d2fb6867 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -194,8 +194,8 @@ test_read_basic (void)
 	guint64 expected_timestamp = 0;
 	gboolean success;
 
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-minimal",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-minimal",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	success = nm_connection_verify (connection, &error);
@@ -254,8 +254,8 @@ test_read_miscellaneous_variables (void)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*invalid MAC in HWADDR_BLACKLIST 'XX:aa:invalid'*");
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-misc-variables",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-misc-variables",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_test_assert_expected_messages ();
 	g_assert_no_error (error);
 	g_assert (connection);
@@ -304,8 +304,8 @@ test_read_variables_corner_cases (void)
 	guint64 expected_timestamp = 0;
 	gboolean success;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-variables-corner-cases-1",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-variables-corner-cases-1",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	success = nm_connection_verify (connection, &error);
@@ -350,10 +350,10 @@ test_read_unmanaged (void)
 	guint64 expected_timestamp = 0;
 	gboolean success;
 
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-nm-controlled",
-	                                   NULL, TYPE_ETHERNET,
-	                                   &unhandled_spec,
-	                                   NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-nm-controlled",
+	                                        NULL, TYPE_ETHERNET,
+	                                        &unhandled_spec,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	success = nm_connection_verify (connection, &error);
@@ -377,16 +377,16 @@ test_read_unmanaged_unrecognized (void)
 {
 	NMConnection *connection;
 	NMSettingConnection *s_con;
-	char *unhandled_spec = NULL;
+	gs_free char *unhandled_spec = NULL;
 	GError *error = NULL;
 	const char *expected_id = "PigeonNet";
 	guint64 expected_timestamp = 0;
 	gboolean success;
 
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-nm-controlled-unrecognized",
-	                                   NULL, NULL,
-	                                   &unhandled_spec,
-	                                   NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-nm-controlled-unrecognized",
+	                                        NULL, NULL,
+	                                        &unhandled_spec,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	success = nm_connection_verify (connection, &error);
@@ -408,16 +408,16 @@ test_read_unrecognized (void)
 {
 	NMConnection *connection;
 	NMSettingConnection *s_con;
-	char *unhandled_spec = NULL;
+	gs_free char *unhandled_spec = NULL;
 	GError *error = NULL;
 	const char *expected_id = "U Can't Touch This";
 	guint64 expected_timestamp = 0;
 	gboolean success;
 
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-unrecognized",
-	                                   NULL, NULL,
-	                                   &unhandled_spec,
-	                                   NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-unrecognized",
+	                                        NULL, NULL,
+	                                        &unhandled_spec,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	success = nm_connection_verify (connection, &error);
@@ -452,8 +452,8 @@ test_read_wired_static (const char *file,
 	NMIPAddress *ip6_addr;
 	gboolean success;
 
-	connection = connection_from_file (file, NULL, TYPE_ETHERNET,
-	                                   &unmanaged, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (file, NULL, TYPE_ETHERNET,
+	                                        &unmanaged, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	success = nm_connection_verify (connection, &error);
@@ -527,7 +527,6 @@ test_read_wired_static (const char *file,
 		g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE);
 	}
 
-	g_free (unmanaged);
 	g_object_unref (connection);
 }
 
@@ -547,8 +546,8 @@ test_read_wired_static_no_prefix (gconstpointer user_data)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*missing PREFIX, assuming*");
-	connection = connection_from_file (file, NULL, TYPE_ETHERNET, NULL,
-	                                   NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (file, NULL, TYPE_ETHERNET, NULL,
+	                                        &error);
 	g_test_assert_expected_messages ();
 	g_assert_no_error (error);
 	g_assert (connection);
@@ -584,10 +583,6 @@ test_read_wired_dhcp (void)
 	NMSettingWired *s_wired;
 	NMSettingIPConfig *s_ip4;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *mac;
 	char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0xee };
@@ -595,15 +590,11 @@ test_read_wired_dhcp (void)
 	const char *expected_id = "System test-wired-dhcp";
 	const char *expected_dhcp_hostname = "foobar";
 
-	connection = connection_from_file (TEST_IFCFG_WIRED_DHCP,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIRED_DHCP,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wired-dhcp-read", "failed to read %s: %s", TEST_IFCFG_WIRED_DHCP, error->message);
 
@@ -722,10 +713,6 @@ test_read_wired_dhcp (void)
 	        NM_SETTING_IP4_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_DNS);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -740,9 +727,9 @@ test_read_wired_dhcp_plus_ip (void)
 	NMIPAddress *ip6_addr;
 	gboolean success;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-plus-ip",
-	                                   NULL, TYPE_ETHERNET, NULL,
-	                                   NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-plus-ip",
+	                                        NULL, TYPE_ETHERNET, NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	success = nm_connection_verify (connection, &error);
@@ -807,6 +794,38 @@ test_read_wired_dhcp_plus_ip (void)
 }
 
 static void
+test_read_wired_shared_plus_ip (void)
+{
+	NMConnection *connection;
+	NMSettingIPConfig *s_ip4;
+	GError *error = NULL;
+	NMIPAddress *ip4_addr;
+
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-shared-plus-ip",
+	                                        NULL, TYPE_ETHERNET, NULL,
+	                                        &error);
+	nmtst_assert_connection_verifies_without_normalization (connection);
+
+	/* ===== 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_SHARED);
+	g_assert (nm_setting_ip_config_get_may_fail (s_ip4));
+
+	/* IP addresses */
+	g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 1);
+	ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0);
+	g_assert (ip4_addr);
+	g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 24);
+	g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "10.20.30.5");
+
+	/* Gateway */
+	g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "1.1.1.1");
+
+	g_object_unref (connection);
+}
+
+static void
 test_read_wired_global_gateway (void)
 {
 	NMConnection *connection;
@@ -817,9 +836,9 @@ test_read_wired_global_gateway (void)
 	NMIPAddress *ip4_addr;
 	char *unmanaged = NULL;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-global-gateway",
-	                                   TEST_IFCFG_DIR"/network-scripts/network-test-wired-global-gateway",
-	                                   TYPE_ETHERNET, &unmanaged, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-global-gateway",
+	                                        TEST_IFCFG_DIR"/network-scripts/network-test-wired-global-gateway",
+	                                        TYPE_ETHERNET, &unmanaged, &error);
 	nmtst_assert_connection_verifies_without_normalization (connection);
 	g_assert (unmanaged == NULL);
 
@@ -850,6 +869,37 @@ test_read_wired_global_gateway (void)
 }
 
 static void
+test_read_wired_obsolete_gateway_n (void)
+{
+	NMConnection *connection;
+	NMSettingIPConfig *s_ip4;
+	GError *error = NULL;
+	NMIPAddress *ip4_addr;
+
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-obsolete-gateway-n",
+	                                        NULL, TYPE_ETHERNET, NULL,
+	                                        &error);
+	nmtst_assert_connection_verifies_without_normalization (connection);
+
+	/* ===== 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_MANUAL);
+
+	/* IP addresses */
+	g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 1);
+	ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0);
+	g_assert (ip4_addr);
+	g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 24);
+	g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "1.2.3.4");
+
+	/* Gateway */
+	g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "1.1.1.1");
+
+	g_object_unref (connection);
+}
+
+static void
 test_read_wired_never_default (void)
 {
 	NMConnection *connection;
@@ -857,9 +907,9 @@ test_read_wired_never_default (void)
 	NMSettingIPConfig *s_ip6;
 	GError *error = NULL;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-never-default",
-	                                   TEST_IFCFG_DIR"/network-scripts/network-test-wired-never-default",
-	                                   TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-never-default",
+	                                        TEST_IFCFG_DIR"/network-scripts/network-test-wired-never-default",
+	                                        TYPE_ETHERNET, NULL, &error);
 	nmtst_assert_connection_verifies_without_normalization (connection);
 
 	/* ===== WIRED SETTING ===== */
@@ -892,23 +942,15 @@ test_read_wired_defroute_no (void)
 	NMSettingIPConfig *s_ip4;
 	NMSettingIPConfig *s_ip6;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System test-wired-defroute-no";
 
-	connection = connection_from_file (TEST_IFCFG_WIRED_DEFROUTE_NO,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIRED_DEFROUTE_NO,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wired-defroute-no-read", "failed to read %s: %s", TEST_IFCFG_WIRED_DEFROUTE_NO, error->message);
 
@@ -991,10 +1033,6 @@ test_read_wired_defroute_no (void)
 	        NM_SETTING_IP6_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_NEVER_DEFAULT);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -1010,23 +1048,15 @@ test_read_wired_defroute_no_gatewaydev_yes (void)
 	NMSettingIPConfig *s_ip4;
 	NMSettingIPConfig *s_ip6;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System test-wired-defroute-no-gatewaydev-yes";
 
-	connection = connection_from_file (TEST_IFCFG_WIRED_DEFROUTE_NO_GATEWAYDEV_YES,
-	                                   TEST_NETWORK_WIRED_DEFROUTE_NO_GATEWAYDEV_YES,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIRED_DEFROUTE_NO_GATEWAYDEV_YES,
+	                                        TEST_NETWORK_WIRED_DEFROUTE_NO_GATEWAYDEV_YES,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wired-defroute-no-gatewaydev-yes-read",
 	        "failed to read %s: %s",
@@ -1117,10 +1147,6 @@ test_read_wired_defroute_no_gatewaydev_yes (void)
 	        NM_SETTING_IP6_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_NEVER_DEFAULT);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -1134,8 +1160,8 @@ test_read_wired_static_routes (void)
 	GError *error = NULL;
 	NMIPRoute *ip4_route;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-static-routes",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-static-routes",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	nmtst_assert_connection_verifies_without_normalization (connection);
 
 	/* ===== CONNECTION SETTING ===== */
@@ -1182,24 +1208,16 @@ test_read_wired_static_routes_legacy (void)
 	NMSettingWired *s_wired;
 	NMSettingIPConfig *s_ip4;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	NMIPRoute *ip4_route;
 	const char *expected_id = "System test-wired-static-routes-legacy";
 
-	connection = connection_from_file (TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 
 	ASSERT (connection != NULL,
 	        "wired-static-routes-legacy-read",
@@ -1291,10 +1309,6 @@ test_read_wired_static_routes_legacy (void)
 	g_assert_cmpstr (nm_ip_route_get_next_hop (ip4_route), ==, "7.7.7.7");
 	g_assert_cmpint (nm_ip_route_get_metric (ip4_route), ==, 3);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -1306,23 +1320,15 @@ test_read_wired_ipv4_manual (const char *file, const char *expected_id)
 	NMSettingWired *s_wired;
 	NMSettingIPConfig *s_ip4;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	NMIPAddress *ip4_addr;
 
-	connection = connection_from_file (file,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (file,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wired-ipv4-manual-read", "failed to read %s: %s", file, error->message);
 
@@ -1402,10 +1408,6 @@ test_read_wired_ipv4_manual (const char *file, const char *expected_id)
 	g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "3.3.3.3");
 	g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 8);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -1420,10 +1422,6 @@ test_read_wired_ipv6_manual (void)
 	NMSettingIPConfig *s_ip4;
 	NMSettingIPConfig *s_ip6;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System test-wired-ipv6-manual";
@@ -1432,15 +1430,11 @@ test_read_wired_ipv6_manual (void)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*ignoring manual default route*");
-	connection = connection_from_file (TEST_IFCFG_WIRED_IPV6_MANUAL,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIRED_IPV6_MANUAL,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	g_test_assert_expected_messages ();
 
 	ASSERT (connection != NULL,
@@ -1635,10 +1629,6 @@ test_read_wired_ipv6_manual (void)
 	        NM_SETTING_IP6_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_DNS_SEARCH);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -1653,25 +1643,17 @@ test_read_wired_ipv6_only (void)
 	NMSettingIPConfig *s_ip4;
 	NMSettingIPConfig *s_ip6;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	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_IFCFG_WIRED_IPV6_ONLY,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIRED_IPV6_ONLY,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wired-ipv6-only-read", "failed to read %s: %s", TEST_IFCFG_WIRED_IPV6_ONLY, error->message);
 
@@ -1773,10 +1755,6 @@ test_read_wired_ipv6_only (void)
 	g_assert_cmpstr (nm_setting_ip_config_get_dns_search (s_ip6, 1), ==, "ipsum.org");
 	g_assert_cmpstr (nm_setting_ip_config_get_dns_search (s_ip6, 2), ==, "dolor.edu");
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -1791,24 +1769,16 @@ test_read_wired_dhcp6_only (void)
 	NMSettingIPConfig *s_ip4;
 	NMSettingIPConfig *s_ip6;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System test-wired-dhcp6-only";
 	const char *method;
 
-	connection = connection_from_file (TEST_IFCFG_WIRED_DHCP6_ONLY,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIRED_DHCP6_ONLY,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wired-dhcp6-only-read", "failed to read %s: %s", TEST_IFCFG_WIRED_DHCP6_ONLY, error->message);
 
@@ -1878,10 +1848,6 @@ test_read_wired_dhcp6_only (void)
 	        NM_SETTING_IP6_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_METHOD);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -1893,21 +1859,13 @@ test_read_onboot_no (void)
 	NMConnection *connection;
 	NMSettingConnection *s_con;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
-	GError *error = NULL;
-
-	connection = connection_from_file (TEST_IFCFG_ONBOOT_NO,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	GError *error = NULL;
+
+	connection = connection_from_file_test (TEST_IFCFG_ONBOOT_NO,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "onboot-no-read", "failed to read %s: %s", TEST_IFCFG_ONBOOT_NO, error->message);
 
@@ -1932,10 +1890,6 @@ test_read_onboot_no (void)
 	        NM_SETTING_CONNECTION_SETTING_NAME,
 	        NM_SETTING_CONNECTION_AUTOCONNECT);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -1947,22 +1901,13 @@ test_read_noip (void)
 	NMConnection *connection;
 	NMSettingIPConfig *s_ip4;
 	NMSettingIPConfig *s_ip6;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
-	GError *error = NULL;
-
-	connection = connection_from_file (TEST_IFCFG_NOIP,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	GError *error = NULL;
+
+	connection = connection_from_file_test (TEST_IFCFG_NOIP,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	g_assert (connection);
 	g_assert (nm_connection_verify (connection, &error));
 	g_assert_no_error (error);
@@ -1977,10 +1922,6 @@ test_read_noip (void)
 	g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE);
 	g_assert (nm_setting_ip_config_get_never_default (s_ip6) == FALSE);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -1996,10 +1937,6 @@ test_read_wired_8021x_peap_mschapv2 (void)
 	NMSetting8021x *s_8021x;
 	NMSetting8021x *tmp_8021x;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_identity = "David Smith";
@@ -2009,15 +1946,11 @@ test_read_wired_8021x_peap_mschapv2 (void)
 	const char *expected_ca_cert_path;
 	const char *read_ca_cert_path;
 
-	connection = connection_from_file (TEST_IFCFG_WIRED_8021x_PEAP_MSCHAPV2,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIRED_8021x_PEAP_MSCHAPV2,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wired-8021x-peap-mschapv2-read", "failed to read %s: %s", TEST_IFCFG_WIRED_8021x_PEAP_MSCHAPV2, error->message);
 
@@ -2176,10 +2109,6 @@ test_read_wired_8021x_peap_mschapv2 (void)
 
 	g_object_unref (tmp_8021x);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -2192,25 +2121,16 @@ test_read_wired_8021x_tls_secret_flags (const char *ifcfg, NMSettingSecretFlags
 	NMConnection *connection;
 	NMSettingWired *s_wired;
 	NMSetting8021x *s_8021x;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *expected_identity = "David Smith";
 	gboolean success = FALSE;
 	char *dirname, *tmp;
 
-	connection = connection_from_file (ifcfg,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (ifcfg,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 
@@ -2242,10 +2162,6 @@ test_read_wired_8021x_tls_secret_flags (const char *ifcfg, NMSettingSecretFlags
 
 	g_free (dirname);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -2260,9 +2176,9 @@ test_read_write_802_1X_subj_matches (void)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*missing IEEE_8021X_CA_CERT*peap*");
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-802-1X-subj-matches",
-	                                   NULL, TYPE_ETHERNET, NULL,
-	                                   NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-802-1X-subj-matches",
+	                                        NULL, TYPE_ETHERNET, NULL,
+	                                        &error);
 	g_test_assert_expected_messages ();
 	g_assert_no_error (error);
 	g_assert (connection != NULL);
@@ -2295,8 +2211,8 @@ test_read_write_802_1X_subj_matches (void)
 	/* re-read the connection for comparison */
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*missing IEEE_8021X_CA_CERT*peap*");
-	reread = connection_from_file (written, NULL, TYPE_ETHERNET, NULL,
-	                               NULL, NULL, NULL, &error, NULL);
+	reread = connection_from_file_test (written, NULL, TYPE_ETHERNET, NULL,
+	                                    &error);
 	g_test_assert_expected_messages ();
 	unlink (written);
 	g_free (written);
@@ -2343,8 +2259,8 @@ test_read_802_1x_ttls_eapgtc (void)
 	 * NMSetting8021x::autheap property.
 	 */
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-802-1x-ttls-eapgtc",
-	                                   NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-802-1x-ttls-eapgtc",
+	                                        NULL, TYPE_WIRELESS, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	success = nm_connection_verify (connection, &error);
@@ -2374,11 +2290,6 @@ test_read_wired_aliases_good (void)
 	NMConnection *connection;
 	NMSettingConnection *s_con;
 	NMSettingIPConfig *s_ip4;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System aliasem0";
@@ -2388,15 +2299,11 @@ test_read_wired_aliases_good (void)
 	const char *expected_gateway = "192.168.1.1";
 	int i, j;
 
-	connection = connection_from_file (TEST_IFCFG_ALIASES_GOOD,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_ALIASES_GOOD,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "aliases-good-read", "failed to read %s: %s", TEST_IFCFG_ALIASES_GOOD, error->message);
 
@@ -2485,9 +2392,6 @@ test_read_wired_aliases_good (void)
 		        expected_address[i]);
 	}
 
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -2497,24 +2401,15 @@ test_read_wired_aliases_bad (const char *base, const char *expected_id)
 	NMConnection *connection;
 	NMSettingConnection *s_con;
 	NMSettingIPConfig *s_ip4;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	NMIPAddress *ip4_addr;
 
-	connection = connection_from_file (base,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (base,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	g_test_assert_expected_messages ();
 	ASSERT (connection != NULL,
 	        "aliases-bad-read", "failed to read %s: %s", base, error->message);
@@ -2575,9 +2470,6 @@ test_read_wired_aliases_bad (const char *base, const char *expected_id)
 	/* Gateway */
 	g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "192.168.1.1");
 
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -2610,12 +2502,7 @@ test_read_wifi_open (void)
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
-	NMSettingIPConfig *s_ip4;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
+	NMSettingIPConfig *s_ip4, *s_ip6;
 	GError *error = NULL;
 	const char *tmp;
 	GBytes *ssid;
@@ -2627,15 +2514,11 @@ test_read_wifi_open (void)
 	const char *expected_mode = "infrastructure";
 	const guint32 expected_channel = 1;
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_OPEN,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_OPEN,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-open-read", "failed to read %s: %s", TEST_IFCFG_WIFI_OPEN, error->message);
 
@@ -2764,6 +2647,8 @@ test_read_wifi_open (void)
 	        TEST_IFCFG_WIFI_OPEN,
 	        NM_SETTING_IP4_CONFIG_SETTING_NAME);
 
+	g_assert_cmpint (nm_setting_ip_config_get_route_metric (s_ip4), ==, 104);
+
 	/* Method */
 	tmp = nm_setting_ip_config_get_method (s_ip4);
 	ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0,
@@ -2772,10 +2657,10 @@ test_read_wifi_open (void)
 	        NM_SETTING_IP4_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_METHOD);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
+	s_ip6 = nm_connection_get_setting_ip6_config (connection);
+	g_assert( s_ip6);
+	g_assert_cmpint (nm_setting_ip_config_get_route_metric (s_ip6), ==, 106);
+
 	g_object_unref (connection);
 }
 
@@ -2787,25 +2672,16 @@ test_read_wifi_open_auto (void)
 	NMConnection *connection;
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System blahblah (test-wifi-open-auto)";
 	const char *expected_mode = "infrastructure";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_OPEN_AUTO,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_OPEN_AUTO,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-open-auto-read", "failed to read %s: %s", TEST_IFCFG_WIFI_OPEN_AUTO, error->message);
 
@@ -2853,10 +2729,6 @@ test_read_wifi_open_auto (void)
 	        NM_SETTING_WIRELESS_SETTING_NAME,
 	        NM_SETTING_WIRELESS_MODE);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -2868,26 +2740,17 @@ test_read_wifi_open_ssid_hex (void)
 	NMConnection *connection;
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	GBytes *ssid;
 	const char *expected_id = "System blahblah (test-wifi-open-ssid-hex)";
 	const char *expected_ssid = "blahblah";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_OPEN_SSID_HEX,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_OPEN_SSID_HEX,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-open-ssid-hex-read", "failed to read %s: %s", TEST_IFCFG_WIFI_OPEN_SSID_HEX, error->message);
 
@@ -2941,10 +2804,6 @@ test_read_wifi_open_ssid_hex (void)
 	        NM_SETTING_WIRELESS_SETTING_NAME,
 	        NM_SETTING_WIRELESS_SSID);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -2952,29 +2811,16 @@ static void
 test_read_wifi_open_ssid_bad (const char *file, const char *test)
 {
 	NMConnection *connection;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
-	GError *error = NULL;
-
-	connection = connection_from_file (file,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	GError *error = NULL;
+
+	connection = connection_from_file_test (file,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection == NULL, test, "unexpected success reading %s", file);
 	g_clear_error (&error);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 }
 
 #define TEST_IFCFG_WIFI_OPEN_SSID_QUOTED TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-quoted"
@@ -2985,26 +2831,17 @@ test_read_wifi_open_ssid_quoted (void)
 	NMConnection *connection;
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	GBytes *ssid;
 	const char *expected_id = "System foo\"bar\\ (test-wifi-open-ssid-quoted)";
 	const char *expected_ssid = "foo\"bar\\";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_OPEN_SSID_QUOTED,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_OPEN_SSID_QUOTED,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-open-ssid-quoted-read", "failed to read %s: %s", TEST_IFCFG_WIFI_OPEN_SSID_QUOTED, error->message);
 
@@ -3058,10 +2895,6 @@ test_read_wifi_open_ssid_quoted (void)
 	        NM_SETTING_WIRELESS_SETTING_NAME,
 	        NM_SETTING_WIRELESS_SSID);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -3075,11 +2908,6 @@ test_read_wifi_wep (void)
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
 	NMSettingIPConfig *s_ip4;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	GBytes *ssid;
@@ -3093,15 +2921,11 @@ test_read_wifi_wep (void)
 	const char *expected_wep_key0 = "0123456789abcdef0123456789";
 	NMWepKeyType key_type;
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WEP,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WEP,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wep-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WEP, error->message);
 
@@ -3316,10 +3140,6 @@ test_read_wifi_wep (void)
 	        NM_SETTING_IP4_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_METHOD);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -3333,11 +3153,6 @@ test_read_wifi_wep_adhoc (void)
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
 	NMSettingIPConfig *s_ip4;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	GBytes *ssid;
@@ -3346,15 +3161,11 @@ test_read_wifi_wep_adhoc (void)
 	const char *expected_mode = "adhoc";
 	const char *expected_wep_key0 = "0123456789abcdef0123456789";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WEP_ADHOC,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WEP_ADHOC,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wep-adhoc-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WEP_ADHOC, error->message);
 
@@ -3556,10 +3367,6 @@ test_read_wifi_wep_adhoc (void)
 	        NM_SETTING_IP4_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_DNS);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -3572,25 +3379,16 @@ test_read_wifi_wep_passphrase (void)
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_wep_key0 = "foobar222blahblah";
 	NMWepKeyType key_type;
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WEP_PASSPHRASE,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WEP_PASSPHRASE,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wep-passphrase-read", "failed to read %s: %s",
 	        TEST_IFCFG_WIFI_WEP_PASSPHRASE, error->message);
@@ -3681,10 +3479,6 @@ test_read_wifi_wep_passphrase (void)
 	        NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
 	        NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -3697,25 +3491,16 @@ test_read_wifi_wep_40_ascii (void)
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_wep_key0 = "Lorem";
 	NMWepKeyType key_type;
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WEP_40_ASCII,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WEP_40_ASCII,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wep-40-ascii-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WEP_40_ASCII, error->message);
 
@@ -3804,10 +3589,6 @@ test_read_wifi_wep_40_ascii (void)
 	        NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
 	        NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -3820,25 +3601,16 @@ test_read_wifi_wep_104_ascii (void)
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_wep_key0 = "LoremIpsumSit";
 	NMWepKeyType key_type;
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WEP_104_ASCII,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WEP_104_ASCII,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wep-104-ascii-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WEP_104_ASCII, error->message);
 
@@ -3927,10 +3699,6 @@ test_read_wifi_wep_104_ascii (void)
 	        NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
 	        NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -3943,26 +3711,17 @@ test_read_wifi_leap (void)
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System blahblah (test-wifi-leap)";
 	const char *expected_identity = "Bill Smith";
 	const char *expected_password = "foobarblah";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_LEAP,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_LEAP,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-leap-read", "failed to read %s: %s", TEST_IFCFG_WIFI_LEAP, error->message);
 
@@ -4052,10 +3811,6 @@ test_read_wifi_leap (void)
 	        NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
 	        NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -4068,24 +3823,15 @@ test_read_wifi_leap_secret_flags (const char *file, NMSettingSecretFlags expecte
 	NMConnection *connection;
 	NMSettingWireless *s_wifi;
 	NMSettingWirelessSecurity *s_wsec;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *expected_identity = "Bill Smith";
 	gboolean success;
 
-	connection = connection_from_file (file,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (file,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 
@@ -4108,10 +3854,6 @@ test_read_wifi_leap_secret_flags (const char *file, NMSettingSecretFlags expecte
 	g_assert (nm_setting_wireless_security_get_leap_password_flags (s_wsec) == expected_flags);
 	g_assert (nm_setting_wireless_security_get_leap_password (s_wsec) == NULL);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -4125,11 +3867,6 @@ test_read_wifi_wpa_psk (void)
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
 	NMSettingIPConfig *s_ip4;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	GBytes *ssid;
@@ -4152,15 +3889,11 @@ test_read_wifi_wpa_psk (void)
 	gboolean found_proto_wpa = FALSE;
 	gboolean found_proto_rsn = FALSE;
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WPA_PSK,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wpa-psk-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WPA_PSK, error->message);
 
@@ -4409,10 +4142,6 @@ test_read_wifi_wpa_psk (void)
 	        NM_SETTING_IP4_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_METHOD);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -4425,25 +4154,16 @@ test_read_wifi_wpa_psk_2 (void)
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System ipsum (test-wifi-wpa-psk-2)";
 	const char *expected_psk = "They're really saying I love you. >>`<< \\";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_2,
-                                     NULL,
-                                     TYPE_WIRELESS,
-                                     &unmanaged,
-                                     &keyfile,
-                                     &routefile,
-                                     &route6file,
-                                     &error,
-                                     &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WPA_PSK_2,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wpa-psk-2-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WPA_PSK_2, error->message);
 
@@ -4500,10 +4220,6 @@ test_read_wifi_wpa_psk_2 (void)
 	        NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
 	        NM_SETTING_WIRELESS_SECURITY_PSK);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -4516,25 +4232,16 @@ test_read_wifi_wpa_psk_unquoted (void)
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System blahblah (test-wifi-wpa-psk-unquoted)";
 	const char *expected_psk = "54336845e2f3f321c4c7";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_UNQUOTED,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WPA_PSK_UNQUOTED,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wpa-psk-unquoted-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WPA_PSK_UNQUOTED, error->message);
 
@@ -4591,10 +4298,6 @@ test_read_wifi_wpa_psk_unquoted (void)
 	        NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
 	        NM_SETTING_WIRELESS_SECURITY_PSK);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -4604,34 +4307,21 @@ static void
 test_read_wifi_wpa_psk_unquoted2 (void)
 {
 	NMConnection *connection;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 
 	/* Ensure a quoted 64-character WPA passphrase will fail since passphrases
 	 * must be between 8 and 63 ASCII characters inclusive per the WPA spec.
 	 */
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_UNQUOTED2,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WPA_PSK_UNQUOTED2,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection == NULL,
 	        "wifi-wpa-psk-unquoted-read", "unexpected success reading %s", TEST_IFCFG_WIFI_WPA_PSK_UNQUOTED2);
 	g_clear_error (&error);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 }
 
 #define TEST_IFCFG_WIFI_WPA_PSK_ADHOC TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-wpa-psk-adhoc"
@@ -4644,11 +4334,6 @@ test_read_wifi_wpa_psk_adhoc (void)
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
 	NMSettingIPConfig *s_ip4;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System blahblah (test-wifi-wpa-psk-adhoc)";
@@ -4658,15 +4343,11 @@ test_read_wifi_wpa_psk_adhoc (void)
 	const char *expected_group = "ccmp";
 	const char *expected_proto = "wpa";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_ADHOC,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WPA_PSK_ADHOC,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wpa-psk-adhoc-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WPA_PSK_ADHOC, error->message);
 
@@ -4805,10 +4486,6 @@ test_read_wifi_wpa_psk_adhoc (void)
 	        NM_SETTING_IP4_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_METHOD);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -4822,11 +4499,6 @@ test_read_wifi_wpa_psk_hex (void)
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
 	NMSettingIPConfig *s_ip4;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	GBytes *ssid;
@@ -4835,15 +4507,11 @@ test_read_wifi_wpa_psk_hex (void)
 	const char *expected_key_mgmt = "wpa-psk";
 	const char *expected_psk = "1da190379817bc360dda52e85c388c439a21ea5c7bf819c64e9da051807deae6";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_HEX,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WPA_PSK_HEX,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wpa-psk-hex-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WPA_PSK_HEX, error->message);
 
@@ -4947,10 +4615,6 @@ test_read_wifi_wpa_psk_hex (void)
 	        NM_SETTING_IP4_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_METHOD);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -4967,24 +4631,16 @@ test_read_wifi_wpa_eap_tls (void)
 	NMSettingIPConfig *s_ip4;
 	NMSetting8021x *s_8021x;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp, *password;
 	const char *expected_identity = "Bill Smith";
 	const char *expected_privkey_password = "test1";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WPA_EAP_TLS,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WPA_EAP_TLS,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wpa-eap-tls-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WPA_EAP_TLS, error->message);
 
@@ -5088,10 +4744,6 @@ test_read_wifi_wpa_eap_tls (void)
 	                    expected_privkey_password,
 	                    NM_SETTING_802_1X_PRIVATE_KEY);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -5107,24 +4759,16 @@ test_read_wifi_wpa_eap_ttls_tls (void)
 	NMSettingIPConfig *s_ip4;
 	NMSetting8021x *s_8021x;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp, *password;
 	const char *expected_identity = "Chuck Shumer";
 	const char *expected_privkey_password = "test1";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WPA_EAP_TTLS_TLS,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WPA_EAP_TTLS_TLS,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wpa-eap-ttls-tls-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WPA_EAP_TTLS_TLS, error->message);
 
@@ -5247,10 +4891,6 @@ test_read_wifi_wpa_eap_ttls_tls (void)
 	        NM_SETTING_802_1X_SETTING_NAME,
 	        NM_SETTING_802_1X_IDENTITY);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -5263,22 +4903,14 @@ test_read_wifi_dynamic_wep_leap (void)
 	NMSettingWireless *s_wifi;
 	NMSettingWirelessSecurity *s_wsec;
 	NMSetting8021x *s_8021x;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE, success;
+	gboolean success;
 	GError *error = NULL;
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_DYNAMIC_WEP_LEAP,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_DYNAMIC_WEP_LEAP,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 
@@ -5319,10 +4951,6 @@ test_read_wifi_dynamic_wep_leap (void)
 	g_assert_cmpstr (nm_setting_802_1x_get_identity (s_8021x), ==, "bill smith");
 	g_assert_cmpstr (nm_setting_802_1x_get_password (s_8021x), ==, "foobar baz");
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -5338,25 +4966,17 @@ test_read_wifi_wep_eap_ttls_chap (void)
 	NMSettingIPConfig *s_ip4;
 	NMSetting8021x *s_8021x;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_password = "foobar baz";
 	const char *expected_identity = "David Smith";
 	const char *expected_key_mgmt = "ieee8021x";
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WEP_EAP_TTLS_CHAP,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WEP_EAP_TTLS_CHAP,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wep-eap-ttls-chap-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WEP_EAP_TTLS_CHAP, error->message);
 
@@ -5480,10 +5100,6 @@ test_read_wifi_wep_eap_ttls_chap (void)
 	        NM_SETTING_802_1X_SETTING_NAME,
 	        NM_SETTING_802_1X_PASSWORD);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -5496,8 +5112,8 @@ test_read_wifi_hidden (void)
 	gboolean success;
 	GError *error = NULL;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-hidden",
-	                                   NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-hidden",
+	                                        NULL, TYPE_WIRELESS, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 
@@ -5584,8 +5200,8 @@ test_write_wifi_hidden (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile, NULL, TYPE_WIRELESS,
-	                               NULL, NULL, NULL, NULL, &error, NULL);
+	reread = connection_from_file_test (testfile, NULL, TYPE_WIRELESS,
+	                                    NULL, &error);
 	unlink (testfile);
 	g_assert_no_error (error);
 	g_assert (reread);
@@ -5610,8 +5226,8 @@ test_read_wifi_band_a (void)
 	gboolean success;
 	GError *error = NULL;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-a",
-	                                   NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-a",
+	                                        NULL, TYPE_WIRELESS, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 
@@ -5698,8 +5314,8 @@ test_write_wifi_band_a (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile, NULL, TYPE_WIRELESS,
-	                               NULL, NULL, NULL, NULL, &error, NULL);
+	reread = connection_from_file_test (testfile, NULL, TYPE_WIRELESS,
+	                                    NULL, &error);
 	unlink (testfile);
 	g_assert_no_error (error);
 	g_assert (reread);
@@ -5721,10 +5337,11 @@ test_read_wifi_band_a_channel_mismatch (void)
 	NMConnection *connection;
 	GError *error = NULL;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-a-channel-mismatch",
-	                                   NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-a-channel-mismatch",
+	                                        NULL, TYPE_WIRELESS, NULL, &error);
 	g_assert (connection == NULL);
 	g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
+	g_clear_error (&error);
 }
 
 static void
@@ -5733,10 +5350,11 @@ test_read_wifi_band_bg_channel_mismatch (void)
 	NMConnection *connection;
 	GError *error = NULL;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-bg-channel-mismatch",
-	                                   NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-bg-channel-mismatch",
+	                                        NULL, TYPE_WIRELESS, NULL, &error);
 	g_assert (connection == NULL);
 	g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
+	g_clear_error (&error);
 }
 
 #define TEST_IFCFG_WIRED_QETH_STATIC TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-qeth-static"
@@ -5749,10 +5367,6 @@ test_read_wired_qeth_static (void)
 	NMSettingWired *s_wired;
 	NMSettingIPConfig *s_ip4;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System test-wired-qeth-static";
@@ -5762,15 +5376,11 @@ test_read_wired_qeth_static (void)
 	const char *expected_channel2 = "0.0.0602";
 	const char * const *subchannels;
 
-	connection = connection_from_file (TEST_IFCFG_WIRED_QETH_STATIC,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIRED_QETH_STATIC,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wired-qeth-static-read", "failed to read %s: %s", TEST_IFCFG_WIRED_QETH_STATIC, error->message);
 
@@ -5902,10 +5512,6 @@ test_read_wired_qeth_static (void)
 	        NM_SETTING_IP4_CONFIG_SETTING_NAME,
 	        NM_SETTING_IP_CONFIG_METHOD);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -5918,10 +5524,6 @@ test_read_wired_ctc_static (void)
 	NMSettingConnection *s_con;
 	NMSettingWired *s_wired;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System test-wired-ctc-static";
@@ -5930,15 +5532,11 @@ test_read_wired_ctc_static (void)
 	const char * const *subchannels;
 	gboolean success;
 
-	connection = connection_from_file (TEST_IFCFG_WIRED_CTC_STATIC,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIRED_CTC_STATIC,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        &unmanaged,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	
@@ -5974,10 +5572,6 @@ test_read_wired_ctc_static (void)
 	g_assert (tmp != NULL);
 	g_assert_cmpstr (tmp, ==, "0");
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -5990,25 +5584,16 @@ test_read_wifi_wep_no_keys (void)
 	NMSettingConnection *s_con;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *tmp;
 	const char *expected_id = "System foobar (test-wifi-wep-no-keys)";
 	NMWepKeyType key_type;
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WEP_NO_KEYS,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WEP_NO_KEYS,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "wifi-wep-no-keys-read", "failed to read %s: %s", TEST_IFCFG_WIFI_WEP_NO_KEYS, error->message);
 
@@ -6086,10 +5671,6 @@ test_read_wifi_wep_no_keys (void)
 	        NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
 	        NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -6100,24 +5681,16 @@ test_read_permissions (void)
 {
 	NMConnection *connection;
 	NMSettingConnection *s_con;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE, success;
+	gboolean success;
 	GError *error = NULL;
 	guint32 num;
 	const char *tmp;
 
-	connection = connection_from_file (TEST_IFCFG_PERMISSIONS,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_PERMISSIONS,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "permissions-read", "failed to read %s: %s", TEST_IFCFG_PERMISSIONS, error->message);
 
@@ -6159,10 +5732,6 @@ test_read_permissions (void)
 	ASSERT (strcmp (tmp, "johnny5") == 0,
 	        "permissions-verify-permissions", "unexpected permission #3");
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -6174,25 +5743,16 @@ test_read_wifi_wep_agent_keys (void)
 	NMConnection *connection;
 	NMSettingWireless *s_wifi;
 	NMSettingWirelessSecurity *s_wsec;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	NMWepKeyType key_type;
 	gboolean success;
 	NMSettingSecretFlags flags;
 
-	connection = connection_from_file (TEST_IFCFG_WIFI_WEP_AGENT_KEYS,
-	                                   NULL,
-	                                   TYPE_WIRELESS,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_WIFI_WEP_AGENT_KEYS,
+	                                        NULL,
+	                                        TYPE_WIRELESS,
+	                                        NULL,
+	                                        &error);
 	g_assert (connection != NULL);
 
 	success = nm_connection_verify (connection, &error);
@@ -6223,10 +5783,6 @@ test_read_wifi_wep_agent_keys (void)
 	flags = nm_setting_wireless_security_get_wep_key_flags (s_wsec);
 	g_assert (flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -6256,11 +5812,7 @@ test_write_wired_static (void)
 	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_simple_connection_new ();
 
@@ -6294,6 +5846,7 @@ test_write_wired_static (void)
 	              NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL,
 	              NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
 	              NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1",
+	              NM_SETTING_IP_CONFIG_ROUTE_METRIC, (gint64) 204,
 	              NULL);
 
 	addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error);
@@ -6319,6 +5872,7 @@ test_write_wired_static (void)
 	g_object_set (s_ip6,
 	              NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL,
 	              NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
+	              NM_SETTING_IP_CONFIG_ROUTE_METRIC, (gint64) 206,
 	              NULL);
 
 	/* Add addresses */
@@ -6378,15 +5932,11 @@ test_write_wired_static (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -6406,16 +5956,16 @@ test_write_wired_static (void)
 	nm_setting_ip_config_remove_dns_search (reread_s_ip4, 3);
 	nm_setting_ip_config_remove_dns_search (reread_s_ip4, 2);
 
+	g_assert_cmpint (nm_setting_ip_config_get_route_metric (reread_s_ip4), ==, 204);
+	g_assert_cmpint (nm_setting_ip_config_get_route_metric (reread_s_ip6), ==, 206);
+
 	ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
 	        "wired-static-write", "written and re-read connection weren't the same.");
 
-	if (route6file)
-		unlink (route6file);
+	route6file = utils_get_route6_path (testfile);
+	unlink (route6file);
 
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
 	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
@@ -6434,11 +5984,6 @@ test_write_wired_dhcp (void)
 	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_simple_connection_new ();
 
@@ -6500,15 +6045,11 @@ test_write_wired_dhcp (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -6521,10 +6062,6 @@ test_write_wired_dhcp (void)
 	        "wired-dhcp-write", "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);
 }
@@ -6537,9 +6074,9 @@ test_write_wired_dhcp_plus_ip (void)
 	GError *error = NULL;
 	gboolean success = FALSE;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-plus-ip",
-	                                   NULL, TYPE_ETHERNET, NULL,
-	                                   NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-plus-ip",
+	                                        NULL, TYPE_ETHERNET, NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection != NULL);
 
@@ -6553,8 +6090,8 @@ test_write_wired_dhcp_plus_ip (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (written, NULL, TYPE_ETHERNET, NULL,
-	                               NULL, NULL, NULL, &error, NULL);
+	reread = connection_from_file_test (written, NULL, TYPE_ETHERNET, NULL,
+	                                    &error);
 	unlink (written);
 	g_free (written);
 
@@ -6583,9 +6120,9 @@ test_read_write_wired_dhcp_send_hostname (void)
 	GError *error = NULL;
 	gboolean success = FALSE;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-send-hostname",
-	                                   NULL, TYPE_ETHERNET, NULL,
-	                                   NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-dhcp-send-hostname",
+	                                        NULL, TYPE_ETHERNET, NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection != NULL);
 
@@ -6613,8 +6150,8 @@ test_read_write_wired_dhcp_send_hostname (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (written, NULL, TYPE_ETHERNET, NULL,
-	                               NULL, NULL, NULL, &error, NULL);
+	reread = connection_from_file_test (written, NULL, TYPE_ETHERNET, NULL,
+	                                    &error);
 	unlink (written);
 	g_free (written);
 
@@ -6657,11 +6194,7 @@ test_write_wired_static_ip6_only (void)
 	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_simple_connection_new ();
 
@@ -6729,15 +6262,11 @@ test_write_wired_static_ip6_only (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -6749,13 +6278,7 @@ test_write_wired_static_ip6_only (void)
 	ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
 	        "wired-static-ip6-only-write", "written and re-read connection weren't the same.");
 
-	if (route6file)
-		unlink (route6file);
-
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
 	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
@@ -6786,7 +6309,6 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data)
 	GError *error = NULL;
 	char *testfile = NULL;
 	char *id = NULL;
-	gboolean ignore_error = FALSE;
 	char *written_ifcfg_gateway;
 	const char *gateway6 = user_data;
 
@@ -6854,13 +6376,11 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               NULL, NULL,
-	                               NULL, NULL,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	g_assert_no_error (error);
 	g_assert (reread);
 	g_assert (nm_connection_verify (reread, &error));
@@ -6909,28 +6429,18 @@ test_read_write_static_routes_legacy (void)
 	NMSettingConnection *s_con;
 	NMSettingWired *s_wired;
 	NMSettingIPConfig *s_ip4;
-	char *unmanaged = NULL;
 	char *testfile = NULL;
-	char *keyfile = NULL;
-	char *keyfile2 = NULL;
-	char *routefile = NULL;
 	char *routefile2 = NULL;
-	char *route6file = NULL;
 	char *route6file2 = NULL;
-	gboolean ignore_error = FALSE;
 	gboolean success;
 	GError *error = NULL;
 	const char *tmp;
 
-	connection = connection_from_file (TEST_IFCFG_READ_WRITE_STATIC_ROUTES_LEGACY,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_READ_WRITE_STATIC_ROUTES_LEGACY,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "read-write-static-routes-legacy-read", "failed to read %s: %s",
 	        TEST_IFCFG_READ_WRITE_STATIC_ROUTES_LEGACY, error->message);
@@ -7011,17 +6521,15 @@ test_read_write_static_routes_legacy (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile2,
-	                               &routefile2,
-	                               &route6file2,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
+	routefile2 = utils_get_route_path (testfile);
 	unlink (routefile2);
+	route6file2 = utils_get_route6_path (testfile);
 	unlink (route6file2);
 
 	ASSERT (reread != NULL,
@@ -7037,12 +6545,7 @@ test_read_write_static_routes_legacy (void)
 	        "read-write-static-routes-legacy-write", "written and re-read connection weren't the same.");
 
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (keyfile2);
-	g_free (routefile);
 	g_free (routefile2);
-	g_free (route6file);
 	g_free (route6file2);
 	g_object_unref (connection);
 	g_object_unref (reread);
@@ -7069,11 +6572,7 @@ test_write_wired_static_routes (void)
 	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_simple_connection_new ();
 
@@ -7164,22 +6663,17 @@ test_write_wired_static_routes (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
 	        "wired-static-routes-write-reread", "failed to read %s: %s", testfile, error->message);
 
-	ASSERT (routefile != NULL,
-	        "wired-static-routes-write-reread", "expected routefile for '%s'", testfile);
+	routefile = utils_get_route_path (testfile);
 	unlink (routefile);
 
 	ASSERT (nm_connection_verify (reread, &error),
@@ -7189,10 +6683,7 @@ test_write_wired_static_routes (void)
 	        "wired-static-routes-write", "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);
 }
@@ -7211,11 +6702,7 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void)
 	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_simple_connection_new ();
 
@@ -7295,22 +6782,17 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
 	        "wired-dhcp-8021x-peap-mschapv2write-reread", "failed to read %s: %s", testfile, error->message);
 
-	ASSERT (keyfile != NULL,
-	        "wired-dhcp-8021x-peap-mschapv2write-reread", "expected keyfile for '%s'", testfile);
+	keyfile = utils_get_keys_path (testfile);
 	unlink (keyfile);
 
 	ASSERT (nm_connection_verify (reread, &error),
@@ -7320,10 +6802,7 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void)
 	        "wired-dhcp-8021x-peap-mschapv2write", "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);
 }
@@ -7365,11 +6844,7 @@ test_write_wired_8021x_tls (NMSetting8021xCKScheme scheme,
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
 	const char *pw;
 	char *tmp;
@@ -7479,17 +6954,13 @@ test_write_wired_8021x_tls (NMSetting8021xCKScheme scheme,
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
-	g_assert (keyfile != NULL);
+	keyfile = utils_get_keys_path (testfile);
 	unlink (keyfile);
 
 	g_assert (reread != NULL);
@@ -7555,10 +7026,7 @@ test_write_wired_8021x_tls (NMSetting8021xCKScheme scheme,
 	g_free (tmp);
 
 	g_free (testfile);
-	g_free (unmanaged);
 	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
 }
@@ -7581,11 +7049,6 @@ test_write_wired_aliases (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	shvarFile *ifcfg;
 	int i, j;
 
@@ -7679,15 +7142,11 @@ test_write_wired_aliases (void)
 	        "wired-aliases-write", "saving failed to delete unused ifcfg-alias0:5");
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 	unlink (TEST_SCRATCH_ALIAS_BASE ":2");
 	unlink (TEST_SCRATCH_ALIAS_BASE ":3");
@@ -7743,9 +7202,6 @@ test_write_wired_aliases (void)
 	g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "1.1.1.1");
 
 	g_free (testfile);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
 }
@@ -7861,8 +7317,8 @@ test_write_gateway (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile, NULL, TYPE_WIRELESS,
-	                               NULL, NULL, NULL, NULL, &error, NULL);
+	reread = connection_from_file_test (testfile, NULL, TYPE_WIRELESS,
+	                                    NULL, &error);
 	unlink (testfile);
 	g_assert_no_error (error);
 	g_assert (reread);
@@ -7892,11 +7348,6 @@ test_write_wifi_open (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 };
 	const char *bssid = "11:22:33:44:55:66";
@@ -7973,15 +7424,11 @@ test_write_wifi_open (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	g_assert_no_error (error);
 
 	/* Now make sure that the ESSID item isn't double-quoted (rh #606518) */
@@ -8011,10 +7458,6 @@ test_write_wifi_open (void)
 	        "wifi-open-write", "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);
 }
@@ -8032,11 +7475,6 @@ test_write_wifi_open_hex_ssid (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const unsigned char ssid_data[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd };
 
@@ -8103,15 +7541,11 @@ test_write_wifi_open_hex_ssid (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -8124,10 +7558,6 @@ test_write_wifi_open_hex_ssid (void)
 	        "wifi-open-hex-ssid-write", "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);
 }
@@ -8146,11 +7576,7 @@ test_write_wifi_wep (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 	struct stat statbuf;
@@ -8232,27 +7658,20 @@ test_write_wifi_wep (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
-	ASSERT (keyfile != NULL,
-	        "wifi-wep-write-reread", "expected keyfile for '%s'", testfile);
-
+	keyfile = utils_get_keys_path (testfile);
 	ASSERT (stat (keyfile, &statbuf) == 0,
 	        "wifi-wep-write-reread", "couldn't stat() '%s'", keyfile);
 	ASSERT (S_ISREG (statbuf.st_mode),
 	        "wifi-wep-write-reread", "keyfile '%s' wasn't a normal file", keyfile);
 	ASSERT ((statbuf.st_mode & 0077) == 0,
 	        "wifi-wep-write-reread", "keyfile '%s' wasn't readable only by its owner", keyfile);
-
 	unlink (keyfile);
 
 	ASSERT (reread != NULL,
@@ -8265,10 +7684,7 @@ test_write_wifi_wep (void)
 	        "wifi-wep-write", "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);
 }
@@ -8287,11 +7703,7 @@ test_write_wifi_wep_adhoc (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 	struct stat statbuf;
@@ -8379,27 +7791,20 @@ test_write_wifi_wep_adhoc (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
-	ASSERT (keyfile != NULL,
-	        "wifi-wep-adhoc-write-reread", "expected keyfile for '%s'", testfile);
-
+	keyfile = utils_get_keys_path (testfile);
 	ASSERT (stat (keyfile, &statbuf) == 0,
 	        "wifi-wep-adhoc-write-reread", "couldn't stat() '%s'", keyfile);
 	ASSERT (S_ISREG (statbuf.st_mode),
 	        "wifi-wep-adhoc-write-reread", "keyfile '%s' wasn't a normal file", keyfile);
 	ASSERT ((statbuf.st_mode & 0077) == 0,
 	        "wifi-wep-adhoc-write-reread", "keyfile '%s' wasn't readable only by its owner", keyfile);
-
 	unlink (keyfile);
 
 	ASSERT (reread != NULL,
@@ -8412,10 +7817,7 @@ test_write_wifi_wep_adhoc (void)
 	        "wifi-wep-adhoc-write", "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);
 }
@@ -8434,11 +7836,7 @@ test_write_wifi_wep_passphrase (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 	struct stat statbuf;
@@ -8518,27 +7916,20 @@ test_write_wifi_wep_passphrase (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
-	ASSERT (keyfile != NULL,
-	        "wifi-wep-passphrase-write-reread", "expected keyfile for '%s'", testfile);
-
+	keyfile = utils_get_keys_path (testfile);
 	ASSERT (stat (keyfile, &statbuf) == 0,
 	        "wifi-wep-passphrase-write-reread", "couldn't stat() '%s'", keyfile);
 	ASSERT (S_ISREG (statbuf.st_mode),
 	        "wifi-wep-passphrase-write-reread", "keyfile '%s' wasn't a normal file", keyfile);
 	ASSERT ((statbuf.st_mode & 0077) == 0,
 	        "wifi-wep-passphrase-write-reread", "keyfile '%s' wasn't readable only by its owner", keyfile);
-
 	unlink (keyfile);
 
 	ASSERT (reread != NULL,
@@ -8551,10 +7942,7 @@ test_write_wifi_wep_passphrase (void)
 	        "wifi-wep-passphrase-write", "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);
 }
@@ -8573,11 +7961,7 @@ test_write_wifi_wep_40_ascii (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah40";
 	struct stat statbuf;
@@ -8659,27 +8043,20 @@ test_write_wifi_wep_40_ascii (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
-	ASSERT (keyfile != NULL,
-	        "wifi-wep-40-ascii-write-reread", "expected keyfile for '%s'", testfile);
-
+	keyfile = utils_get_keys_path (testfile);
 	ASSERT (stat (keyfile, &statbuf) == 0,
 	        "wifi-wep-40-ascii-write-reread", "couldn't stat() '%s'", keyfile);
 	ASSERT (S_ISREG (statbuf.st_mode),
 	        "wifi-wep-40-ascii-write-reread", "keyfile '%s' wasn't a normal file", keyfile);
 	ASSERT ((statbuf.st_mode & 0077) == 0,
 	        "wifi-wep-40-ascii-write-reread", "keyfile '%s' wasn't readable only by its owner", keyfile);
-
 	unlink (keyfile);
 
 	ASSERT (reread != NULL,
@@ -8692,10 +8069,7 @@ test_write_wifi_wep_40_ascii (void)
 	        "wifi-wep-40-ascii-write", "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);
 }
@@ -8714,11 +8088,7 @@ test_write_wifi_wep_104_ascii (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah104";
 	struct stat statbuf;
@@ -8800,27 +8170,20 @@ test_write_wifi_wep_104_ascii (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
-	ASSERT (keyfile != NULL,
-	        "wifi-wep-104-ascii-write-reread", "expected keyfile for '%s'", testfile);
-
+	keyfile = utils_get_keys_path (testfile);
 	ASSERT (stat (keyfile, &statbuf) == 0,
 	        "wifi-wep-104-ascii-write-reread", "couldn't stat() '%s'", keyfile);
 	ASSERT (S_ISREG (statbuf.st_mode),
 	        "wifi-wep-104-ascii-write-reread", "keyfile '%s' wasn't a normal file", keyfile);
 	ASSERT ((statbuf.st_mode & 0077) == 0,
 	        "wifi-wep-104-ascii-write-reread", "keyfile '%s' wasn't readable only by its owner", keyfile);
-
 	unlink (keyfile);
 
 	ASSERT (reread != NULL,
@@ -8833,10 +8196,7 @@ test_write_wifi_wep_104_ascii (void)
 	        "wifi-wep-104-ascii-write", "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);
 }
@@ -8855,11 +8215,7 @@ test_write_wifi_leap (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 	struct stat statbuf;
@@ -8938,27 +8294,20 @@ test_write_wifi_leap (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
-	ASSERT (keyfile != NULL,
-	        "wifi-leap-write-reread", "expected keyfile for '%s'", testfile);
-
+	keyfile = utils_get_keys_path (testfile);
 	ASSERT (stat (keyfile, &statbuf) == 0,
 	        "wifi-leap-write-reread", "couldn't stat() '%s'", keyfile);
 	ASSERT (S_ISREG (statbuf.st_mode),
 	        "wifi-leap-write-reread", "keyfile '%s' wasn't a normal file", keyfile);
 	ASSERT ((statbuf.st_mode & 0077) == 0,
 	        "wifi-leap-write-reread", "keyfile '%s' wasn't readable only by its owner", keyfile);
-
 	unlink (keyfile);
 
 	ASSERT (reread != NULL,
@@ -8971,10 +8320,7 @@ test_write_wifi_leap (void)
 	        "wifi-leap-write", "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);
 }
@@ -8993,11 +8339,7 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 
@@ -9075,21 +8417,17 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	g_assert_no_error (error);
 
 	/* No key should be written out since the secret is not system owned */
-	g_assert (keyfile);
+	keyfile = utils_get_keys_path (testfile);
 	g_assert (g_file_test (keyfile, G_FILE_TEST_EXISTS) == FALSE);
 
 	g_assert (reread);
@@ -9105,10 +8443,7 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags)
 	g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT));
 
 	g_free (testfile);
-	g_free (unmanaged);
 	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
 }
@@ -9132,11 +8467,7 @@ test_write_wifi_wpa_psk (const char *name,
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 
@@ -9229,22 +8560,17 @@ test_write_wifi_wpa_psk (const char *name,
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
-	tmp = g_strdup_printf ("%s-reread", test_name);
-	ASSERT (keyfile != NULL,
-	        tmp, "expected keyfile for '%s'", testfile);
+	keyfile = utils_get_keys_path (testfile);
 	unlink (keyfile);
 
+	tmp = g_strdup_printf ("%s-reread", test_name);
 	ASSERT (reread != NULL,
 	        tmp, "failed to read %s: %s", testfile, error->message);
 
@@ -9256,10 +8582,7 @@ test_write_wifi_wpa_psk (const char *name,
 	        test_name, "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);
 }
@@ -9278,11 +8601,7 @@ test_write_wifi_wpa_psk_adhoc (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 	NMIPAddress *addr;
@@ -9376,19 +8695,14 @@ test_write_wifi_wpa_psk_adhoc (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
-	ASSERT (keyfile != NULL,
-	        "wifi-wpa-psk-adhoc-write-reread", "expected keyfile for '%s'", testfile);
+	keyfile = utils_get_keys_path (testfile);
 	unlink (keyfile);
 
 	ASSERT (reread != NULL,
@@ -9401,10 +8715,7 @@ test_write_wifi_wpa_psk_adhoc (void)
 	        "wifi-wpa-psk-adhoc-write", "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);
 }
@@ -9424,11 +8735,7 @@ test_write_wifi_wpa_eap_tls (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 
@@ -9540,19 +8847,14 @@ test_write_wifi_wpa_eap_tls (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
-	ASSERT (keyfile != NULL,
-	        "wifi-wpa-eap-tls-write-reread", "expected keyfile for '%s'", testfile);
+	keyfile = utils_get_keys_path (testfile);
 	unlink (keyfile);
 
 	ASSERT (reread != NULL,
@@ -9565,10 +8867,7 @@ test_write_wifi_wpa_eap_tls (void)
 	        "wifi-wpa-eap-tls-write", "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);
 }
@@ -9588,11 +8887,7 @@ test_write_wifi_wpa_eap_ttls_tls (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 
@@ -9722,22 +9017,17 @@ test_write_wifi_wpa_eap_ttls_tls (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
 	        "wifi-wpa-eap-ttls-tls-write-reread", "failed to read %s: %s", testfile, error->message);
 
-	ASSERT (keyfile != NULL,
-	        "wifi-wpa-eap-ttls-tls-write-reread", "expected keyfile for '%s'", testfile);
+	keyfile = utils_get_keys_path (testfile);
 	unlink (keyfile);
 
 	ASSERT (nm_connection_verify (reread, &error),
@@ -9747,10 +9037,7 @@ test_write_wifi_wpa_eap_ttls_tls (void)
 	        "wifi-wpa-eap-ttls-tls-write", "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);
 }
@@ -9770,11 +9057,7 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 
@@ -9876,22 +9159,17 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
 	        "wifi-wpa-eap-ttls-mschapv2-write-reread", "failed to read %s: %s", testfile, error->message);
 
-	ASSERT (keyfile != NULL,
-	        "wifi-wpa-eap-ttls-mschapv2-write-reread", "expected keyfile for '%s'", testfile);
+	keyfile = utils_get_keys_path (testfile);
 	unlink (keyfile);
 
 	ASSERT (nm_connection_verify (reread, &error),
@@ -9901,10 +9179,7 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void)
 	        "wifi-wpa-eap-ttls-mschapv2-write", "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);
 }
@@ -9923,11 +9198,7 @@ test_write_wifi_wpa_then_open (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 
@@ -10018,15 +9289,11 @@ test_write_wifi_wpa_then_open (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	g_assert_no_error (error);
 	g_assert (reread);
 
@@ -10036,18 +9303,13 @@ test_write_wifi_wpa_then_open (void)
 	success = nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT);
 	g_assert (success);
 
-	g_free (unmanaged);
-	unmanaged = NULL;
-	g_free (routefile);
-	routefile = NULL;
-	g_free (route6file);
-	route6file = NULL;
 	g_object_unref (reread);
 
 	/* Now change the connection to open and recheck */
 	nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
 
 	/* Write it back out */
+	keyfile = utils_get_keys_path (testfile);
 	success = writer_update_connection (connection,
 	                                    TEST_SCRATCH_DIR "/network-scripts/",
 	                                    testfile,
@@ -10064,22 +9326,18 @@ test_write_wifi_wpa_then_open (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read it for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 	g_assert_no_error (error);
 
 	g_assert (reread);
 
 	/* No keyfile since it's an open connection this time */
-	g_assert (keyfile);
+	keyfile = utils_get_keys_path (testfile);
 	g_assert (g_file_test (keyfile, G_FILE_TEST_EXISTS) == FALSE);
 
 	success = nm_connection_verify (reread, &error);
@@ -10090,10 +9348,7 @@ test_write_wifi_wpa_then_open (void)
 
 	unlink (testfile);
 	g_free (testfile);
-	g_free (unmanaged);
 	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (reread);
 
 	g_object_unref (connection);
@@ -10113,11 +9368,7 @@ test_write_wifi_wpa_then_wep_with_perms (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	char **perms;
 	const char *ssid_data = "SomeSSID";
@@ -10214,15 +9465,11 @@ test_write_wifi_wpa_then_wep_with_perms (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	g_assert_no_error (error);
 	g_assert (reread);
 
@@ -10232,12 +9479,6 @@ test_write_wifi_wpa_then_wep_with_perms (void)
 	success = nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT);
 	g_assert (success);
 
-	g_free (unmanaged);
-	unmanaged = NULL;
-	g_free (routefile);
-	routefile = NULL;
-	g_free (route6file);
-	route6file = NULL;
 	g_object_unref (reread);
 
 	/* Now change the connection to WEP and recheck */
@@ -10251,6 +9492,7 @@ test_write_wifi_wpa_then_wep_with_perms (void)
 	nm_setting_wireless_security_set_wep_key (s_wsec, 0, "abraka  dabra");
 
 	/* Write it back out */
+	keyfile = utils_get_keys_path (testfile);
 	success = writer_update_connection (connection,
 	                                    TEST_SCRATCH_DIR "/network-scripts/",
 	                                    testfile,
@@ -10266,15 +9508,11 @@ test_write_wifi_wpa_then_wep_with_perms (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read it for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	g_assert_no_error (error);
 
 	g_assert (reread);
@@ -10289,14 +9527,12 @@ test_write_wifi_wpa_then_wep_with_perms (void)
 	ASSERT (success,
 	        "test_write_wifi_wpa_then_wep_with_perms", "failed to compare connections");
 
+	keyfile = utils_get_keys_path (testfile);
 	unlink (keyfile);
 	unlink (testfile);
+	g_free (keyfile);
 
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (reread);
 
 	g_object_unref (connection);
@@ -10317,11 +9553,7 @@ test_write_wifi_dynamic_wep_leap (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
 	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GBytes *ssid;
 	const char *ssid_data = "blahblah";
 	shvarFile *ifcfg;
@@ -10409,18 +9641,15 @@ test_write_wifi_dynamic_wep_leap (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	g_assert_no_error (error);
 	g_assert (reread);
-	g_assert (keyfile);
+
+	keyfile = utils_get_keys_path (testfile);
 	unlink (keyfile);
 
 	success = nm_connection_verify (reread, &error);
@@ -10449,10 +9678,7 @@ test_write_wifi_dynamic_wep_leap (void)
 	unlink (testfile);
 
 	g_free (testfile);
-	g_free (unmanaged);
 	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
 }
@@ -10471,11 +9697,7 @@ test_write_wired_qeth_dhcp (void)
 	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_simple_connection_new ();
 
@@ -10546,15 +9768,11 @@ test_write_wired_qeth_dhcp (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -10566,13 +9784,7 @@ test_write_wired_qeth_dhcp (void)
 	ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
 	        "wired-qeth-dhcp-write", "written and re-read connection weren't the same.");
 
-	if (route6file)
-		unlink (route6file);
-
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
 	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
@@ -10592,11 +9804,7 @@ test_write_wired_ctc_dhcp (void)
 	gboolean success;
 	GError *error = NULL;
 	char *testfile = NULL;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
 	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	shvarFile *ifcfg;
 	char *tmp;
 
@@ -10680,15 +9888,11 @@ test_write_wired_ctc_dhcp (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	g_assert (reread);
@@ -10699,13 +9903,7 @@ test_write_wired_ctc_dhcp (void)
 	success = nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT);
 	g_assert (success);
 
-	if (route6file)
-		unlink (route6file);
-
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
 	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
@@ -10724,11 +9922,7 @@ test_write_permissions (void)
 	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_simple_connection_new ();
 
@@ -10791,15 +9985,11 @@ test_write_permissions (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -10811,13 +10001,7 @@ test_write_permissions (void)
 	ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
 	        "permissions-write", "written and re-read connection weren't the same.");
 
-	if (route6file)
-		unlink (route6file);
-
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
 	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
@@ -10839,11 +10023,7 @@ test_write_wifi_wep_agent_keys (void)
 	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_simple_connection_new ();
 	g_assert (connection != NULL);
@@ -10919,15 +10099,11 @@ test_write_wifi_wep_agent_keys (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_WIRELESS,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_WIRELESS,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	g_assert_no_error (error);
@@ -10951,13 +10127,7 @@ test_write_wifi_wep_agent_keys (void)
 	success = nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT);
 	g_assert (success);
 
-	if (route6file)
-		unlink (route6file);
-
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
 	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
@@ -11031,6 +10201,7 @@ test_write_wired_pppoe (void)
 	        "wired-pppoe-write", "unexpected success writing connection to disk");
 
 	g_object_unref (connection);
+	g_clear_error (&error);
 }
 
 static void
@@ -11093,6 +10264,7 @@ test_write_vpn (void)
 	        "vpn-write", "unexpected success writing connection to disk");
 
 	g_object_unref (connection);
+	g_clear_error (&error);
 }
 
 static void
@@ -11175,6 +10347,7 @@ test_write_mobile_broadband (gboolean gsm)
 	        "mobile-broadband-write", "unexpected success writing connection to disk");
 
 	g_object_unref (connection);
+	g_clear_error (&error);
 }
 
 #define TEST_IFCFG_BRIDGE_MAIN TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bridge-main"
@@ -11186,22 +10359,13 @@ test_read_bridge_main (void)
 	NMSettingBridge *s_bridge;
 	const char *mac;
 	char expected_mac_address[ETH_ALEN] = { 0x00, 0x16, 0x41, 0x11, 0x22, 0x33 };
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
-	GError *error = NULL;
-
-	connection = connection_from_file (TEST_IFCFG_BRIDGE_MAIN,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	GError *error = NULL;
+
+	connection = connection_from_file_test (TEST_IFCFG_BRIDGE_MAIN,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	g_assert (connection);
 	g_assert (nm_connection_verify (connection, &error));
 	g_assert_no_error (error);
@@ -11212,7 +10376,7 @@ test_read_bridge_main (void)
 
 	s_bridge = nm_connection_get_setting_bridge (connection);
 	g_assert (s_bridge);
-	g_assert_cmpuint (nm_setting_bridge_get_forward_delay (s_bridge), ==, 0);
+	g_assert_cmpuint (nm_setting_bridge_get_forward_delay (s_bridge), ==, 2);
 	g_assert (nm_setting_bridge_get_stp (s_bridge));
 	g_assert_cmpuint (nm_setting_bridge_get_priority (s_bridge), ==, 32744);
 	g_assert_cmpuint (nm_setting_bridge_get_hello_time (s_bridge), ==, 7);
@@ -11224,10 +10388,6 @@ test_read_bridge_main (void)
 	g_assert (mac);
 	g_assert (nm_utils_hwaddr_matches (mac, -1, expected_mac_address, ETH_ALEN));
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -11246,11 +10406,6 @@ test_write_bridge_main (void)
 	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_simple_connection_new ();
 	g_assert (connection);
@@ -11318,15 +10473,11 @@ test_write_bridge_main (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_BRIDGE,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_BRIDGE,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	g_assert (reread);
@@ -11335,10 +10486,6 @@ test_write_bridge_main (void)
 	g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT));
 
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
 }
@@ -11351,23 +10498,14 @@ test_read_bridge_component (void)
 	NMConnection *connection;
 	NMSettingConnection *s_con;
 	NMSettingBridgePort *s_port;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	gboolean success;
 
-	connection = connection_from_file (TEST_IFCFG_BRIDGE_COMPONENT,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_BRIDGE_COMPONENT,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	g_assert (connection);
 
 	success = nm_connection_verify (connection, &error);
@@ -11385,10 +10523,6 @@ test_read_bridge_component (void)
 	g_assert_cmpuint (nm_setting_bridge_port_get_priority (s_port), ==, 28);
 	g_assert_cmpuint (nm_setting_bridge_port_get_path_cost (s_port), ==, 100);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -11406,11 +10540,7 @@ test_write_bridge_component (void)
 	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_simple_connection_new ();
 	g_assert (connection);
@@ -11466,15 +10596,11 @@ test_write_bridge_component (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	g_assert (reread);
@@ -11484,13 +10610,7 @@ test_write_bridge_component (void)
 
 	g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT));
 
-	if (route6file)
-		unlink (route6file);
-
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
 	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
@@ -11501,22 +10621,13 @@ test_read_bridge_missing_stp (void)
 {
 	NMConnection *connection;
 	NMSettingBridge *s_bridge;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
-	GError *error = NULL;
-
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bridge-missing-stp",
-	                                   NULL,
-	                                   TYPE_BRIDGE,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	GError *error = NULL;
+
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bridge-missing-stp",
+	                                        NULL,
+	                                        TYPE_BRIDGE,
+	                                        NULL,
+	                                        &error);
 	g_assert (connection);
 	g_assert (nm_connection_verify (connection, &error));
 	g_assert_no_error (error);
@@ -11529,10 +10640,6 @@ test_read_bridge_missing_stp (void)
 	g_assert (s_bridge);
 	g_assert (nm_setting_bridge_get_stp (s_bridge) == FALSE);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -11542,31 +10649,18 @@ static void
 test_read_vlan_interface (void)
 {
 	NMConnection *connection;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	NMSettingVlan *s_vlan;
 	guint32 from = 0, to = 0;
 
-	connection = connection_from_file (TEST_IFCFG_VLAN_INTERFACE,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_VLAN_INTERFACE,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection != NULL);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 
 	g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "vlan43");
 
@@ -11613,30 +10707,17 @@ static void
 test_read_vlan_only_vlan_id (void)
 {
 	NMConnection *connection;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	NMSettingVlan *s_vlan;
 
-	connection = connection_from_file (TEST_IFCFG_VLAN_ONLY_VLANID,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_VLAN_ONLY_VLANID,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection != NULL);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 
 	g_assert (nm_connection_get_interface_name (connection) == NULL);
 
@@ -11655,30 +10736,17 @@ static void
 test_read_vlan_only_device (void)
 {
 	NMConnection *connection;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	NMSettingVlan *s_vlan;
 
-	connection = connection_from_file (TEST_IFCFG_VLAN_ONLY_DEVICE,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_VLAN_ONLY_DEVICE,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection != NULL);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 
 	g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "eth0.9");
 
@@ -11698,9 +10766,9 @@ test_read_vlan_physdev (void)
 	GError *error = NULL;
 	NMSettingVlan *s_vlan;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-physdev",
-	                                   NULL, TYPE_ETHERNET, NULL,
-	                                   NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-physdev",
+	                                        NULL, TYPE_ETHERNET, NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	g_assert (nm_connection_verify (connection, &error));
@@ -11720,24 +10788,15 @@ static void
 test_write_vlan (void)
 {
 	NMConnection *connection;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
 	char *written = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	gboolean success = FALSE;
 
-	connection = connection_from_file (TEST_IFCFG_VLAN_INTERFACE,
-	                                   NULL,
-	                                   TYPE_VLAN,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_VLAN_INTERFACE,
+	                                        NULL,
+	                                        TYPE_VLAN,
+	                                        NULL,
+	                                        &error);
 	g_assert (connection != NULL);
 
 	success = writer_new_connection (connection,
@@ -11749,46 +10808,25 @@ test_write_vlan (void)
 	unlink (written);
 	g_free (written);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
+	g_object_unref (connection);
 }
 
 static void
 test_write_vlan_only_vlanid (void)
 {
 	NMConnection *connection, *reread;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
 	char *written = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	gboolean success = FALSE;
 
-	connection = connection_from_file (TEST_IFCFG_VLAN_ONLY_VLANID,
-	                                   NULL,
-	                                   TYPE_VLAN,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_VLAN_ONLY_VLANID,
+	                                        NULL,
+	                                        TYPE_VLAN,
+	                                        NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection != NULL);
 
-	g_free (unmanaged);
-	unmanaged = NULL;
-	g_free (keyfile);
-	keyfile = NULL;
-	g_free (routefile);
-	routefile = NULL;
-	g_free (route6file);
-	route6file = NULL;
-
 	success = writer_new_connection (connection,
 	                                 TEST_SCRATCH_DIR "/network-scripts/",
 	                                 &written,
@@ -11799,21 +10837,13 @@ test_write_vlan_only_vlanid (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (written,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (written,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (written);
 	g_free (written);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 
 	g_assert_no_error (error);
 	g_assert (reread != NULL);
@@ -11842,11 +10872,6 @@ test_write_ethernet_missing_ipv6 (void)
 	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_simple_connection_new ();
 	g_assert (connection);
@@ -11907,15 +10932,11 @@ test_write_ethernet_missing_ipv6 (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -11941,10 +10962,6 @@ test_write_ethernet_missing_ipv6 (void)
 	        "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);
 }
@@ -11955,11 +10972,12 @@ test_read_ibft_ignored (void)
 	NMConnection *connection;
 	GError *error = NULL;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-ibft",
-	                                   NULL, TYPE_ETHERNET,
-	                                   NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-ibft",
+	                                        NULL, TYPE_ETHERNET,
+	                                        NULL, &error);
 	g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
 	g_assert (connection == NULL);
+	g_clear_error (&error);
 }
 
 #define TEST_IFCFG_BOND_MAIN TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bond-main"
@@ -11969,22 +10987,13 @@ test_read_bond_main (void)
 {
 	NMConnection *connection;
 	NMSettingBond *s_bond;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
-	GError *error = NULL;
-
-	connection = connection_from_file (TEST_IFCFG_BOND_MAIN,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	GError *error = NULL;
+
+	connection = connection_from_file_test (TEST_IFCFG_BOND_MAIN,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "bond-main-read", "unexpected failure reading %s", TEST_IFCFG_BOND_MAIN);
 
@@ -12007,10 +11016,6 @@ test_read_bond_main (void)
 	        "bond-main", "failed to verify %s: miimon=%s does not match 100",
 	        TEST_IFCFG_BOND_MAIN, nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MIIMON));
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -12029,11 +11034,6 @@ test_write_bond_main (void)
 	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_simple_connection_new ();
 
@@ -12100,15 +11100,11 @@ test_write_bond_main (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_BOND,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_BOND,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -12121,10 +11117,6 @@ test_write_bond_main (void)
 	        "bond-main-write", "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);
 }
@@ -12136,22 +11128,13 @@ test_read_bond_slave (void)
 {
 	NMConnection *connection;
 	NMSettingConnection *s_con;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
-	GError *error = NULL;
-
-	connection = connection_from_file (TEST_IFCFG_BOND_SLAVE,
-	                                   NULL,
-	                                   TYPE_ETHERNET,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	GError *error = NULL;
+
+	connection = connection_from_file_test (TEST_IFCFG_BOND_SLAVE,
+	                                        NULL,
+	                                        TYPE_ETHERNET,
+	                                        NULL,
+	                                        &error);
 	g_test_assert_expected_messages ();
 
 	ASSERT (connection != NULL,
@@ -12173,10 +11156,6 @@ test_read_bond_slave (void)
 	        "bond-slave-read", "failed to verify %s: slave-type is not bond",
 	        TEST_IFCFG_BOND_SLAVE);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -12193,11 +11172,7 @@ test_write_bond_slave (void)
 	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_simple_connection_new ();
 
@@ -12245,15 +11220,11 @@ test_write_bond_slave (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -12265,13 +11236,7 @@ test_write_bond_slave (void)
 	ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
 	        "bond-slave-write", "written and re-read connection weren't the same.");
 
-	if (route6file)
-		unlink (route6file);
-
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
 	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
@@ -12285,24 +11250,16 @@ test_read_infiniband (void)
 	NMConnection *connection;
 	NMSettingInfiniband *s_infiniband;
 	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
 	GError *error = NULL;
 	const char *mac;
 	char expected_mac_address[INFINIBAND_ALEN] = { 0x80, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22 };
 	const char *transport_mode;
 
-	connection = connection_from_file (TEST_IFCFG_INFINIBAND,
-	                                   NULL,
-	                                   TYPE_INFINIBAND,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	connection = connection_from_file_test (TEST_IFCFG_INFINIBAND,
+	                                        NULL,
+	                                        TYPE_INFINIBAND,
+	                                        &unmanaged,
+	                                        &error);
 	ASSERT (connection != NULL,
 	        "infiniband-read", "failed to read %s: %s", TEST_IFCFG_INFINIBAND, error->message);
 
@@ -12346,10 +11303,6 @@ test_read_infiniband (void)
 	        NM_SETTING_INFINIBAND_SETTING_NAME,
 	        NM_SETTING_INFINIBAND_TRANSPORT_MODE);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -12369,11 +11322,6 @@ test_write_infiniband (void)
 	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_simple_connection_new ();
 
@@ -12443,15 +11391,11 @@ test_write_infiniband (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_INFINIBAND,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_INFINIBAND,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -12464,10 +11408,6 @@ test_write_infiniband (void)
 	        "infiniband-write", "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);
 }
@@ -12479,22 +11419,13 @@ test_read_bond_slave_ib (void)
 {
 	NMConnection *connection;
 	NMSettingConnection *s_con;
-	char *unmanaged = NULL;
-	char *keyfile = NULL;
-	char *routefile = NULL;
-	char *route6file = NULL;
-	gboolean ignore_error = FALSE;
-	GError *error = NULL;
-
-	connection = connection_from_file (TEST_IFCFG_BOND_SLAVE_IB,
-	                                   NULL,
-	                                   NULL,
-	                                   &unmanaged,
-	                                   &keyfile,
-	                                   &routefile,
-	                                   &route6file,
-	                                   &error,
-	                                   &ignore_error);
+	GError *error = NULL;
+
+	connection = connection_from_file_test (TEST_IFCFG_BOND_SLAVE_IB,
+	                                        NULL,
+	                                        NULL,
+	                                        NULL,
+	                                        &error);
 	g_test_assert_expected_messages();
 
 	ASSERT (connection != NULL,
@@ -12516,10 +11447,6 @@ test_read_bond_slave_ib (void)
 	        "bond-slave-read-ib", "failed to verify %s: slave-type is not bond",
 	        TEST_IFCFG_BOND_SLAVE_IB);
 
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
-	g_free (route6file);
 	g_object_unref (connection);
 }
 
@@ -12535,11 +11462,7 @@ test_write_bond_slave_ib (void)
 	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_simple_connection_new ();
 
@@ -12588,15 +11511,11 @@ test_write_bond_slave_ib (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               NULL,
-	                               &unmanaged,
-	                               &keyfile,
-	                               &routefile,
-	                               &route6file,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    NULL,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	ASSERT (reread != NULL,
@@ -12608,18 +11527,43 @@ test_write_bond_slave_ib (void)
 	ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
 	        "bond-slave-write-ib", "written and re-read connection weren't the same.");
 
-	if (route6file)
-		unlink (route6file);
-
 	g_free (testfile);
-	g_free (unmanaged);
-	g_free (keyfile);
-	g_free (routefile);
 	g_free (route6file);
 	g_object_unref (connection);
 	g_object_unref (reread);
 }
 
+static void
+test_read_bond_opts_mode_numeric (void)
+{
+	NMConnection *connection;
+	NMSettingConnection *s_con;
+	NMSettingBond *s_bond;
+	gboolean success;
+	GError *error = NULL;
+
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-bond-mode-numeric",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
+	g_assert_no_error (error);
+	g_assert (connection);
+
+	success = nm_connection_verify (connection, &error);
+	g_assert_no_error (error);
+	g_assert (success);
+
+	g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "bond0");
+
+	s_con = nm_connection_get_setting_connection (connection);
+	g_assert (s_con);
+	g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_BOND_SETTING_NAME);
+
+	s_bond = nm_connection_get_setting_bond (connection);
+	g_assert (s_bond);
+	g_assert_cmpstr (nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MODE), ==, "802.3ad");
+
+	g_object_unref (connection);
+}
+
 #define DCB_ALL_FLAGS (NM_SETTING_DCB_FLAG_ENABLE | \
                        NM_SETTING_DCB_FLAG_ADVERTISE | \
                        NM_SETTING_DCB_FLAG_WILLING)
@@ -12639,8 +11583,8 @@ test_read_dcb_basic (void)
 	guint expected_traffic_classes[8] = { 7, 6, 5, 4, 3, 2, 1, 0 };
 	gboolean expected_pfcs[8] = { TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE };
 
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	success = nm_connection_verify (connection, &error);
@@ -12698,7 +11642,7 @@ test_write_dcb_basic (void)
 	NMSettingDcb *s_dcb;
 	NMSettingIPConfig *s_ip4;
 	NMSettingIPConfig *s_ip6;
-	gboolean success, ignore_error;
+	gboolean success;
 	guint i;
 	char *uuid, *testfile;
 	const guint group_ids[8] = { 4, 0xF, 6, 0xF, 1, 7, 3, 0xF };
@@ -12770,13 +11714,11 @@ test_write_dcb_basic (void)
 	g_assert (testfile);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               NULL, NULL,
-	                               NULL, NULL,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	g_assert_no_error (error);
@@ -12797,8 +11739,8 @@ test_read_dcb_default_app_priorities (void)
 	NMSettingDcb *s_dcb;
 	gboolean success;
 
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-default-app-priorities",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-default-app-priorities",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 	success = nm_connection_verify (connection, &error);
@@ -12828,13 +11770,14 @@ test_read_dcb_bad_booleans (void)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*invalid DCB_PG_STRICT value*not all 0s and 1s*");
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-booleans",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-booleans",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_test_assert_expected_messages ();
 
 	g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
 	g_assert (strstr (error->message, "invalid boolean digit"));
 	g_assert (connection == NULL);
+	g_clear_error (&error);
 }
 
 static void
@@ -12845,13 +11788,14 @@ test_read_dcb_short_booleans (void)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*DCB_PG_STRICT value*8 characters*");
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-booleans",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-booleans",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_test_assert_expected_messages ();
 
 	g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
 	g_assert (strstr (error->message, "boolean array must be 8 characters"));
 	g_assert (connection == NULL);
+	g_clear_error (&error);
 }
 
 static void
@@ -12862,13 +11806,14 @@ test_read_dcb_bad_uints (void)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*invalid DCB_PG_UP2TC value*not 0 - 7*");
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-uints",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-uints",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_test_assert_expected_messages ();
 
 	g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
 	g_assert (strstr (error->message, "invalid uint digit"));
 	g_assert (connection == NULL);
+	g_clear_error (&error);
 }
 
 static void
@@ -12879,13 +11824,14 @@ test_read_dcb_short_uints (void)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*DCB_PG_UP2TC value*8 characters*");
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-uints",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-uints",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_test_assert_expected_messages ();
 
 	g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
 	g_assert (strstr (error->message, "uint array must be 8 characters"));
 	g_assert (connection == NULL);
+	g_clear_error (&error);
 }
 
 static void
@@ -12896,13 +11842,14 @@ test_read_dcb_bad_percent (void)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*invalid DCB_PG_PCT percentage value*");
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-percent",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-percent",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_test_assert_expected_messages ();
 
 	g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
 	g_assert (strstr (error->message, "invalid percent element"));
 	g_assert (connection == NULL);
+	g_clear_error (&error);
 }
 
 static void
@@ -12913,13 +11860,14 @@ test_read_dcb_short_percent (void)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*invalid DCB_PG_PCT percentage list value*");
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-percent",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-percent",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_test_assert_expected_messages ();
 
 	g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
 	g_assert (strstr (error->message, "percent array must be 8 elements"));
 	g_assert (connection == NULL);
+	g_clear_error (&error);
 }
 
 static void
@@ -12930,13 +11878,14 @@ test_read_dcb_pgpct_not_100 (void)
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
 	                       "*DCB_PG_PCT percentages do not equal 100*");
-	connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-pgpct-not-100",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-pgpct-not-100",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_test_assert_expected_messages ();
 
 	g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
 	g_assert (strstr (error->message, "invalid percentage sum"));
 	g_assert (connection == NULL);
+	g_clear_error (&error);
 }
 
 static void
@@ -12950,7 +11899,7 @@ test_read_fcoe_mode (gconstpointer user_data)
 	char *file;
 
 	file = g_strdup_printf (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-fcoe-%s", expected_mode);
-	connection = connection_from_file (file, NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (file, NULL, TYPE_ETHERNET, NULL, &error);
 	g_free (file);
 	g_assert_no_error (error);
 	g_assert (connection);
@@ -12978,7 +11927,7 @@ test_write_fcoe_mode (gconstpointer user_data)
 	NMSettingDcb *s_dcb;
 	NMSettingIPConfig *s_ip4;
 	NMSettingIPConfig *s_ip6;
-	gboolean success, ignore_error;
+	gboolean success;
 	char *uuid, *testfile;
 
 	connection = nm_simple_connection_new ();
@@ -13040,13 +11989,11 @@ test_write_fcoe_mode (gconstpointer user_data)
 	}
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile,
-	                               NULL,
-	                               TYPE_ETHERNET,
-	                               NULL, NULL,
-	                               NULL, NULL,
-	                               &error,
-	                               &ignore_error);
+	reread = connection_from_file_test (testfile,
+	                                    NULL,
+	                                    TYPE_ETHERNET,
+	                                    NULL,
+	                                    &error);
 	unlink (testfile);
 
 	g_assert_no_error (error);
@@ -13069,8 +12016,8 @@ test_read_team_master (void)
 	GError *error = NULL;
 	const char *expected_config = "{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }";
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-master",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-master",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 
@@ -13181,8 +12128,8 @@ test_write_team_master (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile, NULL, TYPE_ETHERNET,
-	                               NULL, NULL, NULL, NULL, &error, NULL);
+	reread = connection_from_file_test (testfile, NULL, TYPE_ETHERNET,
+	                                    NULL, &error);
 	unlink (testfile);
 	g_assert_no_error (error);
 	g_assert (reread);
@@ -13208,8 +12155,8 @@ test_read_team_port (void)
 	GError *error = NULL;
 	const char *expected_config = "{ \"p4p1\": { \"prio\": -10, \"sticky\": true } }";
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 
@@ -13294,6 +12241,7 @@ test_write_team_port (void)
 	val = svGetValue (f, "TEAM_PORT_CONFIG", TRUE);
 	g_assert (val);
 	g_assert_cmpstr (val, ==, escaped_expected_config);
+	g_free (val);
 	val = svGetValue (f, "TEAM_MASTER", TRUE);
 	g_assert (val);
 	g_assert_cmpstr (val, ==, "team0");
@@ -13304,8 +12252,8 @@ test_write_team_port (void)
 	nm_connection_normalize (connection, NULL, NULL, NULL);
 
 	/* re-read the connection for comparison */
-	reread = connection_from_file (testfile, NULL, TYPE_ETHERNET,
-	                               NULL, NULL, NULL, NULL, &error, NULL);
+	reread = connection_from_file_test (testfile, NULL, TYPE_ETHERNET,
+	                                    NULL, &error);
 	unlink (testfile);
 	g_assert_no_error (error);
 	g_assert (reread);
@@ -13329,8 +12277,8 @@ test_read_team_port_empty_config (void)
 	gboolean success;
 	GError *error = NULL;
 
-	connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port-empty-config",
-	                                   NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port-empty-config",
+	                                        NULL, TYPE_ETHERNET, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (connection);
 
@@ -13475,8 +12423,8 @@ test_read_vlan_trailing_spaces (void)
 	g_assert (strstr (contents, "DEVICE=\"vlan201\"  \n"));
 	g_free (contents);
 
-	connection = connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL,
-	                                   NULL, NULL, NULL, &error, NULL);
+	connection = connection_from_file_test (testfile, NULL, TYPE_ETHERNET, NULL,
+	                                        &error);
 	g_assert_no_error (error);
 	g_assert (connection != NULL);
 
@@ -13513,7 +12461,7 @@ NMTST_DEFINE ();
 
 int main (int argc, char **argv)
 {
-	nmtst_init_assert_logging (&argc, &argv);
+	nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT");
 
 	g_test_add_func (TPATH "svUnescape", test_svUnescape);
 	g_test_add_func (TPATH "vlan-trailing-spaces", test_read_vlan_trailing_spaces);
@@ -13536,8 +12484,10 @@ int main (int argc, char **argv)
 	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);
 	test_read_wired_defroute_no ();
 	test_read_wired_defroute_no_gatewaydev_yes ();
@@ -13706,6 +12656,7 @@ int main (int argc, char **argv)
 	test_write_bond_main ();
 	test_write_bond_slave ();
 	test_write_bond_slave_ib ();
+	g_test_add_func (TPATH "bond/bonding-opts-numeric-mode", test_read_bond_opts_mode_numeric);
 
 	/* bridging */
 	test_read_bridge_main ();
diff --git a/src/settings/plugins/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/utils.c
index 5b9e9d79..4b7cb43d 100644
--- a/src/settings/plugins/ifcfg-rh/utils.c
+++ b/src/settings/plugins/ifcfg-rh/utils.c
@@ -356,6 +356,30 @@ gone:
 }
 
 gboolean
+utils_has_complex_routes (const char *filename)
+{
+	char *rules;
+
+	g_return_val_if_fail (filename != NULL, TRUE);
+
+	rules = utils_get_extra_path (filename, RULE_TAG);
+	if (g_file_test (rules, G_FILE_TEST_EXISTS)) {
+		g_free (rules);
+		return TRUE;
+	}
+	g_free (rules);
+
+	rules = utils_get_extra_path (filename, RULE6_TAG);
+	if (g_file_test (rules, G_FILE_TEST_EXISTS)) {
+		g_free (rules);
+		return TRUE;
+	}
+	g_free (rules);
+
+	return FALSE;
+}
+
+gboolean
 utils_ignore_ip_config (NMConnection *connection)
 {
 	NMSettingConnection *s_con;
diff --git a/src/settings/plugins/ifcfg-rh/utils.h b/src/settings/plugins/ifcfg-rh/utils.h
index 95af828b..445437c4 100644
--- a/src/settings/plugins/ifcfg-rh/utils.h
+++ b/src/settings/plugins/ifcfg-rh/utils.h
@@ -25,6 +25,13 @@
 #include <nm-connection.h>
 #include "shvar.h"
 #include "common.h"
+#include "nm-logging.h"
+
+#define NM_IFCFG_CONNECTION_LOG_PATH(path)  str_if_set (path,"in-memory")
+#define NM_IFCFG_CONNECTION_LOG_FMT         "%s (%s,\"%s\")"
+#define NM_IFCFG_CONNECTION_LOG_ARG(con)    NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con))
+#define NM_IFCFG_CONNECTION_LOG_FMTD        "%s (%s,\"%s\",%p)"
+#define NM_IFCFG_CONNECTION_LOG_ARGD(con)   NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con)
 
 char *utils_single_quote_string (const char *str);
 
@@ -47,6 +54,7 @@ shvarFile *utils_get_route_ifcfg (const char *parent, gboolean should_create);
 shvarFile *utils_get_route6_ifcfg (const char *parent, gboolean should_create);
 
 gboolean utils_has_route_file_new_syntax (const char *filename);
+gboolean utils_has_complex_routes (const char *filename);
 
 gboolean utils_ignore_ip_config (NMConnection *connection);
 
diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c
index f4ffffd6..d2b0c970 100644
--- a/src/settings/plugins/ifcfg-rh/writer.c
+++ b/src/settings/plugins/ifcfg-rh/writer.c
@@ -44,6 +44,7 @@
 #include <nm-utils.h>
 
 #include "nm-logging.h"
+#include "gsystem-local-alloc.h"
 #include "common.h"
 #include "shvar.h"
 #include "reader.h"
@@ -695,9 +696,15 @@ write_wireless_security_setting (NMConnection *connection,
 				 * keys.
 				 */
 				key_type = nm_setting_wireless_security_get_wep_key_type (s_wsec);
+				if (key_type == NM_WEP_KEY_TYPE_UNKNOWN) {
+					if (nm_utils_wep_key_valid (key, NM_WEP_KEY_TYPE_KEY))
+						key_type = NM_WEP_KEY_TYPE_KEY;
+					else if (nm_utils_wep_key_valid (key, NM_WEP_KEY_TYPE_PASSPHRASE))
+						key_type = NM_WEP_KEY_TYPE_PASSPHRASE;
+				}
 				if (key_type == NM_WEP_KEY_TYPE_PASSPHRASE)
 					tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1);
-				else {
+				else if (key_type == NM_WEP_KEY_TYPE_KEY) {
 					tmp = g_strdup_printf ("KEY%d", i + 1);
 
 					/* Add 's:' prefix for ASCII keys */
@@ -705,7 +712,8 @@ write_wireless_security_setting (NMConnection *connection,
 						ascii_key = g_strdup_printf ("s:%s", key);
 						key = ascii_key;
 					}
-				}
+				} else
+					key = NULL;
 
 				set_secret (ifcfg,
 				            tmp,
@@ -1806,6 +1814,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
 	char *route_path = NULL;
 	gint32 j;
 	guint32 i, n, num;
+	gint64 route_metric;
 	GString *searches;
 	gboolean success = FALSE;
 	gboolean fake_ip4 = FALSE;
@@ -2015,6 +2024,11 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
 	            nm_setting_ip_config_get_may_fail (s_ip4) ? "no" : "yes",
 	            FALSE);
 
+	route_metric = nm_setting_ip_config_get_route_metric (s_ip4);
+	tmp = route_metric != -1 ? g_strdup_printf ("%"G_GINT64_FORMAT, route_metric) : NULL;
+	svSetValue (ifcfg, "IPV4_ROUTE_METRIC", tmp, FALSE);
+	g_free (tmp);
+
 	/* Static routes - route-<name> file */
 	route_path = utils_get_route_path (ifcfg->fileName);
 	if (!route_path) {
@@ -2105,13 +2119,16 @@ static void
 write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path)
 {
 	NMSettingIPConfig *s_ip4;
-	char *base_ifcfg_dir, *base_ifcfg_name, *base_name;
+	gs_free char *base_ifcfg_dir = NULL, *base_ifcfg_name = NULL;
+	const char*base_name;
 	int i, num, base_ifcfg_name_len, base_name_len;
 	GDir *dir;
 
 	base_ifcfg_dir = g_path_get_dirname (base_ifcfg_path);
 	base_ifcfg_name = g_path_get_basename (base_ifcfg_path);
 	base_ifcfg_name_len = strlen (base_ifcfg_name);
+	if (!g_str_has_prefix (base_ifcfg_name, IFCFG_TAG))
+		g_return_if_reached ();
 	base_name = base_ifcfg_name + strlen (IFCFG_TAG);
 	base_name_len = strlen (base_name);
 
@@ -2183,9 +2200,6 @@ write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path)
 		svWriteFile (ifcfg, 0644, NULL);
 		svCloseFile (ifcfg);
 	}
-
-	g_free (base_ifcfg_name);
-	g_free (base_ifcfg_dir);
 }
 
 static gboolean
@@ -2249,10 +2263,12 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
 	NMSettingIPConfig *s_ip4;
 	const char *value;
 	char *addr_key;
+	char *tmp;
 	guint32 i, num, num4;
 	GString *searches;
 	NMIPAddress *addr;
 	const char *dns;
+	gint64 route_metric;
 	GString *ip_str1, *ip_str2, *ip_ptr;
 	char *route6_path;
 
@@ -2266,6 +2282,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
 		svSetValue (ifcfg, "IPV6_PEERDNS", "yes", FALSE);
 		svSetValue (ifcfg, "IPV6_PEERROUTES", "yes", FALSE);
 		svSetValue (ifcfg, "IPV6_FAILURE_FATAL", "no", FALSE);
+		svSetValue (ifcfg, "IPV6_ROUTE_METRIC", NULL, FALSE);
 		return TRUE;
 	}
 
@@ -2380,6 +2397,11 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
 	            nm_setting_ip_config_get_may_fail (s_ip6) ? "no" : "yes",
 	            FALSE);
 
+	route_metric = nm_setting_ip_config_get_route_metric (s_ip6);
+	tmp = route_metric != -1 ? g_strdup_printf ("%"G_GINT64_FORMAT, route_metric) : NULL;
+	svSetValue (ifcfg, "IPV6_ROUTE_METRIC", tmp, FALSE);
+	g_free (tmp);
+
 	/* IPv6 Privacy Extensions */
 	svSetValue (ifcfg, "IPV6_PRIVACY", NULL, FALSE);
 	svSetValue (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", NULL, FALSE);
@@ -2624,6 +2646,12 @@ writer_update_connection (NMConnection *connection,
                           const char *keyfile,
                           GError **error)
 {
+	if (utils_has_complex_routes (filename)) {
+		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
+		             "Cannot modify a connection that has an associated 'rule-' or 'rule6-' file");
+		return FALSE;
+	}
+
 	return write_connection (connection, ifcfg_dir, filename, keyfile, NULL, error);
 }