about summary refs log tree commit diff
path: root/libnm-core/nm-connection.c
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2021-01-11 18:07:03 +0100
committerSebastien Bacher <seb128@ubuntu.com>2021-01-11 18:15:57 +0100
commit2567f558da3eb9911678227d4aeb15162e707d89 (patch)
tree13c80b0e091c8ba585b14b966cda998f95f1936d /libnm-core/nm-connection.c
parent02d99ffd62ede29cffcb45fcbe33d044b7406d3a (diff)
parentf54032b30e1ddd84f10a339e0caf493772e049a7 (diff)
Merge branch 'debian/master' into ubuntu/master
Diffstat (limited to 'libnm-core/nm-connection.c')
-rw-r--r--libnm-core/nm-connection.c3842
1 files changed, 1917 insertions, 1925 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index 5f18b651..10bfe7b8 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: LGPL-2.1+
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /*
  * Copyright (C) 2007 - 2018 Red Hat, Inc.
  * Copyright (C) 2007 - 2008 Novell, Inc.
@@ -36,87 +36,80 @@
 
 /*****************************************************************************/
 
-enum {
-	SECRETS_UPDATED,
-	SECRETS_CLEARED,
-	CHANGED,
-	LAST_SIGNAL
-};
+enum { SECRETS_UPDATED, SECRETS_CLEARED, CHANGED, LAST_SIGNAL };
 
-static guint signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL] = {0};
 
 typedef struct {
-	NMConnection *self;
+    NMConnection *self;
 
-	GHashTable *settings;
+    GHashTable *settings;
 
-	/* D-Bus path of the connection, if any */
-	char *path;
+    /* D-Bus path of the connection, if any */
+    char *path;
 } NMConnectionPrivate;
 
-G_DEFINE_INTERFACE (NMConnection, nm_connection, G_TYPE_OBJECT)
+G_DEFINE_INTERFACE(NMConnection, nm_connection, G_TYPE_OBJECT)
 
-static NMConnectionPrivate *nm_connection_get_private (NMConnection *connection);
-#define NM_CONNECTION_GET_PRIVATE(o) (nm_connection_get_private ((NMConnection *)o))
+static NMConnectionPrivate *nm_connection_get_private(NMConnection *connection);
+#define NM_CONNECTION_GET_PRIVATE(o) (nm_connection_get_private((NMConnection *) o))
 
 /*****************************************************************************/
 
 static gpointer
-_gtype_to_hash_key (GType gtype)
+_gtype_to_hash_key(GType gtype)
 {
 #if NM_MORE_ASSERTS
-	_nm_unused const gsize *const test_gtype_typedef = &gtype;
+    _nm_unused const gsize *const test_gtype_typedef = &gtype;
 
-	nm_assert ((GType) (GPOINTER_TO_SIZE (GSIZE_TO_POINTER (gtype))) == gtype);
-	G_STATIC_ASSERT_EXPR (sizeof (gpointer) >= sizeof (gsize));
-	G_STATIC_ASSERT_EXPR (sizeof (gsize) == sizeof (GType));
+    nm_assert((GType)(GPOINTER_TO_SIZE(GSIZE_TO_POINTER(gtype))) == gtype);
+    G_STATIC_ASSERT_EXPR(sizeof(gpointer) >= sizeof(gsize));
+    G_STATIC_ASSERT_EXPR(sizeof(gsize) == sizeof(GType));
 #endif
 
-	return GSIZE_TO_POINTER (gtype);
+    return GSIZE_TO_POINTER(gtype);
 }
 
 /*****************************************************************************/
 
 static void
-setting_changed_cb (NMSetting *setting,
-                    GParamSpec *pspec,
-                    NMConnection *self)
+setting_changed_cb(NMSetting *setting, GParamSpec *pspec, NMConnection *self)
 {
-	g_signal_emit (self, signals[CHANGED], 0);
+    g_signal_emit(self, signals[CHANGED], 0);
 }
 
 static void
-_setting_release (NMConnection *connection, NMSetting *setting)
+_setting_release(NMConnection *connection, NMSetting *setting)
 {
-	g_signal_handlers_disconnect_by_func (setting, setting_changed_cb, connection);
+    g_signal_handlers_disconnect_by_func(setting, setting_changed_cb, connection);
 }
 
 static gboolean
-_setting_release_hfr (gpointer key, gpointer value, gpointer user_data)
+_setting_release_hfr(gpointer key, gpointer value, gpointer user_data)
 {
-	_setting_release (user_data, value);
-	return TRUE;
+    _setting_release(user_data, value);
+    return TRUE;
 }
 
 static void
-_nm_connection_add_setting (NMConnection *connection, NMSetting *setting)
+_nm_connection_add_setting(NMConnection *connection, NMSetting *setting)
 {
-	NMConnectionPrivate *priv;
-	GType setting_type;
-	NMSetting *s_old;
+    NMConnectionPrivate *priv;
+    GType                setting_type;
+    NMSetting *          s_old;
 
-	nm_assert (NM_IS_CONNECTION (connection));
-	nm_assert (NM_IS_SETTING (setting));
+    nm_assert(NM_IS_CONNECTION(connection));
+    nm_assert(NM_IS_SETTING(setting));
 
-	priv = NM_CONNECTION_GET_PRIVATE (connection);
-	setting_type = G_OBJECT_TYPE (setting);
+    priv         = NM_CONNECTION_GET_PRIVATE(connection);
+    setting_type = G_OBJECT_TYPE(setting);
 
-	if ((s_old = g_hash_table_lookup (priv->settings, _gtype_to_hash_key (setting_type))))
-		_setting_release (connection, s_old);
+    if ((s_old = g_hash_table_lookup(priv->settings, _gtype_to_hash_key(setting_type))))
+        _setting_release(connection, s_old);
 
-	g_hash_table_insert (priv->settings, _gtype_to_hash_key (setting_type), setting);
+    g_hash_table_insert(priv->settings, _gtype_to_hash_key(setting_type), setting);
 
-	g_signal_connect (setting, "notify", (GCallback) setting_changed_cb, connection);
+    g_signal_connect(setting, "notify", (GCallback) setting_changed_cb, connection);
 }
 
 /**
@@ -130,33 +123,33 @@ _nm_connection_add_setting (NMConnection *connection, NMSetting *setting)
  * the setting object's reference count.
  **/
 void
-nm_connection_add_setting (NMConnection *connection, NMSetting *setting)
+nm_connection_add_setting(NMConnection *connection, NMSetting *setting)
 {
-	g_return_if_fail (NM_IS_CONNECTION (connection));
-	g_return_if_fail (NM_IS_SETTING (setting));
+    g_return_if_fail(NM_IS_CONNECTION(connection));
+    g_return_if_fail(NM_IS_SETTING(setting));
 
-	_nm_connection_add_setting (connection, setting);
-	g_signal_emit (connection, signals[CHANGED], 0);
+    _nm_connection_add_setting(connection, setting);
+    g_signal_emit(connection, signals[CHANGED], 0);
 }
 
 gboolean
-_nm_connection_remove_setting (NMConnection *connection, GType setting_type)
+_nm_connection_remove_setting(NMConnection *connection, GType setting_type)
 {
-	NMConnectionPrivate *priv;
-	NMSetting *setting;
+    NMConnectionPrivate *priv;
+    NMSetting *          setting;
 
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
-	g_return_val_if_fail (g_type_is_a (setting_type, NM_TYPE_SETTING), FALSE);
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE);
+    g_return_val_if_fail(g_type_is_a(setting_type, NM_TYPE_SETTING), FALSE);
 
-	priv = NM_CONNECTION_GET_PRIVATE (connection);
-	setting = g_hash_table_lookup (priv->settings, _gtype_to_hash_key (setting_type));
-	if (setting) {
-		g_signal_handlers_disconnect_by_func (setting, setting_changed_cb, connection);
-		g_hash_table_remove (priv->settings, _gtype_to_hash_key (setting_type));
-		g_signal_emit (connection, signals[CHANGED], 0);
-		return TRUE;
-	}
-	return FALSE;
+    priv    = NM_CONNECTION_GET_PRIVATE(connection);
+    setting = g_hash_table_lookup(priv->settings, _gtype_to_hash_key(setting_type));
+    if (setting) {
+        g_signal_handlers_disconnect_by_func(setting, setting_changed_cb, connection);
+        g_hash_table_remove(priv->settings, _gtype_to_hash_key(setting_type));
+        g_signal_emit(connection, signals[CHANGED], 0);
+        return TRUE;
+    }
+    return FALSE;
 }
 
 /**
@@ -168,31 +161,31 @@ _nm_connection_remove_setting (NMConnection *connection, GType setting_type)
  * operation dereferences the #NMSetting object.
  **/
 void
-nm_connection_remove_setting (NMConnection *connection, GType setting_type)
+nm_connection_remove_setting(NMConnection *connection, GType setting_type)
 {
-	_nm_connection_remove_setting (connection, setting_type);
+    _nm_connection_remove_setting(connection, setting_type);
 }
 
 static gpointer
-_connection_get_setting (NMConnection *connection, GType setting_type)
+_connection_get_setting(NMConnection *connection, GType setting_type)
 {
-	NMSetting *setting;
+    NMSetting *setting;
 
-	nm_assert (NM_IS_CONNECTION (connection));
-	nm_assert (g_type_is_a (setting_type, NM_TYPE_SETTING));
+    nm_assert(NM_IS_CONNECTION(connection));
+    nm_assert(g_type_is_a(setting_type, NM_TYPE_SETTING));
 
-	setting = g_hash_table_lookup (NM_CONNECTION_GET_PRIVATE (connection)->settings,
-	                               _gtype_to_hash_key (setting_type));
-	nm_assert (!setting || G_TYPE_CHECK_INSTANCE_TYPE (setting, setting_type));
-	return setting;
+    setting = g_hash_table_lookup(NM_CONNECTION_GET_PRIVATE(connection)->settings,
+                                  _gtype_to_hash_key(setting_type));
+    nm_assert(!setting || G_TYPE_CHECK_INSTANCE_TYPE(setting, setting_type));
+    return setting;
 }
 
 static gpointer
-_connection_get_setting_check (NMConnection *connection, GType setting_type)
+_connection_get_setting_check(NMConnection *connection, GType setting_type)
 {
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
 
-	return _connection_get_setting (connection, setting_type);
+    return _connection_get_setting(connection, setting_type);
 }
 
 /**
@@ -207,23 +200,21 @@ _connection_get_setting_check (NMConnection *connection, GType setting_type)
  * added to the #NMConnection
  **/
 NMSetting *
-nm_connection_get_setting (NMConnection *connection, GType setting_type)
+nm_connection_get_setting(NMConnection *connection, GType setting_type)
 {
-	g_return_val_if_fail (g_type_is_a (setting_type, NM_TYPE_SETTING), NULL);
+    g_return_val_if_fail(g_type_is_a(setting_type, NM_TYPE_SETTING), NULL);
 
-	return _connection_get_setting_check (connection, setting_type);
+    return _connection_get_setting_check(connection, setting_type);
 }
 
 NMSettingIPConfig *
-nm_connection_get_setting_ip_config (NMConnection *connection,
-                                     int addr_family)
+nm_connection_get_setting_ip_config(NMConnection *connection, int addr_family)
 {
-	nm_assert_addr_family (addr_family);
+    nm_assert_addr_family(addr_family);
 
-	return NM_SETTING_IP_CONFIG (_connection_get_setting (connection,
-	                                                        (addr_family == AF_INET)
-	                                                      ? NM_TYPE_SETTING_IP4_CONFIG
-	                                                      : NM_TYPE_SETTING_IP6_CONFIG));
+    return NM_SETTING_IP_CONFIG(_connection_get_setting(
+        connection,
+        (addr_family == AF_INET) ? NM_TYPE_SETTING_IP4_CONFIG : NM_TYPE_SETTING_IP6_CONFIG));
 }
 
 /**
@@ -238,80 +229,85 @@ nm_connection_get_setting_ip_config (NMConnection *connection,
  * added to the #NMConnection
  **/
 NMSetting *
-nm_connection_get_setting_by_name (NMConnection *connection, const char *name)
+nm_connection_get_setting_by_name(NMConnection *connection, const char *name)
 {
-	GType type;
+    GType type;
 
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
 
-	type = nm_setting_lookup_type (name);
-	return type ? _connection_get_setting (connection, type) : NULL;
+    type = nm_setting_lookup_type(name);
+    return type ? _connection_get_setting(connection, type) : NULL;
 }
 
 /*****************************************************************************/
 
 gpointer /* (NMSetting *) */
-_nm_connection_check_main_setting (NMConnection *connection,
-                                   const char *setting_name,
-                                   GError **error)
+_nm_connection_check_main_setting(NMConnection *connection,
+                                  const char *  setting_name,
+                                  GError **     error)
 {
-	NMSetting *setting;
+    NMSetting *setting;
 
-	nm_assert (NM_IS_CONNECTION (connection));
-	nm_assert (setting_name);
+    nm_assert(NM_IS_CONNECTION(connection));
+    nm_assert(setting_name);
 
-	if (!nm_connection_is_type (connection, setting_name)) {
-		nm_utils_error_set (error,
-		                    NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE,
-		                    "connection type is not \"%s\"",
-		                    setting_name);
-		return NULL;
-	}
+    if (!nm_connection_is_type(connection, setting_name)) {
+        nm_utils_error_set(error,
+                           NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE,
+                           "connection type is not \"%s\"",
+                           setting_name);
+        return NULL;
+    }
 
-	setting = nm_connection_get_setting_by_name (connection, setting_name);
-	if (!setting) {
-		nm_utils_error_set (error,
-		                    NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE,
-		                    "connection misses \"%s\" settings",
-		                    setting_name);
-		return NULL;
-	}
+    setting = nm_connection_get_setting_by_name(connection, setting_name);
+    if (!setting) {
+        nm_utils_error_set(error,
+                           NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE,
+                           "connection misses \"%s\" settings",
+                           setting_name);
+        return NULL;
+    }
 
-	return setting;
+    return setting;
 }
 
 /*****************************************************************************/
 
 static gboolean
-validate_permissions_type (GVariant *variant, GError **error)
-{
-	GVariant *s_con;
-	GVariant *permissions;
-	gboolean valid = TRUE;
-
-	/* Ensure the connection::permissions item (if present) is the correct
-	 * type, otherwise the g_object_set() will throw a warning and ignore the
-	 * error, leaving us with no permissions.
-	 */
-	s_con = g_variant_lookup_value (variant, NM_SETTING_CONNECTION_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
-	if (!s_con)
-		return TRUE;
-
-	permissions = g_variant_lookup_value (s_con, NM_SETTING_CONNECTION_PERMISSIONS, NULL);
-	if (permissions) {
-		if (!g_variant_is_of_type (permissions, G_VARIANT_TYPE_STRING_ARRAY)) {
-			g_set_error_literal (error,
-			                     NM_CONNECTION_ERROR,
-			                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
-			                     _("wrong type; should be a list of strings."));
-			g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_PERMISSIONS);
-			valid = FALSE;
-		}
-		g_variant_unref (permissions);
-	}
-
-	g_variant_unref (s_con);
-	return valid;
+validate_permissions_type(GVariant *variant, GError **error)
+{
+    GVariant *s_con;
+    GVariant *permissions;
+    gboolean  valid = TRUE;
+
+    /* Ensure the connection::permissions item (if present) is the correct
+     * type, otherwise the g_object_set() will throw a warning and ignore the
+     * error, leaving us with no permissions.
+     */
+    s_con = g_variant_lookup_value(variant,
+                                   NM_SETTING_CONNECTION_SETTING_NAME,
+                                   NM_VARIANT_TYPE_SETTING);
+    if (!s_con)
+        return TRUE;
+
+    permissions = g_variant_lookup_value(s_con, NM_SETTING_CONNECTION_PERMISSIONS, NULL);
+    if (permissions) {
+        if (!g_variant_is_of_type(permissions, G_VARIANT_TYPE_STRING_ARRAY)) {
+            g_set_error_literal(error,
+                                NM_CONNECTION_ERROR,
+                                NM_CONNECTION_ERROR_INVALID_PROPERTY,
+                                _("wrong type; should be a list of strings."));
+            g_prefix_error(error,
+                           "%s.%s: ",
+                           NM_SETTING_CONNECTION_SETTING_NAME,
+                           NM_SETTING_CONNECTION_PERMISSIONS);
+            valid = FALSE;
+        }
+        g_variant_unref(permissions);
+    }
+
+    g_variant_unref(s_con);
+    return valid;
 }
 
 /**
@@ -332,113 +328,114 @@ validate_permissions_type (GVariant *variant, GError **error)
  *   are lost.
  **/
 gboolean
-_nm_connection_replace_settings (NMConnection *connection,
-                                 GVariant *new_settings,
-                                 NMSettingParseFlags parse_flags,
-                                 GError **error)
-{
-	NMConnectionPrivate *priv;
-	GVariantIter iter;
-	const char *setting_name;
-	GVariant *setting_dict;
-	GSList *settings = NULL, *s;
-	gboolean changed, success;
-
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
-	g_return_val_if_fail (g_variant_is_of_type (new_settings, NM_VARIANT_TYPE_CONNECTION), FALSE);
-	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-	nm_assert (!NM_FLAGS_ANY (parse_flags, ~NM_SETTING_PARSE_FLAGS_ALL));
-	nm_assert (!NM_FLAGS_ALL (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT | NM_SETTING_PARSE_FLAGS_BEST_EFFORT));
-
-	priv = NM_CONNECTION_GET_PRIVATE (connection);
-
-	if (   !NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)
-	    && !validate_permissions_type (new_settings, error))
-		return FALSE;
-
-	g_variant_iter_init (&iter, new_settings);
-	while (g_variant_iter_next (&iter, "{&s@a{sv}}", &setting_name, &setting_dict)) {
-		gs_unref_variant GVariant *setting_dict_free = NULL;
-		GError *local = NULL;
-		NMSetting *setting;
-		GType type;
-
-		setting_dict_free = setting_dict;
-
-		type = nm_setting_lookup_type (setting_name);
-		if (type == G_TYPE_INVALID) {
-			if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT))
-				continue;
-			g_set_error_literal (error,
-			                     NM_CONNECTION_ERROR,
-			                     NM_CONNECTION_ERROR_INVALID_SETTING,
-			                     _("unknown setting name"));
-			g_prefix_error (error, "%s: ", setting_name);
-			g_slist_free_full (settings, g_object_unref);
-			return FALSE;
-		}
-
-		for (s = settings; s; s = s->next) {
-			if (G_OBJECT_TYPE (s->data) == type) {
-				if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) {
-					g_set_error_literal (error,
-					                     NM_CONNECTION_ERROR,
-					                     NM_CONNECTION_ERROR_INVALID_SETTING,
-					                     _("duplicate setting name"));
-					g_prefix_error (error, "%s: ", setting_name);
-					g_slist_free_full (settings, g_object_unref);
-					return FALSE;
-				}
-				/* last wins. */
-				g_object_unref (s->data);
-				settings = g_slist_delete_link (settings, s);
-				break;
-			}
-		}
-
-		setting = _nm_setting_new_from_dbus (type, setting_dict, new_settings, parse_flags, &local);
-
-		if (!setting) {
-			if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT))
-				continue;
-			g_propagate_error (error, local);
-			g_slist_free_full (settings, g_object_unref);
-			return FALSE;
-		}
-
-		settings = g_slist_prepend (settings, setting);
-	}
-
-	if (g_hash_table_size (priv->settings) > 0) {
-		g_hash_table_foreach_remove (priv->settings, _setting_release_hfr, connection);
-		changed = TRUE;
-	} else
-		changed = (settings != NULL);
-
-	/* Note: @settings might be empty in which case the connection
-	 * has no NMSetting instances... which is fine, just something
-	 * to be aware of. */
-	for (s = settings; s; s = s->next)
-		_nm_connection_add_setting (connection, s->data);
-
-	g_slist_free (settings);
-
-	/* If verification/normalization fails, the original connection
-	 * is already lost. From an API point of view, it would be nicer
-	 * not to touch the input argument if we fail at the end.
-	 * However, that would require creating a temporary connection
-	 * to validate it first. As none of the caller cares about the
-	 * state of the @connection when normalization fails, just do it
-	 * this way. */
-	if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_NORMALIZE))
-		success = nm_connection_normalize (connection, NULL, NULL, error);
-	else
-		success = TRUE;
-
-	if (changed)
-		g_signal_emit (connection, signals[CHANGED], 0);
-	return success;
+_nm_connection_replace_settings(NMConnection *      connection,
+                                GVariant *          new_settings,
+                                NMSettingParseFlags parse_flags,
+                                GError **           error)
+{
+    NMConnectionPrivate *priv;
+    GVariantIter         iter;
+    const char *         setting_name;
+    GVariant *           setting_dict;
+    GSList *             settings = NULL, *s;
+    gboolean             changed, success;
+
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE);
+    g_return_val_if_fail(g_variant_is_of_type(new_settings, NM_VARIANT_TYPE_CONNECTION), FALSE);
+    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+
+    nm_assert(!NM_FLAGS_ANY(parse_flags, ~NM_SETTING_PARSE_FLAGS_ALL));
+    nm_assert(!NM_FLAGS_ALL(parse_flags,
+                            NM_SETTING_PARSE_FLAGS_STRICT | NM_SETTING_PARSE_FLAGS_BEST_EFFORT));
+
+    priv = NM_CONNECTION_GET_PRIVATE(connection);
+
+    if (!NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)
+        && !validate_permissions_type(new_settings, error))
+        return FALSE;
+
+    g_variant_iter_init(&iter, new_settings);
+    while (g_variant_iter_next(&iter, "{&s@a{sv}}", &setting_name, &setting_dict)) {
+        gs_unref_variant GVariant *setting_dict_free = NULL;
+        GError *                   local             = NULL;
+        NMSetting *                setting;
+        GType                      type;
+
+        setting_dict_free = setting_dict;
+
+        type = nm_setting_lookup_type(setting_name);
+        if (type == G_TYPE_INVALID) {
+            if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT))
+                continue;
+            g_set_error_literal(error,
+                                NM_CONNECTION_ERROR,
+                                NM_CONNECTION_ERROR_INVALID_SETTING,
+                                _("unknown setting name"));
+            g_prefix_error(error, "%s: ", setting_name);
+            g_slist_free_full(settings, g_object_unref);
+            return FALSE;
+        }
+
+        for (s = settings; s; s = s->next) {
+            if (G_OBJECT_TYPE(s->data) == type) {
+                if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) {
+                    g_set_error_literal(error,
+                                        NM_CONNECTION_ERROR,
+                                        NM_CONNECTION_ERROR_INVALID_SETTING,
+                                        _("duplicate setting name"));
+                    g_prefix_error(error, "%s: ", setting_name);
+                    g_slist_free_full(settings, g_object_unref);
+                    return FALSE;
+                }
+                /* last wins. */
+                g_object_unref(s->data);
+                settings = g_slist_delete_link(settings, s);
+                break;
+            }
+        }
+
+        setting = _nm_setting_new_from_dbus(type, setting_dict, new_settings, parse_flags, &local);
+
+        if (!setting) {
+            if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT))
+                continue;
+            g_propagate_error(error, local);
+            g_slist_free_full(settings, g_object_unref);
+            return FALSE;
+        }
+
+        settings = g_slist_prepend(settings, setting);
+    }
+
+    if (g_hash_table_size(priv->settings) > 0) {
+        g_hash_table_foreach_remove(priv->settings, _setting_release_hfr, connection);
+        changed = TRUE;
+    } else
+        changed = (settings != NULL);
+
+    /* Note: @settings might be empty in which case the connection
+     * has no NMSetting instances... which is fine, just something
+     * to be aware of. */
+    for (s = settings; s; s = s->next)
+        _nm_connection_add_setting(connection, s->data);
+
+    g_slist_free(settings);
+
+    /* If verification/normalization fails, the original connection
+     * is already lost. From an API point of view, it would be nicer
+     * not to touch the input argument if we fail at the end.
+     * However, that would require creating a temporary connection
+     * to validate it first. As none of the caller cares about the
+     * state of the @connection when normalization fails, just do it
+     * this way. */
+    if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_NORMALIZE))
+        success = nm_connection_normalize(connection, NULL, NULL, error);
+    else
+        success = TRUE;
+
+    if (changed)
+        g_signal_emit(connection, signals[CHANGED], 0);
+    return success;
 }
 
 /**
@@ -455,11 +452,12 @@ _nm_connection_replace_settings (NMConnection *connection,
  *   be deserialized (in which case @connection will be unchanged).
  **/
 gboolean
-nm_connection_replace_settings (NMConnection *connection,
-                                GVariant *new_settings,
-                                GError **error)
+nm_connection_replace_settings(NMConnection *connection, GVariant *new_settings, GError **error)
 {
-	return _nm_connection_replace_settings (connection, new_settings, NM_SETTING_PARSE_FLAGS_NONE, error);
+    return _nm_connection_replace_settings(connection,
+                                           new_settings,
+                                           NM_SETTING_PARSE_FLAGS_NONE,
+                                           error);
 }
 
 /**
@@ -471,42 +469,42 @@ nm_connection_replace_settings (NMConnection *connection,
  * with the copied settings.
  **/
 void
-nm_connection_replace_settings_from_connection (NMConnection *connection,
-                                                NMConnection *new_connection)
+nm_connection_replace_settings_from_connection(NMConnection *connection,
+                                               NMConnection *new_connection)
 {
-	NMConnectionPrivate *priv, *new_priv;
-	GHashTableIter iter;
-	NMSetting *setting;
-	gboolean changed;
+    NMConnectionPrivate *priv, *new_priv;
+    GHashTableIter       iter;
+    NMSetting *          setting;
+    gboolean             changed;
 
-	g_return_if_fail (NM_IS_CONNECTION (connection));
-	g_return_if_fail (NM_IS_CONNECTION (new_connection));
+    g_return_if_fail(NM_IS_CONNECTION(connection));
+    g_return_if_fail(NM_IS_CONNECTION(new_connection));
 
-	/* When 'connection' and 'new_connection' are the same object simply return
-	 * in order not to destroy 'connection'.
-	 */
-	if (connection == new_connection)
-		return;
+    /* When 'connection' and 'new_connection' are the same object simply return
+     * in order not to destroy 'connection'.
+     */
+    if (connection == new_connection)
+        return;
 
-	/* No need to validate permissions like nm_connection_replace_settings()
-	 * since we're dealing with an NMConnection which has already done that.
-	 */
+    /* No need to validate permissions like nm_connection_replace_settings()
+     * since we're dealing with an NMConnection which has already done that.
+     */
 
-	priv = NM_CONNECTION_GET_PRIVATE (connection);
-	new_priv = NM_CONNECTION_GET_PRIVATE (new_connection);
+    priv     = NM_CONNECTION_GET_PRIVATE(connection);
+    new_priv = NM_CONNECTION_GET_PRIVATE(new_connection);
 
-	if ((changed = g_hash_table_size (priv->settings) > 0))
-		g_hash_table_foreach_remove (priv->settings, _setting_release_hfr, connection);
+    if ((changed = g_hash_table_size(priv->settings) > 0))
+        g_hash_table_foreach_remove(priv->settings, _setting_release_hfr, connection);
 
-	if (g_hash_table_size (new_priv->settings)) {
-		g_hash_table_iter_init (&iter, new_priv->settings);
-		while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting))
-			_nm_connection_add_setting (connection, nm_setting_duplicate (setting));
-		changed = TRUE;
-	}
+    if (g_hash_table_size(new_priv->settings)) {
+        g_hash_table_iter_init(&iter, new_priv->settings);
+        while (g_hash_table_iter_next(&iter, NULL, (gpointer) &setting))
+            _nm_connection_add_setting(connection, nm_setting_duplicate(setting));
+        changed = TRUE;
+    }
 
-	if (changed)
-		g_signal_emit (connection, signals[CHANGED], 0);
+    if (changed)
+        g_signal_emit(connection, signals[CHANGED], 0);
 }
 
 /**
@@ -516,18 +514,18 @@ nm_connection_replace_settings_from_connection (NMConnection *connection,
  * Deletes all of @connection's settings.
  **/
 void
-nm_connection_clear_settings (NMConnection *connection)
+nm_connection_clear_settings(NMConnection *connection)
 {
-	NMConnectionPrivate *priv;
+    NMConnectionPrivate *priv;
 
-	g_return_if_fail (NM_IS_CONNECTION (connection));
+    g_return_if_fail(NM_IS_CONNECTION(connection));
 
-	priv = NM_CONNECTION_GET_PRIVATE (connection);
+    priv = NM_CONNECTION_GET_PRIVATE(connection);
 
-	if (g_hash_table_size (priv->settings) > 0) {
-		g_hash_table_foreach_remove (priv->settings, _setting_release_hfr, connection);
-		g_signal_emit (connection, signals[CHANGED], 0);
-	}
+    if (g_hash_table_size(priv->settings) > 0) {
+        g_hash_table_foreach_remove(priv->settings, _setting_release_hfr, connection);
+        g_signal_emit(connection, signals[CHANGED], 0);
+    }
 }
 
 /**
@@ -543,70 +541,67 @@ nm_connection_clear_settings (NMConnection *connection)
  * Returns: %TRUE if the comparison succeeds, %FALSE if it does not
  **/
 gboolean
-nm_connection_compare (NMConnection *a,
-                       NMConnection *b,
-                       NMSettingCompareFlags flags)
+nm_connection_compare(NMConnection *a, NMConnection *b, NMSettingCompareFlags flags)
 {
-	GHashTableIter iter;
-	NMSetting *src;
+    GHashTableIter iter;
+    NMSetting *    src;
 
-	if (a == b)
-		return TRUE;
-	if (!a || !b)
-		return FALSE;
+    if (a == b)
+        return TRUE;
+    if (!a || !b)
+        return FALSE;
 
-	/* B / A: ensure settings in B that are not in A make the comparison fail */
-	if (g_hash_table_size (NM_CONNECTION_GET_PRIVATE (a)->settings) !=
-	    g_hash_table_size (NM_CONNECTION_GET_PRIVATE (b)->settings))
-		return FALSE;
+    /* B / A: ensure settings in B that are not in A make the comparison fail */
+    if (g_hash_table_size(NM_CONNECTION_GET_PRIVATE(a)->settings)
+        != g_hash_table_size(NM_CONNECTION_GET_PRIVATE(b)->settings))
+        return FALSE;
 
-	/* A / B: ensure all settings in A match corresponding ones in B */
-	g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (a)->settings);
-	while (g_hash_table_iter_next (&iter, NULL, (gpointer) &src)) {
-		NMSetting *cmp = nm_connection_get_setting (b, G_OBJECT_TYPE (src));
+    /* A / B: ensure all settings in A match corresponding ones in B */
+    g_hash_table_iter_init(&iter, NM_CONNECTION_GET_PRIVATE(a)->settings);
+    while (g_hash_table_iter_next(&iter, NULL, (gpointer) &src)) {
+        NMSetting *cmp = nm_connection_get_setting(b, G_OBJECT_TYPE(src));
 
-		if (   !cmp
-		    || !_nm_setting_compare (a, src, b, cmp, flags))
-			return FALSE;
-	}
+        if (!cmp || !_nm_setting_compare(a, src, b, cmp, flags))
+            return FALSE;
+    }
 
-	return TRUE;
+    return TRUE;
 }
 
 static gboolean
-diff_one_connection (NMConnection *a,
-                     NMConnection *b,
-                     NMSettingCompareFlags flags,
-                     gboolean invert_results,
-                     GHashTable *diffs)
+diff_one_connection(NMConnection *        a,
+                    NMConnection *        b,
+                    NMSettingCompareFlags flags,
+                    gboolean              invert_results,
+                    GHashTable *          diffs)
 {
-	NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (a);
-	GHashTableIter iter;
-	NMSetting *a_setting = NULL;
-	gboolean diff_found = FALSE;
+    NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE(a);
+    GHashTableIter       iter;
+    NMSetting *          a_setting  = NULL;
+    gboolean             diff_found = FALSE;
 
-	g_hash_table_iter_init (&iter, priv->settings);
-	while (g_hash_table_iter_next (&iter, NULL, (gpointer) &a_setting)) {
-		NMSetting *b_setting = NULL;
-		const char *setting_name = nm_setting_get_name (a_setting);
-		GHashTable *results;
-		gboolean new_results = TRUE;
+    g_hash_table_iter_init(&iter, priv->settings);
+    while (g_hash_table_iter_next(&iter, NULL, (gpointer) &a_setting)) {
+        NMSetting * b_setting    = NULL;
+        const char *setting_name = nm_setting_get_name(a_setting);
+        GHashTable *results;
+        gboolean    new_results = TRUE;
 
-		if (b)
-			b_setting = nm_connection_get_setting (b, G_OBJECT_TYPE (a_setting));
+        if (b)
+            b_setting = nm_connection_get_setting(b, G_OBJECT_TYPE(a_setting));
 
-		results = g_hash_table_lookup (diffs, setting_name);
-		if (results)
-			new_results = FALSE;
+        results = g_hash_table_lookup(diffs, setting_name);
+        if (results)
+            new_results = FALSE;
 
-		if (!_nm_setting_diff (a, a_setting, b, b_setting, flags, invert_results, &results))
-			diff_found = TRUE;
+        if (!_nm_setting_diff(a, a_setting, b, b_setting, flags, invert_results, &results))
+            diff_found = TRUE;
 
-		if (new_results && results)
-			g_hash_table_insert (diffs, g_strdup (setting_name), results);
-	}
+        if (new_results && results)
+            g_hash_table_insert(diffs, g_strdup(setting_name), results);
+    }
 
-	return diff_found;
+    return diff_found;
 }
 
 /**
@@ -629,244 +624,241 @@ diff_one_connection (NMConnection *a,
  * not
  **/
 gboolean
-nm_connection_diff (NMConnection *a,
-                    NMConnection *b,
-                    NMSettingCompareFlags flags,
-                    GHashTable **out_settings)
+nm_connection_diff(NMConnection *        a,
+                   NMConnection *        b,
+                   NMSettingCompareFlags flags,
+                   GHashTable **         out_settings)
 {
-	GHashTable *diffs;
-	gboolean diff_found = FALSE;
+    GHashTable *diffs;
+    gboolean    diff_found = FALSE;
 
-	g_return_val_if_fail (NM_IS_CONNECTION (a), FALSE);
-	g_return_val_if_fail (!out_settings || !*out_settings, FALSE);
-	g_return_val_if_fail (!b || NM_IS_CONNECTION (b), FALSE);
+    g_return_val_if_fail(NM_IS_CONNECTION(a), FALSE);
+    g_return_val_if_fail(!out_settings || !*out_settings, FALSE);
+    g_return_val_if_fail(!b || NM_IS_CONNECTION(b), FALSE);
 
-	if (a == b)
-		return TRUE;
+    if (a == b)
+        return TRUE;
 
-	diffs = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
+    diffs = g_hash_table_new_full(nm_str_hash,
+                                  g_str_equal,
+                                  g_free,
+                                  (GDestroyNotify) g_hash_table_destroy);
 
-	/* Diff A to B, then B to A to capture keys in B that aren't in A */
-	if (diff_one_connection (a, b, flags, FALSE, diffs))
-		diff_found = TRUE;
-	if (   b
-	    && diff_one_connection (b, a, flags, TRUE, diffs))
-		diff_found = TRUE;
+    /* Diff A to B, then B to A to capture keys in B that aren't in A */
+    if (diff_one_connection(a, b, flags, FALSE, diffs))
+        diff_found = TRUE;
+    if (b && diff_one_connection(b, a, flags, TRUE, diffs))
+        diff_found = TRUE;
 
-	nm_assert (diff_found == (g_hash_table_size (diffs) != 0));
+    nm_assert(diff_found == (g_hash_table_size(diffs) != 0));
 
-	if (g_hash_table_size (diffs) == 0) {
-		g_hash_table_destroy (diffs);
-		diffs = NULL;
-	}
+    if (g_hash_table_size(diffs) == 0) {
+        g_hash_table_destroy(diffs);
+        diffs = NULL;
+    }
 
-	NM_SET_OUT (out_settings, diffs);
+    NM_SET_OUT(out_settings, diffs);
 
-	return !diff_found;
+    return !diff_found;
 }
 
 NMSetting *
-_nm_connection_find_base_type_setting (NMConnection *connection)
-{
-	NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
-	GHashTableIter iter;
-	NMSetting *setting = NULL;
-	NMSetting *s_iter;
-	NMSettingPriority setting_prio = NM_SETTING_PRIORITY_USER;
-	NMSettingPriority s_iter_prio;
-
-	g_hash_table_iter_init (&iter, priv->settings);
-	while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &s_iter)) {
-		s_iter_prio = _nm_setting_get_base_type_priority (s_iter);
-		if (s_iter_prio == NM_SETTING_PRIORITY_INVALID)
-			continue;
-
-		if (setting) {
-			if (s_iter_prio > setting_prio) {
-				continue;
-			} else if (s_iter_prio == setting_prio) {
-				NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
-				const char *type;
-
-				if (s_con) {
-					type = nm_setting_connection_get_connection_type (s_con);
-					if (type)
-						return nm_connection_get_setting_by_name (connection, type);
-				}
-				return NULL;
-			}
-		}
-		setting = s_iter;
-		setting_prio = s_iter_prio;
-	}
-	return setting;
+_nm_connection_find_base_type_setting(NMConnection *connection)
+{
+    NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE(connection);
+    GHashTableIter       iter;
+    NMSetting *          setting = NULL;
+    NMSetting *          s_iter;
+    NMSettingPriority    setting_prio = NM_SETTING_PRIORITY_USER;
+    NMSettingPriority    s_iter_prio;
+
+    g_hash_table_iter_init(&iter, priv->settings);
+    while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &s_iter)) {
+        s_iter_prio = _nm_setting_get_base_type_priority(s_iter);
+        if (s_iter_prio == NM_SETTING_PRIORITY_INVALID)
+            continue;
+
+        if (setting) {
+            if (s_iter_prio > setting_prio) {
+                continue;
+            } else if (s_iter_prio == setting_prio) {
+                NMSettingConnection *s_con = nm_connection_get_setting_connection(connection);
+                const char *         type;
+
+                if (s_con) {
+                    type = nm_setting_connection_get_connection_type(s_con);
+                    if (type)
+                        return nm_connection_get_setting_by_name(connection, type);
+                }
+                return NULL;
+            }
+        }
+        setting      = s_iter;
+        setting_prio = s_iter_prio;
+    }
+    return setting;
 }
 
 static gboolean
-_normalize_connection_uuid (NMConnection *self)
+_normalize_connection_uuid(NMConnection *self)
 {
-	NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
-	char uuid[37];
+    NMSettingConnection *s_con = nm_connection_get_setting_connection(self);
+    char                 uuid[37];
 
-	nm_assert (s_con);
+    nm_assert(s_con);
 
-	if (nm_setting_connection_get_uuid (s_con))
-		return FALSE;
+    if (nm_setting_connection_get_uuid(s_con))
+        return FALSE;
 
-	g_object_set (s_con,
-	              NM_SETTING_CONNECTION_UUID,
-	              nm_utils_uuid_generate_buf (uuid),
-	              NULL);
-	return TRUE;
+    g_object_set(s_con, NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_buf(uuid), NULL);
+    return TRUE;
 }
 
 static gboolean
-_normalize_connection_type (NMConnection *self)
+_normalize_connection_type(NMConnection *self)
 {
-	NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
-	NMSetting *s_base = NULL;
-	const char *type;
+    NMSettingConnection *s_con  = nm_connection_get_setting_connection(self);
+    NMSetting *          s_base = NULL;
+    const char *         type;
 
-	type = nm_setting_connection_get_connection_type (s_con);
+    type = nm_setting_connection_get_connection_type(s_con);
 
-	if (type) {
-		s_base = nm_connection_get_setting_by_name (self, type);
+    if (type) {
+        s_base = nm_connection_get_setting_by_name(self, type);
 
-		if (!s_base) {
-			GType base_type = nm_setting_lookup_type (type);
+        if (!s_base) {
+            GType base_type = nm_setting_lookup_type(type);
 
-			g_return_val_if_fail (base_type, FALSE);
-			nm_connection_add_setting (self, g_object_new (base_type, NULL));
-			return TRUE;
-		}
-	} else {
-		s_base =  _nm_connection_find_base_type_setting (self);
-		g_return_val_if_fail (s_base, FALSE);
+            g_return_val_if_fail(base_type, FALSE);
+            nm_connection_add_setting(self, g_object_new(base_type, NULL));
+            return TRUE;
+        }
+    } else {
+        s_base = _nm_connection_find_base_type_setting(self);
+        g_return_val_if_fail(s_base, FALSE);
 
-		type = nm_setting_get_name (s_base);
-		g_object_set (s_con, NM_SETTING_CONNECTION_TYPE, type, NULL);
-		return TRUE;
-	}
+        type = nm_setting_get_name(s_base);
+        g_object_set(s_con, NM_SETTING_CONNECTION_TYPE, type, NULL);
+        return TRUE;
+    }
 
-	return FALSE;
+    return FALSE;
 }
 
 const char *
-_nm_connection_detect_bluetooth_type (NMConnection *self)
+_nm_connection_detect_bluetooth_type(NMConnection *self)
 {
-	NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth (self);
+    NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth(self);
 
-	if (   s_bt
-	    && nm_setting_bluetooth_get_connection_type (s_bt)) {
-		if (   nm_connection_get_setting_gsm (self)
-		    || nm_connection_get_setting_cdma (self))
-			return NM_SETTING_BLUETOOTH_TYPE_DUN;
-		if (nm_connection_get_setting_bridge (self))
-			return NM_SETTING_BLUETOOTH_TYPE_NAP;
-		return NM_SETTING_BLUETOOTH_TYPE_PANU;
-	}
+    if (s_bt && nm_setting_bluetooth_get_connection_type(s_bt)) {
+        if (nm_connection_get_setting_gsm(self) || nm_connection_get_setting_cdma(self))
+            return NM_SETTING_BLUETOOTH_TYPE_DUN;
+        if (nm_connection_get_setting_bridge(self))
+            return NM_SETTING_BLUETOOTH_TYPE_NAP;
+        return NM_SETTING_BLUETOOTH_TYPE_PANU;
+    }
 
-	/* NULL means the connection is not a bluetooth type, or it needs
-	 * no normalization, as the type is set explicitly. */
-	return NULL;
+    /* NULL means the connection is not a bluetooth type, or it needs
+     * no normalization, as the type is set explicitly. */
+    return NULL;
 }
 
 const char *
-_nm_connection_detect_slave_type (NMConnection *connection, NMSetting **out_s_port)
-{
-	NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
-	GHashTableIter iter;
-	const char *slave_type = NULL;
-	NMSetting *s_port = NULL, *s_iter;
-
-	g_hash_table_iter_init (&iter, priv->settings);
-	while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &s_iter)) {
-		const char *name = nm_setting_get_name (s_iter);
-		const char *i_slave_type = NULL;
-
-		if (!strcmp (name, NM_SETTING_BRIDGE_PORT_SETTING_NAME))
-			i_slave_type = NM_SETTING_BRIDGE_SETTING_NAME;
-		else if (!strcmp (name, NM_SETTING_TEAM_PORT_SETTING_NAME))
-			i_slave_type = NM_SETTING_TEAM_SETTING_NAME;
-		else if (!strcmp (name, NM_SETTING_OVS_PORT_SETTING_NAME))
-			i_slave_type = NM_SETTING_OVS_BRIDGE_SETTING_NAME;
-		else if (!strcmp (name, NM_SETTING_OVS_INTERFACE_SETTING_NAME))
-			i_slave_type = NM_SETTING_OVS_PORT_SETTING_NAME;
-		else
-			continue;
-
-		if (slave_type) {
-			/* there are more then one matching port types, cannot detect the slave type. */
-			slave_type = NULL;
-			s_port = NULL;
-			break;
-		}
-		slave_type = i_slave_type;
-		s_port = s_iter;
-	}
-
-	if (out_s_port)
-		*out_s_port = s_port;
-	return slave_type;
+_nm_connection_detect_slave_type(NMConnection *connection, NMSetting **out_s_port)
+{
+    NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE(connection);
+    GHashTableIter       iter;
+    const char *         slave_type = NULL;
+    NMSetting *          s_port     = NULL, *s_iter;
+
+    g_hash_table_iter_init(&iter, priv->settings);
+    while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &s_iter)) {
+        const char *name         = nm_setting_get_name(s_iter);
+        const char *i_slave_type = NULL;
+
+        if (!strcmp(name, NM_SETTING_BRIDGE_PORT_SETTING_NAME))
+            i_slave_type = NM_SETTING_BRIDGE_SETTING_NAME;
+        else if (!strcmp(name, NM_SETTING_TEAM_PORT_SETTING_NAME))
+            i_slave_type = NM_SETTING_TEAM_SETTING_NAME;
+        else if (!strcmp(name, NM_SETTING_OVS_PORT_SETTING_NAME))
+            i_slave_type = NM_SETTING_OVS_BRIDGE_SETTING_NAME;
+        else if (!strcmp(name, NM_SETTING_OVS_INTERFACE_SETTING_NAME))
+            i_slave_type = NM_SETTING_OVS_PORT_SETTING_NAME;
+        else
+            continue;
+
+        if (slave_type) {
+            /* there are more then one matching port types, cannot detect the slave type. */
+            slave_type = NULL;
+            s_port     = NULL;
+            break;
+        }
+        slave_type = i_slave_type;
+        s_port     = s_iter;
+    }
+
+    if (out_s_port)
+        *out_s_port = s_port;
+    return slave_type;
 }
 
 static gboolean
-_normalize_connection_slave_type (NMConnection *self)
-{
-	NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
-	const char *slave_type, *port_type;
-
-	if (!s_con)
-		return FALSE;
-	if (!nm_setting_connection_get_master (s_con))
-		return FALSE;
-
-	slave_type = nm_setting_connection_get_slave_type (s_con);
-	if (slave_type) {
-		if (   _nm_setting_slave_type_is_valid (slave_type, &port_type)
-		    && port_type) {
-			NMSetting *s_port;
-
-			s_port = nm_connection_get_setting_by_name (self, port_type);
-			if (!s_port) {
-				GType p_type = nm_setting_lookup_type (port_type);
-
-				g_return_val_if_fail (p_type, FALSE);
-				nm_connection_add_setting (self, g_object_new (p_type, NULL));
-				return TRUE;
-			}
-		}
-	} else {
-		if ((slave_type = _nm_connection_detect_slave_type (self, NULL))) {
-			g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, slave_type, NULL);
-			return TRUE;
-		}
-	}
-	return FALSE;
+_normalize_connection_slave_type(NMConnection *self)
+{
+    NMSettingConnection *s_con = nm_connection_get_setting_connection(self);
+    const char *         slave_type, *port_type;
+
+    if (!s_con)
+        return FALSE;
+    if (!nm_setting_connection_get_master(s_con))
+        return FALSE;
+
+    slave_type = nm_setting_connection_get_slave_type(s_con);
+    if (slave_type) {
+        if (_nm_setting_slave_type_is_valid(slave_type, &port_type) && port_type) {
+            NMSetting *s_port;
+
+            s_port = nm_connection_get_setting_by_name(self, port_type);
+            if (!s_port) {
+                GType p_type = nm_setting_lookup_type(port_type);
+
+                g_return_val_if_fail(p_type, FALSE);
+                nm_connection_add_setting(self, g_object_new(p_type, NULL));
+                return TRUE;
+            }
+        }
+    } else {
+        if ((slave_type = _nm_connection_detect_slave_type(self, NULL))) {
+            g_object_set(s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, slave_type, NULL);
+            return TRUE;
+        }
+    }
+    return FALSE;
 }
 
 static gboolean
-_normalize_ethernet_link_neg (NMConnection *self)
+_normalize_ethernet_link_neg(NMConnection *self)
 {
-	NMSettingWired *s_wired = nm_connection_get_setting_wired (self);
+    NMSettingWired *s_wired = nm_connection_get_setting_wired(self);
 
-	if (s_wired) {
-		guint32 speed = nm_setting_wired_get_speed (s_wired);
-		const char *duplex = nm_setting_wired_get_duplex (s_wired);
+    if (s_wired) {
+        guint32     speed  = nm_setting_wired_get_speed(s_wired);
+        const char *duplex = nm_setting_wired_get_duplex(s_wired);
 
-		if (   (speed && !duplex)
-		    || (!speed && duplex)) {
-			speed = 0;
-			duplex = NULL;
-			g_object_set (s_wired,
-			              NM_SETTING_WIRED_SPEED, (guint) speed,
-			              NM_SETTING_WIRED_DUPLEX, duplex,
-			              NULL);
-			return TRUE;
-		}
-	}
+        if ((speed && !duplex) || (!speed && duplex)) {
+            speed  = 0;
+            duplex = NULL;
+            g_object_set(s_wired,
+                         NM_SETTING_WIRED_SPEED,
+                         (guint) speed,
+                         NM_SETTING_WIRED_DUPLEX,
+                         duplex,
+                         NULL);
+            return TRUE;
+        }
+    }
 
-	return FALSE;
+    return FALSE;
 }
 
 /**
@@ -884,491 +876,497 @@ _normalize_ethernet_link_neg (NMConnection *self)
  * Returns: %TRUE if the AF is supported, %FALSE otherwise
  **/
 static gboolean
-_supports_addr_family (NMConnection *self, int family)
+_supports_addr_family(NMConnection *self, int family)
 {
-	const char *connection_type = nm_connection_get_connection_type (self);
-	NMSettingConnection *s_con;
+    const char *         connection_type = nm_connection_get_connection_type(self);
+    NMSettingConnection *s_con;
 
-	g_return_val_if_fail (connection_type, TRUE);
-	if (strcmp (connection_type, NM_SETTING_OVS_INTERFACE_SETTING_NAME) == 0)
-		return TRUE;
-	if (strcmp (connection_type, NM_SETTING_WPAN_SETTING_NAME) == 0)
-		return FALSE;
-	if (strcmp (connection_type, NM_SETTING_6LOWPAN_SETTING_NAME) == 0)
-		return family == AF_INET6 || family == AF_UNSPEC;
-	if (   (s_con = nm_connection_get_setting_connection (self))
-	    && (nm_streq0 (nm_setting_connection_get_slave_type (s_con), NM_SETTING_VRF_SETTING_NAME)))
-		return TRUE;
+    g_return_val_if_fail(connection_type, TRUE);
+    if (strcmp(connection_type, NM_SETTING_OVS_INTERFACE_SETTING_NAME) == 0)
+        return TRUE;
+    if (strcmp(connection_type, NM_SETTING_WPAN_SETTING_NAME) == 0)
+        return FALSE;
+    if (strcmp(connection_type, NM_SETTING_6LOWPAN_SETTING_NAME) == 0)
+        return family == AF_INET6 || family == AF_UNSPEC;
+    if ((s_con = nm_connection_get_setting_connection(self))
+        && (nm_streq0(nm_setting_connection_get_slave_type(s_con), NM_SETTING_VRF_SETTING_NAME)))
+        return TRUE;
 
-	return !nm_setting_connection_get_master (nm_connection_get_setting_connection (self));
+    return !nm_setting_connection_get_master(nm_connection_get_setting_connection(self));
 }
 
 static gboolean
-_normalize_ip_config (NMConnection *self, GHashTable *parameters)
-{
-	NMSettingIPConfig *s_ip4, *s_ip6;
-	NMSettingProxy *s_proxy;
-	NMSetting *setting;
-	gboolean changed = FALSE;
-	guint num, i;
-
-	s_ip4 = nm_connection_get_setting_ip4_config (self);
-	s_ip6 = nm_connection_get_setting_ip6_config (self);
-	s_proxy = nm_connection_get_setting_proxy (self);
-
-	if (_supports_addr_family (self, AF_INET)) {
-
-		if (!s_ip4) {
-			const char *default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
-
-			if (nm_connection_is_type (self, NM_SETTING_WIREGUARD_SETTING_NAME))
-				default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
-
-			 /* But if no IP4 setting was specified, assume the caller was just
-			  * being lazy and use the default method.
-			  */
-			setting = nm_setting_ip4_config_new ();
-
-			g_object_set (setting,
-			              NM_SETTING_IP_CONFIG_METHOD, default_ip4_method,
-			              NULL);
-			nm_connection_add_setting (self, setting);
-			changed = TRUE;
-		} else {
-			if (   nm_setting_ip_config_get_gateway (s_ip4)
-			    && nm_setting_ip_config_get_never_default (s_ip4)) {
-				g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, NULL, NULL);
-				changed = TRUE;
-			}
-
-			if (   nm_streq0 (nm_setting_ip_config_get_method (s_ip4),
-			                  NM_SETTING_IP4_CONFIG_METHOD_DISABLED)
-			    && !nm_setting_ip_config_get_may_fail (s_ip4)) {
-				g_object_set (s_ip4, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL);
-				changed = TRUE;
-			}
-
-			num = nm_setting_ip_config_get_num_addresses (s_ip4);
-			if (   num > 1
-			    && nm_streq0 (nm_setting_ip_config_get_method (s_ip4),
-			                  NM_SETTING_IP4_CONFIG_METHOD_SHARED)) {
-				for (i = num - 1; i > 0; i--)
-					nm_setting_ip_config_remove_address (s_ip4, i);
-				changed = TRUE;
-			}
-		}
-	} else {
-		if (s_ip4) {
-			nm_connection_remove_setting (self, NM_TYPE_SETTING_IP4_CONFIG);
-			changed = TRUE;
-		}
-	}
-
-	if (_supports_addr_family (self, AF_INET6)) {
-		if (!s_ip6) {
-			const char *default_ip6_method = NULL;
-
-			if (parameters)
-				default_ip6_method = g_hash_table_lookup (parameters, NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD);
-			if (!default_ip6_method) {
-				if (nm_connection_is_type (self, NM_SETTING_WIREGUARD_SETTING_NAME))
-					default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
-				else
-					default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
-			}
-
-			/* If no IP6 setting was specified, then assume that means IP6 config is
-			 * allowed to fail.
-			 */
-			setting = nm_setting_ip6_config_new ();
-
-			g_object_set (setting,
-			              NM_SETTING_IP_CONFIG_METHOD, default_ip6_method,
-			              NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
-			              NULL);
-			nm_connection_add_setting (self, setting);
-			changed = TRUE;
-		} else {
-			const char *token;
-
-			token = nm_setting_ip6_config_get_token ((NMSettingIP6Config *) s_ip6);
-			if (   token
-			    && nm_setting_ip6_config_get_addr_gen_mode ((NMSettingIP6Config *) s_ip6) == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64) {
-				struct in6_addr i6_token;
-				char normalized[NM_UTILS_INET_ADDRSTRLEN];
-
-				if (   inet_pton (AF_INET6, token, &i6_token) == 1
-				    && _nm_utils_inet6_is_token (&i6_token)) {
-					_nm_utils_inet6_ntop (&i6_token, normalized);
-					if (g_strcmp0 (token, normalized)) {
-						g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_TOKEN, normalized, NULL);
-						changed = TRUE;
-					}
-				}
-			}
-
-			if (   nm_setting_ip_config_get_gateway (s_ip6)
-			    && nm_setting_ip_config_get_never_default (s_ip6)) {
-				g_object_set (s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, NULL, NULL);
-				changed = TRUE;
-			}
-
-			if (   NM_IN_STRSET (nm_setting_ip_config_get_method (s_ip6),
-			                     NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
-			                     NM_SETTING_IP6_CONFIG_METHOD_DISABLED)
-			    && !nm_setting_ip_config_get_may_fail (s_ip6)) {
-				g_object_set (s_ip6, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL);
-				changed = TRUE;
-			}
-		}
-	} else {
-		if (s_ip6) {
-			nm_connection_remove_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
-			changed = TRUE;
-		}
-	}
-
-	if (_supports_addr_family (self, AF_UNSPEC)) {
-		if (!s_proxy) {
-			setting = nm_setting_proxy_new ();
-			nm_connection_add_setting (self, setting);
-			changed = TRUE;
-		}
-	} else {
-		if (s_proxy) {
-			nm_connection_remove_setting (self, NM_TYPE_SETTING_PROXY);
-			changed = TRUE;
-		}
-	}
-
-	return changed;
+_normalize_ip_config(NMConnection *self, GHashTable *parameters)
+{
+    NMSettingIPConfig *s_ip4, *s_ip6;
+    NMSettingProxy *   s_proxy;
+    NMSetting *        setting;
+    gboolean           changed = FALSE;
+    guint              num, i;
+
+    s_ip4   = nm_connection_get_setting_ip4_config(self);
+    s_ip6   = nm_connection_get_setting_ip6_config(self);
+    s_proxy = nm_connection_get_setting_proxy(self);
+
+    if (_supports_addr_family(self, AF_INET)) {
+        if (!s_ip4) {
+            const char *default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
+
+            if (nm_connection_is_type(self, NM_SETTING_WIREGUARD_SETTING_NAME))
+                default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
+
+            /* But if no IP4 setting was specified, assume the caller was just
+             * being lazy and use the default method.
+             */
+            setting = nm_setting_ip4_config_new();
+
+            g_object_set(setting, NM_SETTING_IP_CONFIG_METHOD, default_ip4_method, NULL);
+            nm_connection_add_setting(self, setting);
+            changed = TRUE;
+        } else {
+            if (nm_setting_ip_config_get_gateway(s_ip4)
+                && nm_setting_ip_config_get_never_default(s_ip4)) {
+                g_object_set(s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, NULL, NULL);
+                changed = TRUE;
+            }
+
+            if (nm_streq0(nm_setting_ip_config_get_method(s_ip4),
+                          NM_SETTING_IP4_CONFIG_METHOD_DISABLED)
+                && !nm_setting_ip_config_get_may_fail(s_ip4)) {
+                g_object_set(s_ip4, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL);
+                changed = TRUE;
+            }
+
+            num = nm_setting_ip_config_get_num_addresses(s_ip4);
+            if (num > 1
+                && nm_streq0(nm_setting_ip_config_get_method(s_ip4),
+                             NM_SETTING_IP4_CONFIG_METHOD_SHARED)) {
+                for (i = num - 1; i > 0; i--)
+                    nm_setting_ip_config_remove_address(s_ip4, i);
+                changed = TRUE;
+            }
+        }
+    } else {
+        if (s_ip4) {
+            nm_connection_remove_setting(self, NM_TYPE_SETTING_IP4_CONFIG);
+            changed = TRUE;
+        }
+    }
+
+    if (_supports_addr_family(self, AF_INET6)) {
+        if (!s_ip6) {
+            const char *default_ip6_method = NULL;
+
+            if (parameters)
+                default_ip6_method =
+                    g_hash_table_lookup(parameters,
+                                        NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD);
+            if (!default_ip6_method) {
+                if (nm_connection_is_type(self, NM_SETTING_WIREGUARD_SETTING_NAME))
+                    default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
+                else
+                    default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
+            }
+
+            /* If no IP6 setting was specified, then assume that means IP6 config is
+             * allowed to fail.
+             */
+            setting = nm_setting_ip6_config_new();
+
+            g_object_set(setting,
+                         NM_SETTING_IP_CONFIG_METHOD,
+                         default_ip6_method,
+                         NM_SETTING_IP_CONFIG_MAY_FAIL,
+                         TRUE,
+                         NULL);
+            nm_connection_add_setting(self, setting);
+            changed = TRUE;
+        } else {
+            const char *token;
+
+            token = nm_setting_ip6_config_get_token((NMSettingIP6Config *) s_ip6);
+            if (token
+                && nm_setting_ip6_config_get_addr_gen_mode((NMSettingIP6Config *) s_ip6)
+                       == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64) {
+                struct in6_addr i6_token;
+                char            normalized[NM_UTILS_INET_ADDRSTRLEN];
+
+                if (inet_pton(AF_INET6, token, &i6_token) == 1
+                    && _nm_utils_inet6_is_token(&i6_token)) {
+                    _nm_utils_inet6_ntop(&i6_token, normalized);
+                    if (g_strcmp0(token, normalized)) {
+                        g_object_set(s_ip6, NM_SETTING_IP6_CONFIG_TOKEN, normalized, NULL);
+                        changed = TRUE;
+                    }
+                }
+            }
+
+            if (nm_setting_ip_config_get_gateway(s_ip6)
+                && nm_setting_ip_config_get_never_default(s_ip6)) {
+                g_object_set(s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, NULL, NULL);
+                changed = TRUE;
+            }
+
+            if (NM_IN_STRSET(nm_setting_ip_config_get_method(s_ip6),
+                             NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+                             NM_SETTING_IP6_CONFIG_METHOD_DISABLED)
+                && !nm_setting_ip_config_get_may_fail(s_ip6)) {
+                g_object_set(s_ip6, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL);
+                changed = TRUE;
+            }
+        }
+    } else {
+        if (s_ip6) {
+            nm_connection_remove_setting(self, NM_TYPE_SETTING_IP6_CONFIG);
+            changed = TRUE;
+        }
+    }
+
+    if (_supports_addr_family(self, AF_UNSPEC)) {
+        if (!s_proxy) {
+            setting = nm_setting_proxy_new();
+            nm_connection_add_setting(self, setting);
+            changed = TRUE;
+        }
+    } else {
+        if (s_proxy) {
+            nm_connection_remove_setting(self, NM_TYPE_SETTING_PROXY);
+            changed = TRUE;
+        }
+    }
+
+    return changed;
 }
 
 static gboolean
-_normalize_infiniband_mtu (NMConnection *self)
+_normalize_infiniband_mtu(NMConnection *self)
 {
-	NMSettingInfiniband *s_infini = nm_connection_get_setting_infiniband (self);
+    NMSettingInfiniband *s_infini = nm_connection_get_setting_infiniband(self);
 
-	if (   !s_infini
-	    || nm_setting_infiniband_get_mtu (s_infini) <= NM_INFINIBAND_MAX_MTU
-	    || !NM_IN_STRSET (nm_setting_infiniband_get_transport_mode (s_infini), "datagram",
-	                                                                           "connected"))
-		return FALSE;
+    if (!s_infini || nm_setting_infiniband_get_mtu(s_infini) <= NM_INFINIBAND_MAX_MTU
+        || !NM_IN_STRSET(nm_setting_infiniband_get_transport_mode(s_infini),
+                         "datagram",
+                         "connected"))
+        return FALSE;
 
-	g_object_set (s_infini, NM_SETTING_INFINIBAND_MTU, (guint) NM_INFINIBAND_MAX_MTU, NULL);
-	return TRUE;
+    g_object_set(s_infini, NM_SETTING_INFINIBAND_MTU, (guint) NM_INFINIBAND_MAX_MTU, NULL);
+    return TRUE;
 }
 
 static gboolean
-_normalize_bond_mode (NMConnection *self)
+_normalize_bond_mode(NMConnection *self)
 {
-	NMSettingBond *s_bond = nm_connection_get_setting_bond (self);
+    NMSettingBond *s_bond = nm_connection_get_setting_bond(self);
 
-	/* Convert mode from numeric to string notation */
-	if (s_bond) {
-		const char *mode = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MODE);
-		int mode_int = nm_utils_bond_mode_string_to_int (mode);
+    /* Convert mode from numeric to string notation */
+    if (s_bond) {
+        const char *mode = nm_setting_bond_get_option_by_name(s_bond, NM_SETTING_BOND_OPTION_MODE);
+        int         mode_int = nm_utils_bond_mode_string_to_int(mode);
 
-		if (mode_int != -1) {
-			const char *mode_new = nm_utils_bond_mode_int_to_string (mode_int);
-			if (g_strcmp0 (mode_new, mode) != 0) {
-				nm_setting_bond_add_option (s_bond, NM_SETTING_BOND_OPTION_MODE, mode_new);
-				return TRUE;
-			}
-		}
-	}
-	return FALSE;
+        if (mode_int != -1) {
+            const char *mode_new = nm_utils_bond_mode_int_to_string(mode_int);
+            if (g_strcmp0(mode_new, mode) != 0) {
+                nm_setting_bond_add_option(s_bond, NM_SETTING_BOND_OPTION_MODE, mode_new);
+                return TRUE;
+            }
+        }
+    }
+    return FALSE;
 }
 
 static gboolean
-_normalize_bond_options (NMConnection *self)
-{
-	NMSettingBond *s_bond = nm_connection_get_setting_bond (self);
-	gboolean changed = FALSE;
-	const char *name, *mode_str;
-	NMBondMode mode;
-	guint32 num, i;
-
-	/* Strip away unsupported options for current mode */
-	if (s_bond) {
-		mode_str = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MODE);
-		mode = _nm_setting_bond_mode_from_string (mode_str);
-		if (mode == NM_BOND_MODE_UNKNOWN)
-			return FALSE;
+_normalize_bond_options(NMConnection *self)
+{
+    NMSettingBond *s_bond  = nm_connection_get_setting_bond(self);
+    gboolean       changed = FALSE;
+    const char *   name, *mode_str;
+    NMBondMode     mode;
+    guint32        num, i;
+
+    /* Strip away unsupported options for current mode */
+    if (s_bond) {
+        mode_str = nm_setting_bond_get_option_by_name(s_bond, NM_SETTING_BOND_OPTION_MODE);
+        mode     = _nm_setting_bond_mode_from_string(mode_str);
+        if (mode == NM_BOND_MODE_UNKNOWN)
+            return FALSE;
 again:
-		num = nm_setting_bond_get_num_options (s_bond);
-		for (i = 0; i < num; i++) {
-			if (   nm_setting_bond_get_option (s_bond, i, &name, NULL)
-			    && !_nm_setting_bond_option_supported (name, mode)) {
-				nm_setting_bond_remove_option (s_bond, name);
-				changed = TRUE;
-				goto again;
-			}
-		}
-	}
+        num = nm_setting_bond_get_num_options(s_bond);
+        for (i = 0; i < num; i++) {
+            if (nm_setting_bond_get_option(s_bond, i, &name, NULL)
+                && !_nm_setting_bond_option_supported(name, mode)) {
+                nm_setting_bond_remove_option(s_bond, name);
+                changed = TRUE;
+                goto again;
+            }
+        }
+    }
 
-	return changed;
+    return changed;
 }
 
 static gboolean
-_normalize_wireless_mac_address_randomization (NMConnection *self)
-{
-	NMSettingWireless *s_wifi = nm_connection_get_setting_wireless (self);
-	const char *cloned_mac_address;
-	NMSettingMacRandomization mac_address_randomization;
-
-	if (!s_wifi)
-		return FALSE;
-
-	mac_address_randomization = nm_setting_wireless_get_mac_address_randomization (s_wifi);
-	if (!NM_IN_SET (mac_address_randomization,
-	                NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
-	                NM_SETTING_MAC_RANDOMIZATION_NEVER,
-	                NM_SETTING_MAC_RANDOMIZATION_ALWAYS))
-		return FALSE;
-
-	cloned_mac_address = nm_setting_wireless_get_cloned_mac_address (s_wifi);
-	if (cloned_mac_address) {
-		if (nm_streq (cloned_mac_address, "random")) {
-			if (mac_address_randomization == NM_SETTING_MAC_RANDOMIZATION_ALWAYS)
-				return FALSE;
-			mac_address_randomization = NM_SETTING_MAC_RANDOMIZATION_ALWAYS;
-		} else if (nm_streq (cloned_mac_address, "permanent")) {
-			if (mac_address_randomization == NM_SETTING_MAC_RANDOMIZATION_NEVER)
-				return FALSE;
-			mac_address_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER;
-		} else {
-			if (mac_address_randomization == NM_SETTING_MAC_RANDOMIZATION_DEFAULT)
-				return FALSE;
-			mac_address_randomization = NM_SETTING_MAC_RANDOMIZATION_DEFAULT;
-		}
-		g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, mac_address_randomization, NULL);
-		return TRUE;
-	}
-	if (mac_address_randomization != NM_SETTING_MAC_RANDOMIZATION_DEFAULT) {
-		g_object_set (s_wifi,
-		              NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS,
-		              mac_address_randomization == NM_SETTING_MAC_RANDOMIZATION_ALWAYS
-		                  ? "random" : "permanent",
-		              NULL);
-		return TRUE;
-	}
-	return FALSE;
+_normalize_wireless_mac_address_randomization(NMConnection *self)
+{
+    NMSettingWireless *       s_wifi = nm_connection_get_setting_wireless(self);
+    const char *              cloned_mac_address;
+    NMSettingMacRandomization mac_address_randomization;
+
+    if (!s_wifi)
+        return FALSE;
+
+    mac_address_randomization = nm_setting_wireless_get_mac_address_randomization(s_wifi);
+    if (!NM_IN_SET(mac_address_randomization,
+                   NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
+                   NM_SETTING_MAC_RANDOMIZATION_NEVER,
+                   NM_SETTING_MAC_RANDOMIZATION_ALWAYS))
+        return FALSE;
+
+    cloned_mac_address = nm_setting_wireless_get_cloned_mac_address(s_wifi);
+    if (cloned_mac_address) {
+        if (nm_streq(cloned_mac_address, "random")) {
+            if (mac_address_randomization == NM_SETTING_MAC_RANDOMIZATION_ALWAYS)
+                return FALSE;
+            mac_address_randomization = NM_SETTING_MAC_RANDOMIZATION_ALWAYS;
+        } else if (nm_streq(cloned_mac_address, "permanent")) {
+            if (mac_address_randomization == NM_SETTING_MAC_RANDOMIZATION_NEVER)
+                return FALSE;
+            mac_address_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER;
+        } else {
+            if (mac_address_randomization == NM_SETTING_MAC_RANDOMIZATION_DEFAULT)
+                return FALSE;
+            mac_address_randomization = NM_SETTING_MAC_RANDOMIZATION_DEFAULT;
+        }
+        g_object_set(s_wifi,
+                     NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION,
+                     mac_address_randomization,
+                     NULL);
+        return TRUE;
+    }
+    if (mac_address_randomization != NM_SETTING_MAC_RANDOMIZATION_DEFAULT) {
+        g_object_set(s_wifi,
+                     NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS,
+                     mac_address_randomization == NM_SETTING_MAC_RANDOMIZATION_ALWAYS ? "random"
+                                                                                      : "permanent",
+                     NULL);
+        return TRUE;
+    }
+    return FALSE;
 }
 
 static gboolean
-_normalize_macsec (NMConnection *self)
+_normalize_macsec(NMConnection *self)
 {
-	NMSettingMacsec *s_macsec = nm_connection_get_setting_macsec (self);
-	gboolean changed = FALSE;
+    NMSettingMacsec *s_macsec = nm_connection_get_setting_macsec(self);
+    gboolean         changed  = FALSE;
 
-	if (!s_macsec)
-		return FALSE;
+    if (!s_macsec)
+        return FALSE;
 
-	if (nm_setting_macsec_get_mode (s_macsec) != NM_SETTING_MACSEC_MODE_PSK) {
-		if (nm_setting_macsec_get_mka_cak (s_macsec)) {
-			g_object_set (s_macsec, NM_SETTING_MACSEC_MKA_CAK, NULL, NULL);
-			changed = TRUE;
-		}
-		if (nm_setting_macsec_get_mka_ckn (s_macsec)) {
-			g_object_set (s_macsec, NM_SETTING_MACSEC_MKA_CKN, NULL, NULL);
-			changed = TRUE;
-		}
-	}
+    if (nm_setting_macsec_get_mode(s_macsec) != NM_SETTING_MACSEC_MODE_PSK) {
+        if (nm_setting_macsec_get_mka_cak(s_macsec)) {
+            g_object_set(s_macsec, NM_SETTING_MACSEC_MKA_CAK, NULL, NULL);
+            changed = TRUE;
+        }
+        if (nm_setting_macsec_get_mka_ckn(s_macsec)) {
+            g_object_set(s_macsec, NM_SETTING_MACSEC_MKA_CKN, NULL, NULL);
+            changed = TRUE;
+        }
+    }
 
-	return changed;
+    return changed;
 }
 
 static gboolean
-_normalize_team_config (NMConnection *self)
+_normalize_team_config(NMConnection *self)
 {
-	NMSettingTeam *s_team = nm_connection_get_setting_team (self);
+    NMSettingTeam *s_team = nm_connection_get_setting_team(self);
 
-	if (s_team) {
-		const char *config = nm_setting_team_get_config (s_team);
+    if (s_team) {
+        const char *config = nm_setting_team_get_config(s_team);
 
-		if (config && !*config) {
-			g_object_set (s_team, NM_SETTING_TEAM_CONFIG, NULL, NULL);
-			return TRUE;
-		}
-	}
-	return FALSE;
+        if (config && !*config) {
+            g_object_set(s_team, NM_SETTING_TEAM_CONFIG, NULL, NULL);
+            return TRUE;
+        }
+    }
+    return FALSE;
 }
 
 static gboolean
-_normalize_team_port_config (NMConnection *self)
+_normalize_team_port_config(NMConnection *self)
 {
-	NMSettingTeamPort *s_team_port = nm_connection_get_setting_team_port (self);
+    NMSettingTeamPort *s_team_port = nm_connection_get_setting_team_port(self);
 
-	if (s_team_port) {
-		const char *config = nm_setting_team_port_get_config (s_team_port);
+    if (s_team_port) {
+        const char *config = nm_setting_team_port_get_config(s_team_port);
 
-		if (config && !*config) {
-			g_object_set (s_team_port, NM_SETTING_TEAM_PORT_CONFIG, NULL, NULL);
-			return TRUE;
-		}
-	}
-	return FALSE;
+        if (config && !*config) {
+            g_object_set(s_team_port, NM_SETTING_TEAM_PORT_CONFIG, NULL, NULL);
+            return TRUE;
+        }
+    }
+    return FALSE;
 }
 
 static gboolean
-_normalize_bluetooth_type (NMConnection *self)
+_normalize_bluetooth_type(NMConnection *self)
 {
-	const char *type = _nm_connection_detect_bluetooth_type (self);
+    const char *type = _nm_connection_detect_bluetooth_type(self);
 
-	if (type) {
-		g_object_set (nm_connection_get_setting_bluetooth (self),
-		              NM_SETTING_BLUETOOTH_TYPE, type,
-		              NULL);
-		return TRUE;
-	}
-	return FALSE;
+    if (type) {
+        g_object_set(nm_connection_get_setting_bluetooth(self),
+                     NM_SETTING_BLUETOOTH_TYPE,
+                     type,
+                     NULL);
+        return TRUE;
+    }
+    return FALSE;
 }
 
 static gboolean
-_normalize_ovs_interface_type (NMConnection *self)
+_normalize_ovs_interface_type(NMConnection *self)
 {
-	NMSettingOvsInterface *s_ovs_interface = nm_connection_get_setting_ovs_interface (self);
-	gboolean modified;
-	int v;
+    NMSettingOvsInterface *s_ovs_interface = nm_connection_get_setting_ovs_interface(self);
+    gboolean               modified;
+    int                    v;
 
-	if (!s_ovs_interface)
-		return FALSE;
+    if (!s_ovs_interface)
+        return FALSE;
 
-	v = _nm_setting_ovs_interface_verify_interface_type (s_ovs_interface,
-	                                                     nm_setting_ovs_interface_get_interface_type (s_ovs_interface),
-	                                                     self,
-	                                                     TRUE,
-	                                                     &modified,
-	                                                     NULL,
-	                                                     NULL);
-	if (v != TRUE)
-		g_return_val_if_reached (modified);
+    v = _nm_setting_ovs_interface_verify_interface_type(
+        s_ovs_interface,
+        nm_setting_ovs_interface_get_interface_type(s_ovs_interface),
+        self,
+        TRUE,
+        &modified,
+        NULL,
+        NULL);
+    if (v != TRUE)
+        g_return_val_if_reached(modified);
 
-	return modified;
+    return modified;
 }
 
 static gboolean
-_normalize_ip_tunnel_wired_setting (NMConnection *self)
+_normalize_ip_tunnel_wired_setting(NMConnection *self)
 {
-	NMSettingIPTunnel *s_ip_tunnel;
+    NMSettingIPTunnel *s_ip_tunnel;
 
-	s_ip_tunnel = nm_connection_get_setting_ip_tunnel (self);
-	if (!s_ip_tunnel)
-		return FALSE;
+    s_ip_tunnel = nm_connection_get_setting_ip_tunnel(self);
+    if (!s_ip_tunnel)
+        return FALSE;
 
-	if (   nm_connection_get_setting_wired (self)
-	    && !NM_IN_SET (nm_setting_ip_tunnel_get_mode (s_ip_tunnel),
-	                   NM_IP_TUNNEL_MODE_GRETAP,
-	                   NM_IP_TUNNEL_MODE_IP6GRETAP)) {
-		nm_connection_remove_setting (self, NM_TYPE_SETTING_WIRED);
-		return TRUE;
-	}
+    if (nm_connection_get_setting_wired(self)
+        && !NM_IN_SET(nm_setting_ip_tunnel_get_mode(s_ip_tunnel),
+                      NM_IP_TUNNEL_MODE_GRETAP,
+                      NM_IP_TUNNEL_MODE_IP6GRETAP)) {
+        nm_connection_remove_setting(self, NM_TYPE_SETTING_WIRED);
+        return TRUE;
+    }
 
-	return FALSE;
+    return FALSE;
 }
 
 static gboolean
-_normalize_sriov_vf_order (NMConnection *self)
+_normalize_sriov_vf_order(NMConnection *self)
 {
-	NMSettingSriov *s_sriov;
+    NMSettingSriov *s_sriov;
 
-	s_sriov = NM_SETTING_SRIOV (nm_connection_get_setting (self, NM_TYPE_SETTING_SRIOV));
-	if (!s_sriov)
-		return FALSE;
+    s_sriov = NM_SETTING_SRIOV(nm_connection_get_setting(self, NM_TYPE_SETTING_SRIOV));
+    if (!s_sriov)
+        return FALSE;
 
-	return _nm_setting_sriov_sort_vfs (s_sriov);
+    return _nm_setting_sriov_sort_vfs(s_sriov);
 }
 
 static gboolean
-_normalize_bridge_vlan_order (NMConnection *self)
+_normalize_bridge_vlan_order(NMConnection *self)
 {
-	NMSettingBridge *s_bridge;
+    NMSettingBridge *s_bridge;
 
-	s_bridge = nm_connection_get_setting_bridge (self);
-	if (!s_bridge)
-		return FALSE;
+    s_bridge = nm_connection_get_setting_bridge(self);
+    if (!s_bridge)
+        return FALSE;
 
-	return _nm_setting_bridge_sort_vlans (s_bridge);
+    return _nm_setting_bridge_sort_vlans(s_bridge);
 }
 
 static gboolean
-_normalize_bridge_port_vlan_order (NMConnection *self)
+_normalize_bridge_port_vlan_order(NMConnection *self)
 {
-	NMSettingBridgePort *s_port;
+    NMSettingBridgePort *s_port;
 
-	s_port = nm_connection_get_setting_bridge_port (self);
-	if (!s_port)
-		return FALSE;
+    s_port = nm_connection_get_setting_bridge_port(self);
+    if (!s_port)
+        return FALSE;
 
-	return _nm_setting_bridge_port_sort_vlans (s_port);
+    return _nm_setting_bridge_port_sort_vlans(s_port);
 }
 
 static gboolean
-_normalize_gsm_auto_config (NMConnection *self)
+_normalize_gsm_auto_config(NMConnection *self)
 {
-	NMSettingGsm *s_gsm;
+    NMSettingGsm *s_gsm;
 
-	s_gsm = nm_connection_get_setting_gsm (self);
-	if (!s_gsm)
-		return FALSE;
+    s_gsm = nm_connection_get_setting_gsm(self);
+    if (!s_gsm)
+        return FALSE;
 
-	if (!nm_setting_gsm_get_auto_config (s_gsm))
-		return FALSE;
+    if (!nm_setting_gsm_get_auto_config(s_gsm))
+        return FALSE;
 
-	if (   !nm_setting_gsm_get_apn (s_gsm)
-	    && !nm_setting_gsm_get_username (s_gsm)
-	    && !nm_setting_gsm_get_password (s_gsm))
-		return FALSE;
+    if (!nm_setting_gsm_get_apn(s_gsm) && !nm_setting_gsm_get_username(s_gsm)
+        && !nm_setting_gsm_get_password(s_gsm))
+        return FALSE;
 
-	g_object_set (s_gsm,
-	              NM_SETTING_GSM_AUTO_CONFIG, FALSE,
-	              NULL);
-	return TRUE;
+    g_object_set(s_gsm, NM_SETTING_GSM_AUTO_CONFIG, FALSE, NULL);
+    return TRUE;
 }
 
 static gboolean
-_normalize_required_settings (NMConnection *self)
-{
-	NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth (self);
-	NMSetting *s_bridge;
-	gboolean changed = FALSE;
-
-	if (nm_connection_get_setting_vlan (self)) {
-		if (!nm_connection_get_setting_wired (self)) {
-			nm_connection_add_setting (self, nm_setting_wired_new ());
-			changed = TRUE;
-		}
-	}
-	if (s_bt && nm_streq0 (nm_setting_bluetooth_get_connection_type (s_bt), NM_SETTING_BLUETOOTH_TYPE_NAP)) {
-		if (!nm_connection_get_setting_bridge (self)) {
-			s_bridge = nm_setting_bridge_new ();
-			g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL);
-			nm_connection_add_setting (self, s_bridge);
-			changed = TRUE;
-		}
-	}
-	return changed;
+_normalize_required_settings(NMConnection *self)
+{
+    NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth(self);
+    NMSetting *         s_bridge;
+    gboolean            changed = FALSE;
+
+    if (nm_connection_get_setting_vlan(self)) {
+        if (!nm_connection_get_setting_wired(self)) {
+            nm_connection_add_setting(self, nm_setting_wired_new());
+            changed = TRUE;
+        }
+    }
+    if (s_bt
+        && nm_streq0(nm_setting_bluetooth_get_connection_type(s_bt),
+                     NM_SETTING_BLUETOOTH_TYPE_NAP)) {
+        if (!nm_connection_get_setting_bridge(self)) {
+            s_bridge = nm_setting_bridge_new();
+            g_object_set(s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL);
+            nm_connection_add_setting(self, s_bridge);
+            changed = TRUE;
+        }
+    }
+    return changed;
 }
 
 static gboolean
-_normalize_invalid_slave_port_settings (NMConnection *self)
+_normalize_invalid_slave_port_settings(NMConnection *self)
 {
-	NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
-	const char *slave_type;
-	gboolean changed = FALSE;
+    NMSettingConnection *s_con = nm_connection_get_setting_connection(self);
+    const char *         slave_type;
+    gboolean             changed = FALSE;
 
-	slave_type = nm_setting_connection_get_slave_type (s_con);
+    slave_type = nm_setting_connection_get_slave_type(s_con);
 
-	if (   !nm_streq0 (slave_type, NM_SETTING_BRIDGE_SETTING_NAME)
-	    && _nm_connection_remove_setting (self, NM_TYPE_SETTING_BRIDGE_PORT))
-		changed = TRUE;
+    if (!nm_streq0(slave_type, NM_SETTING_BRIDGE_SETTING_NAME)
+        && _nm_connection_remove_setting(self, NM_TYPE_SETTING_BRIDGE_PORT))
+        changed = TRUE;
 
-	if (   !nm_streq0 (slave_type, NM_SETTING_TEAM_SETTING_NAME)
-	    && _nm_connection_remove_setting (self, NM_TYPE_SETTING_TEAM_PORT))
-		changed = TRUE;
+    if (!nm_streq0(slave_type, NM_SETTING_TEAM_SETTING_NAME)
+        && _nm_connection_remove_setting(self, NM_TYPE_SETTING_TEAM_PORT))
+        changed = TRUE;
 
-	return changed;
+    return changed;
 }
 
 /**
@@ -1389,168 +1387,168 @@ _normalize_invalid_slave_port_settings (NMConnection *self)
  * Returns: %TRUE if the connection is valid, %FALSE if it is not
  **/
 gboolean
-nm_connection_verify (NMConnection *connection, GError **error)
+nm_connection_verify(NMConnection *connection, GError **error)
 {
-	NMSettingVerifyResult result;
+    NMSettingVerifyResult result;
 
-	result = _nm_connection_verify (connection, error);
+    result = _nm_connection_verify(connection, error);
 
-	/* we treat normalizable connections as valid. */
-	if (result == NM_SETTING_VERIFY_NORMALIZABLE)
-		g_clear_error (error);
+    /* we treat normalizable connections as valid. */
+    if (result == NM_SETTING_VERIFY_NORMALIZABLE)
+        g_clear_error(error);
 
-	return result == NM_SETTING_VERIFY_SUCCESS || result == NM_SETTING_VERIFY_NORMALIZABLE;
+    return result == NM_SETTING_VERIFY_SUCCESS || result == NM_SETTING_VERIFY_NORMALIZABLE;
 }
 
 NMSettingVerifyResult
-_nm_connection_verify (NMConnection *connection, GError **error)
-{
-	NMSettingIPConfig *s_ip4, *s_ip6;
-	NMSettingProxy *s_proxy;
-	gs_free NMSetting **settings = NULL;
-	gs_free_error GError *normalizable_error = NULL;
-	NMSettingVerifyResult normalizable_error_type = NM_SETTING_VERIFY_SUCCESS;
-	guint i;
-
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_SETTING_VERIFY_ERROR);
-	g_return_val_if_fail (!error || !*error, NM_SETTING_VERIFY_ERROR);
-
-	settings = nm_connection_get_settings (connection, NULL);
-	if (   !settings
-	    || !NM_IS_SETTING_CONNECTION (settings[0])) {
-		g_set_error_literal (error,
-		                     NM_CONNECTION_ERROR,
-		                     NM_CONNECTION_ERROR_MISSING_SETTING,
-		                     _("setting not found"));
-		g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME);
-		return NM_SETTING_VERIFY_ERROR;
-	}
-
-	for (i = 0; settings[i]; i++) {
-		GError *verify_error = NULL;
-		NMSettingVerifyResult verify_result;
-
-		nm_assert (NM_IS_SETTING (settings[i]));
-		nm_assert (NM_IS_SETTING_CONNECTION (settings[i]) == (i == 0));
-
-		/* verify all settings. We stop if we find the first non-normalizable
-		 * @NM_SETTING_VERIFY_ERROR. If we find normalizable errors we continue
-		 * but remember the error to return it to the user.
-		 * @NM_SETTING_VERIFY_NORMALIZABLE_ERROR has a higher priority then
-		 * @NM_SETTING_VERIFY_NORMALIZABLE, so, if we encounter such an error type,
-		 * we remember it instead (to return it as output).
-		 **/
-		verify_result = _nm_setting_verify (settings[i], connection, &verify_error);
-		if (verify_result == NM_SETTING_VERIFY_NORMALIZABLE ||
-		    verify_result == NM_SETTING_VERIFY_NORMALIZABLE_ERROR) {
-			if (   verify_result == NM_SETTING_VERIFY_NORMALIZABLE_ERROR
-			    && normalizable_error_type == NM_SETTING_VERIFY_NORMALIZABLE) {
-				/* NORMALIZABLE_ERROR has higher priority. */
-				g_clear_error (&normalizable_error);
-			}
-			if (!normalizable_error) {
-				g_propagate_error (&normalizable_error, verify_error);
-				verify_error = NULL;
-				normalizable_error_type = verify_result;
-			}
-		} else if (verify_result != NM_SETTING_VERIFY_SUCCESS) {
-			g_propagate_error (error, verify_error);
-			g_return_val_if_fail (verify_result == NM_SETTING_VERIFY_ERROR, NM_SETTING_VERIFY_ERROR);
-			return NM_SETTING_VERIFY_ERROR;
-		}
-		g_clear_error (&verify_error);
-	}
-
-	s_ip4 = nm_connection_get_setting_ip4_config (connection);
-	s_ip6 = nm_connection_get_setting_ip6_config (connection);
-	s_proxy = nm_connection_get_setting_proxy (connection);
-
-	nm_assert (normalizable_error_type != NM_SETTING_VERIFY_ERROR);
-	if (NM_IN_SET (normalizable_error_type, NM_SETTING_VERIFY_SUCCESS,
-	                                        NM_SETTING_VERIFY_NORMALIZABLE)) {
-		if (_supports_addr_family (connection, AF_INET)) {
-			if (!s_ip4 && normalizable_error_type == NM_SETTING_VERIFY_SUCCESS) {
-				g_set_error_literal (&normalizable_error,
-				                     NM_CONNECTION_ERROR,
-				                     NM_CONNECTION_ERROR_MISSING_SETTING,
-				                     _("setting is required for non-slave connections"));
-				g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME);
-
-				/* having a master without IP config was not a verify() error, accept
-				 * it for backward compatibility. */
-				normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
-			}
-		} else {
-			if (s_ip4) {
-				g_clear_error (&normalizable_error);
-				g_set_error_literal (&normalizable_error,
-				                     NM_CONNECTION_ERROR,
-				                     NM_CONNECTION_ERROR_INVALID_SETTING,
-				                     _("setting not allowed in slave connection"));
-				g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME);
-				/* having a slave with IP config *was* and is a verify() error. */
-				normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
-			}
-		}
-
-		if (_supports_addr_family (connection, AF_INET6)) {
-			if (!s_ip6 && normalizable_error_type == NM_SETTING_VERIFY_SUCCESS) {
-				g_set_error_literal (&normalizable_error,
-				                     NM_CONNECTION_ERROR,
-				                     NM_CONNECTION_ERROR_MISSING_SETTING,
-				                     _("setting is required for non-slave connections"));
-				g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME);
-
-				/* having a master without IP config was not a verify() error, accept
-				 * it for backward compatibility. */
-				normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
-			}
-		} else {
-			if (s_ip6) {
-				g_clear_error (&normalizable_error);
-				g_set_error_literal (&normalizable_error,
-				                     NM_CONNECTION_ERROR,
-				                     NM_CONNECTION_ERROR_INVALID_SETTING,
-				                     _("setting not allowed in slave connection"));
-				g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME);
-				/* having a slave with IP config *was* and is a verify() error. */
-				normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
-			}
-		}
-
-		if (_supports_addr_family (connection, AF_UNSPEC)) {
-			if (!s_proxy && normalizable_error_type == NM_SETTING_VERIFY_SUCCESS) {
-				g_set_error_literal (&normalizable_error,
-				                     NM_CONNECTION_ERROR,
-				                     NM_CONNECTION_ERROR_MISSING_SETTING,
-				                     _("setting is required for non-slave connections"));
-				g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_PROXY_SETTING_NAME);
-
-				/* having a master without proxy config was not a verify() error, accept
-				 * it for backward compatibility. */
-				normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
-			}
-		} else {
-			if (s_proxy) {
-				g_clear_error (&normalizable_error);
-				g_set_error_literal (&normalizable_error,
-				                     NM_CONNECTION_ERROR,
-				                     NM_CONNECTION_ERROR_INVALID_SETTING,
-				                     _("setting not allowed in slave connection"));
-				g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_PROXY_SETTING_NAME);
-				/* having a slave with proxy config *was* and is a verify() error. */
-				normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
-			}
-		}
-	}
-
-	if (normalizable_error_type != NM_SETTING_VERIFY_SUCCESS) {
-		g_propagate_error (error, normalizable_error);
-		normalizable_error = NULL;
-		return normalizable_error_type;
-	}
-
-	return NM_SETTING_VERIFY_SUCCESS;
+_nm_connection_verify(NMConnection *connection, GError **error)
+{
+    NMSettingIPConfig *s_ip4, *s_ip6;
+    NMSettingProxy *   s_proxy;
+    gs_free NMSetting **settings                  = NULL;
+    gs_free_error GError *normalizable_error      = NULL;
+    NMSettingVerifyResult normalizable_error_type = NM_SETTING_VERIFY_SUCCESS;
+    guint                 i;
+
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), NM_SETTING_VERIFY_ERROR);
+    g_return_val_if_fail(!error || !*error, NM_SETTING_VERIFY_ERROR);
+
+    settings = nm_connection_get_settings(connection, NULL);
+    if (!settings || !NM_IS_SETTING_CONNECTION(settings[0])) {
+        g_set_error_literal(error,
+                            NM_CONNECTION_ERROR,
+                            NM_CONNECTION_ERROR_MISSING_SETTING,
+                            _("setting not found"));
+        g_prefix_error(error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME);
+        return NM_SETTING_VERIFY_ERROR;
+    }
+
+    for (i = 0; settings[i]; i++) {
+        GError *              verify_error = NULL;
+        NMSettingVerifyResult verify_result;
+
+        nm_assert(NM_IS_SETTING(settings[i]));
+        nm_assert(NM_IS_SETTING_CONNECTION(settings[i]) == (i == 0));
+
+        /* verify all settings. We stop if we find the first non-normalizable
+         * @NM_SETTING_VERIFY_ERROR. If we find normalizable errors we continue
+         * but remember the error to return it to the user.
+         * @NM_SETTING_VERIFY_NORMALIZABLE_ERROR has a higher priority then
+         * @NM_SETTING_VERIFY_NORMALIZABLE, so, if we encounter such an error type,
+         * we remember it instead (to return it as output).
+         **/
+        verify_result = _nm_setting_verify(settings[i], connection, &verify_error);
+        if (verify_result == NM_SETTING_VERIFY_NORMALIZABLE
+            || verify_result == NM_SETTING_VERIFY_NORMALIZABLE_ERROR) {
+            if (verify_result == NM_SETTING_VERIFY_NORMALIZABLE_ERROR
+                && normalizable_error_type == NM_SETTING_VERIFY_NORMALIZABLE) {
+                /* NORMALIZABLE_ERROR has higher priority. */
+                g_clear_error(&normalizable_error);
+            }
+            if (!normalizable_error) {
+                g_propagate_error(&normalizable_error, verify_error);
+                verify_error            = NULL;
+                normalizable_error_type = verify_result;
+            }
+        } else if (verify_result != NM_SETTING_VERIFY_SUCCESS) {
+            g_propagate_error(error, verify_error);
+            g_return_val_if_fail(verify_result == NM_SETTING_VERIFY_ERROR, NM_SETTING_VERIFY_ERROR);
+            return NM_SETTING_VERIFY_ERROR;
+        }
+        g_clear_error(&verify_error);
+    }
+
+    s_ip4   = nm_connection_get_setting_ip4_config(connection);
+    s_ip6   = nm_connection_get_setting_ip6_config(connection);
+    s_proxy = nm_connection_get_setting_proxy(connection);
+
+    nm_assert(normalizable_error_type != NM_SETTING_VERIFY_ERROR);
+    if (NM_IN_SET(normalizable_error_type,
+                  NM_SETTING_VERIFY_SUCCESS,
+                  NM_SETTING_VERIFY_NORMALIZABLE)) {
+        if (_supports_addr_family(connection, AF_INET)) {
+            if (!s_ip4 && normalizable_error_type == NM_SETTING_VERIFY_SUCCESS) {
+                g_set_error_literal(&normalizable_error,
+                                    NM_CONNECTION_ERROR,
+                                    NM_CONNECTION_ERROR_MISSING_SETTING,
+                                    _("setting is required for non-slave connections"));
+                g_prefix_error(&normalizable_error, "%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME);
+
+                /* having a master without IP config was not a verify() error, accept
+                 * it for backward compatibility. */
+                normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
+            }
+        } else {
+            if (s_ip4) {
+                g_clear_error(&normalizable_error);
+                g_set_error_literal(&normalizable_error,
+                                    NM_CONNECTION_ERROR,
+                                    NM_CONNECTION_ERROR_INVALID_SETTING,
+                                    _("setting not allowed in slave connection"));
+                g_prefix_error(&normalizable_error, "%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME);
+                /* having a slave with IP config *was* and is a verify() error. */
+                normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
+            }
+        }
+
+        if (_supports_addr_family(connection, AF_INET6)) {
+            if (!s_ip6 && normalizable_error_type == NM_SETTING_VERIFY_SUCCESS) {
+                g_set_error_literal(&normalizable_error,
+                                    NM_CONNECTION_ERROR,
+                                    NM_CONNECTION_ERROR_MISSING_SETTING,
+                                    _("setting is required for non-slave connections"));
+                g_prefix_error(&normalizable_error, "%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME);
+
+                /* having a master without IP config was not a verify() error, accept
+                 * it for backward compatibility. */
+                normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
+            }
+        } else {
+            if (s_ip6) {
+                g_clear_error(&normalizable_error);
+                g_set_error_literal(&normalizable_error,
+                                    NM_CONNECTION_ERROR,
+                                    NM_CONNECTION_ERROR_INVALID_SETTING,
+                                    _("setting not allowed in slave connection"));
+                g_prefix_error(&normalizable_error, "%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME);
+                /* having a slave with IP config *was* and is a verify() error. */
+                normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
+            }
+        }
+
+        if (_supports_addr_family(connection, AF_UNSPEC)) {
+            if (!s_proxy && normalizable_error_type == NM_SETTING_VERIFY_SUCCESS) {
+                g_set_error_literal(&normalizable_error,
+                                    NM_CONNECTION_ERROR,
+                                    NM_CONNECTION_ERROR_MISSING_SETTING,
+                                    _("setting is required for non-slave connections"));
+                g_prefix_error(&normalizable_error, "%s: ", NM_SETTING_PROXY_SETTING_NAME);
+
+                /* having a master without proxy config was not a verify() error, accept
+                 * it for backward compatibility. */
+                normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
+            }
+        } else {
+            if (s_proxy) {
+                g_clear_error(&normalizable_error);
+                g_set_error_literal(&normalizable_error,
+                                    NM_CONNECTION_ERROR,
+                                    NM_CONNECTION_ERROR_INVALID_SETTING,
+                                    _("setting not allowed in slave connection"));
+                g_prefix_error(&normalizable_error, "%s: ", NM_SETTING_PROXY_SETTING_NAME);
+                /* having a slave with proxy config *was* and is a verify() error. */
+                normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
+            }
+        }
+    }
+
+    if (normalizable_error_type != NM_SETTING_VERIFY_SUCCESS) {
+        g_propagate_error(error, normalizable_error);
+        normalizable_error = NULL;
+        return normalizable_error_type;
+    }
+
+    return NM_SETTING_VERIFY_SUCCESS;
 }
 
 /**
@@ -1565,92 +1563,93 @@ _nm_connection_verify (NMConnection *connection, GError **error)
  * Since: 1.2
  **/
 gboolean
-nm_connection_verify_secrets (NMConnection *connection, GError **error)
+nm_connection_verify_secrets(NMConnection *connection, GError **error)
 {
-	GHashTableIter iter;
-	NMSetting *setting;
+    GHashTableIter iter;
+    NMSetting *    setting;
 
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
-	g_return_val_if_fail (!error || !*error, FALSE);
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE);
+    g_return_val_if_fail(!error || !*error, FALSE);
 
-	g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
-	while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) {
-		if (!nm_setting_verify_secrets (setting, connection, error))
-			return FALSE;
-	}
-	return TRUE;
+    g_hash_table_iter_init(&iter, NM_CONNECTION_GET_PRIVATE(connection)->settings);
+    while (g_hash_table_iter_next(&iter, NULL, (gpointer) &setting)) {
+        if (!nm_setting_verify_secrets(setting, connection, error))
+            return FALSE;
+    }
+    return TRUE;
 }
 
 static gboolean
-_connection_normalize (NMConnection *connection,
-                       GHashTable *parameters,
-                       gboolean *modified,
-                       GError **error)
+_connection_normalize(NMConnection *connection,
+                      GHashTable *  parameters,
+                      gboolean *    modified,
+                      GError **     error)
 {
-	NMSettingVerifyResult success;
-	gboolean was_modified;
+    NMSettingVerifyResult success;
+    gboolean              was_modified;
 
 #if NM_MORE_ASSERTS > 10
-	/* only call this _nm_connection_verify() confirms that the connection
-	 * requires normalization and is normalizable. */
-	nm_assert (NM_IN_SET (_nm_connection_verify (connection, NULL),
-	                      NM_SETTING_VERIFY_NORMALIZABLE,
-	                      NM_SETTING_VERIFY_NORMALIZABLE_ERROR));
+    /* only call this _nm_connection_verify() confirms that the connection
+     * requires normalization and is normalizable. */
+    nm_assert(NM_IN_SET(_nm_connection_verify(connection, NULL),
+                        NM_SETTING_VERIFY_NORMALIZABLE,
+                        NM_SETTING_VERIFY_NORMALIZABLE_ERROR));
 #endif
 
-	/* Try to perform all kind of normalizations on the settings to fix it.
-	 * We only do this, after verifying that the connection contains no un-normalizable
-	 * errors, because in that case we rather fail without touching the settings. */
-
-	was_modified = FALSE;
-
-	was_modified |= _normalize_connection_uuid (connection);
-	was_modified |= _normalize_connection_type (connection);
-	was_modified |= _normalize_connection_slave_type (connection);
-	was_modified |= _normalize_required_settings (connection);
-	was_modified |= _normalize_invalid_slave_port_settings (connection);
-	was_modified |= _normalize_ip_config (connection, parameters);
-	was_modified |= _normalize_ethernet_link_neg (connection);
-	was_modified |= _normalize_infiniband_mtu (connection);
-	was_modified |= _normalize_bond_mode (connection);
-	was_modified |= _normalize_bond_options (connection);
-	was_modified |= _normalize_wireless_mac_address_randomization (connection);
-	was_modified |= _normalize_macsec (connection);
-	was_modified |= _normalize_team_config (connection);
-	was_modified |= _normalize_team_port_config (connection);
-	was_modified |= _normalize_bluetooth_type (connection);
-	was_modified |= _normalize_ovs_interface_type (connection);
-	was_modified |= _normalize_ip_tunnel_wired_setting (connection);
-	was_modified |= _normalize_sriov_vf_order (connection);
-	was_modified |= _normalize_bridge_vlan_order (connection);
-	was_modified |= _normalize_bridge_port_vlan_order (connection);
-	was_modified |= _normalize_gsm_auto_config (connection);
-
-	was_modified = !!was_modified;
-
-	/* Verify anew */
-	success = _nm_connection_verify (connection, error);
-
-	NM_SET_OUT (modified, was_modified);
-
-	if (success != NM_SETTING_VERIFY_SUCCESS) {
-		/* we would expect, that after normalization, the connection can be verified.
-		 * Also treat NM_SETTING_VERIFY_NORMALIZABLE as failure, because there is something
-		 * odd going on. */
-		if (error && !*error) {
-			g_set_error_literal (error,
-			                     NM_CONNECTION_ERROR,
-			                     NM_CONNECTION_ERROR_FAILED,
-			                     _("Unexpected failure to normalize the connection"));
-		}
-		g_warning ("connection did not verify after normalization: %s", error ? (*error)->message : "??");
-		g_return_val_if_reached (FALSE);
-	}
-
-	/* we would expect, that the connection was modified during normalization. */
-	g_return_val_if_fail (was_modified, TRUE);
-
-	return TRUE;
+    /* Try to perform all kind of normalizations on the settings to fix it.
+     * We only do this, after verifying that the connection contains no un-normalizable
+     * errors, because in that case we rather fail without touching the settings. */
+
+    was_modified = FALSE;
+
+    was_modified |= _normalize_connection_uuid(connection);
+    was_modified |= _normalize_connection_type(connection);
+    was_modified |= _normalize_connection_slave_type(connection);
+    was_modified |= _normalize_required_settings(connection);
+    was_modified |= _normalize_invalid_slave_port_settings(connection);
+    was_modified |= _normalize_ip_config(connection, parameters);
+    was_modified |= _normalize_ethernet_link_neg(connection);
+    was_modified |= _normalize_infiniband_mtu(connection);
+    was_modified |= _normalize_bond_mode(connection);
+    was_modified |= _normalize_bond_options(connection);
+    was_modified |= _normalize_wireless_mac_address_randomization(connection);
+    was_modified |= _normalize_macsec(connection);
+    was_modified |= _normalize_team_config(connection);
+    was_modified |= _normalize_team_port_config(connection);
+    was_modified |= _normalize_bluetooth_type(connection);
+    was_modified |= _normalize_ovs_interface_type(connection);
+    was_modified |= _normalize_ip_tunnel_wired_setting(connection);
+    was_modified |= _normalize_sriov_vf_order(connection);
+    was_modified |= _normalize_bridge_vlan_order(connection);
+    was_modified |= _normalize_bridge_port_vlan_order(connection);
+    was_modified |= _normalize_gsm_auto_config(connection);
+
+    was_modified = !!was_modified;
+
+    /* Verify anew */
+    success = _nm_connection_verify(connection, error);
+
+    NM_SET_OUT(modified, was_modified);
+
+    if (success != NM_SETTING_VERIFY_SUCCESS) {
+        /* we would expect, that after normalization, the connection can be verified.
+         * Also treat NM_SETTING_VERIFY_NORMALIZABLE as failure, because there is something
+         * odd going on. */
+        if (error && !*error) {
+            g_set_error_literal(error,
+                                NM_CONNECTION_ERROR,
+                                NM_CONNECTION_ERROR_FAILED,
+                                _("Unexpected failure to normalize the connection"));
+        }
+        g_warning("connection did not verify after normalization: %s",
+                  error ? (*error)->message : "??");
+        g_return_val_if_reached(FALSE);
+    }
+
+    /* we would expect, that the connection was modified during normalization. */
+    g_return_val_if_fail(was_modified, TRUE);
+
+    return TRUE;
 }
 
 /**
@@ -1677,165 +1676,163 @@ _connection_normalize (NMConnection *connection,
  * Returns: %TRUE if the connection is valid, %FALSE if it is not
  **/
 gboolean
-nm_connection_normalize (NMConnection *connection,
-                         GHashTable *parameters,
-                         gboolean *modified,
-                         GError **error)
-{
-	NMSettingVerifyResult success;
-	gs_free_error GError *normalizable_error = NULL;
-
-	success = _nm_connection_verify (connection, &normalizable_error);
-
-	if (!NM_IN_SET (success,
-	                NM_SETTING_VERIFY_NORMALIZABLE,
-	                NM_SETTING_VERIFY_NORMALIZABLE_ERROR)) {
-		if (normalizable_error) {
-			nm_assert (success == NM_SETTING_VERIFY_ERROR);
-			g_propagate_error (error, g_steal_pointer (&normalizable_error));
-		} else
-			nm_assert (success == NM_SETTING_VERIFY_SUCCESS);
-
-		NM_SET_OUT (modified, FALSE);
-
-		if (success != NM_SETTING_VERIFY_SUCCESS) {
-			if (   error
-			    && !*error) {
-				g_set_error_literal (error,
-				                     NM_CONNECTION_ERROR,
-				                     NM_CONNECTION_ERROR_FAILED,
-				                     _("Unexpected failure to verify the connection"));
-				return FALSE;
-			}
-			return FALSE;
-		}
-
-		if (error && *error)
-			return FALSE;
-		return TRUE;
-	}
-
-	return _connection_normalize (connection, parameters, modified, error);
+nm_connection_normalize(NMConnection *connection,
+                        GHashTable *  parameters,
+                        gboolean *    modified,
+                        GError **     error)
+{
+    NMSettingVerifyResult success;
+    gs_free_error GError *normalizable_error = NULL;
+
+    success = _nm_connection_verify(connection, &normalizable_error);
+
+    if (!NM_IN_SET(success, NM_SETTING_VERIFY_NORMALIZABLE, NM_SETTING_VERIFY_NORMALIZABLE_ERROR)) {
+        if (normalizable_error) {
+            nm_assert(success == NM_SETTING_VERIFY_ERROR);
+            g_propagate_error(error, g_steal_pointer(&normalizable_error));
+        } else
+            nm_assert(success == NM_SETTING_VERIFY_SUCCESS);
+
+        NM_SET_OUT(modified, FALSE);
+
+        if (success != NM_SETTING_VERIFY_SUCCESS) {
+            if (error && !*error) {
+                g_set_error_literal(error,
+                                    NM_CONNECTION_ERROR,
+                                    NM_CONNECTION_ERROR_FAILED,
+                                    _("Unexpected failure to verify the connection"));
+                return FALSE;
+            }
+            return FALSE;
+        }
+
+        if (error && *error)
+            return FALSE;
+        return TRUE;
+    }
+
+    return _connection_normalize(connection, parameters, modified, error);
 }
 
 gboolean
-_nm_connection_ensure_normalized (NMConnection *connection,
-                                  gboolean allow_modify,
-                                  const char *expected_uuid,
-                                  gboolean coerce_uuid,
-                                  NMConnection **out_connection_clone,
-                                  GError **error)
-{
-	gs_unref_object NMConnection *connection_clone = NULL;
-	gs_free_error GError *local = NULL;
-	NMSettingVerifyResult vresult;
-
-	nm_assert (NM_IS_CONNECTION (connection));
-	nm_assert (!out_connection_clone || !*out_connection_clone);
-	nm_assert (!expected_uuid || nm_utils_is_uuid (expected_uuid));
-
-	if (expected_uuid) {
-		if (nm_streq0 (expected_uuid, nm_connection_get_uuid (connection)))
-			expected_uuid = NULL;
-		else if (   !coerce_uuid
-		         || (!allow_modify && !out_connection_clone)) {
-			g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
-			             _("unexpected uuid %s instead of %s"),
-			             nm_connection_get_uuid (connection),
-			             expected_uuid);
-			return FALSE;
-		}
-	}
-
-	vresult = _nm_connection_verify (connection, &local);
-	if (vresult != NM_SETTING_VERIFY_SUCCESS) {
-		if (!NM_IN_SET (vresult, NM_SETTING_VERIFY_NORMALIZABLE,
-		                         NM_SETTING_VERIFY_NORMALIZABLE_ERROR)) {
-			g_propagate_error (error, g_steal_pointer (&local));
-			return FALSE;
-		}
-		if (!allow_modify) {
-			if (!out_connection_clone) {
-				/* even NM_SETTING_VERIFY_NORMALIZABLE is treated as an error. We could normalize,
-				 * but are not allowed to (and no out argument is provided for cloning).  */
-				g_propagate_error (error, g_steal_pointer (&local));
-				return FALSE;
-			}
-			connection_clone = nm_simple_connection_new_clone (connection);
-			connection = connection_clone;
-		}
-		if (!_connection_normalize (connection, NULL, NULL, error))
-			g_return_val_if_reached (FALSE);
-	}
-
-	if (expected_uuid) {
-		NMSettingConnection *s_con;
-
-		if (   !allow_modify
-		    && !connection_clone) {
-			nm_assert (out_connection_clone);
-			connection_clone = nm_simple_connection_new_clone (connection);
-			connection = connection_clone;
-		}
-		s_con = nm_connection_get_setting_connection (connection);
-		g_object_set (s_con,
-		              NM_SETTING_CONNECTION_UUID,
-		              expected_uuid,
-		              NULL);
-	}
-
-	NM_SET_OUT (out_connection_clone, g_steal_pointer (&connection_clone));
-	return TRUE;
+_nm_connection_ensure_normalized(NMConnection * connection,
+                                 gboolean       allow_modify,
+                                 const char *   expected_uuid,
+                                 gboolean       coerce_uuid,
+                                 NMConnection **out_connection_clone,
+                                 GError **      error)
+{
+    gs_unref_object NMConnection *connection_clone = NULL;
+    gs_free_error GError *local                    = NULL;
+    NMSettingVerifyResult vresult;
+
+    nm_assert(NM_IS_CONNECTION(connection));
+    nm_assert(!out_connection_clone || !*out_connection_clone);
+    nm_assert(!expected_uuid || nm_utils_is_uuid(expected_uuid));
+
+    if (expected_uuid) {
+        if (nm_streq0(expected_uuid, nm_connection_get_uuid(connection)))
+            expected_uuid = NULL;
+        else if (!coerce_uuid || (!allow_modify && !out_connection_clone)) {
+            g_set_error(error,
+                        NM_CONNECTION_ERROR,
+                        NM_CONNECTION_ERROR_INVALID_PROPERTY,
+                        _("unexpected uuid %s instead of %s"),
+                        nm_connection_get_uuid(connection),
+                        expected_uuid);
+            return FALSE;
+        }
+    }
+
+    vresult = _nm_connection_verify(connection, &local);
+    if (vresult != NM_SETTING_VERIFY_SUCCESS) {
+        if (!NM_IN_SET(vresult,
+                       NM_SETTING_VERIFY_NORMALIZABLE,
+                       NM_SETTING_VERIFY_NORMALIZABLE_ERROR)) {
+            g_propagate_error(error, g_steal_pointer(&local));
+            return FALSE;
+        }
+        if (!allow_modify) {
+            if (!out_connection_clone) {
+                /* even NM_SETTING_VERIFY_NORMALIZABLE is treated as an error. We could normalize,
+                 * but are not allowed to (and no out argument is provided for cloning).  */
+                g_propagate_error(error, g_steal_pointer(&local));
+                return FALSE;
+            }
+            connection_clone = nm_simple_connection_new_clone(connection);
+            connection       = connection_clone;
+        }
+        if (!_connection_normalize(connection, NULL, NULL, error))
+            g_return_val_if_reached(FALSE);
+    }
+
+    if (expected_uuid) {
+        NMSettingConnection *s_con;
+
+        if (!allow_modify && !connection_clone) {
+            nm_assert(out_connection_clone);
+            connection_clone = nm_simple_connection_new_clone(connection);
+            connection       = connection_clone;
+        }
+        s_con = nm_connection_get_setting_connection(connection);
+        g_object_set(s_con, NM_SETTING_CONNECTION_UUID, expected_uuid, NULL);
+    }
+
+    NM_SET_OUT(out_connection_clone, g_steal_pointer(&connection_clone));
+    return TRUE;
 }
 
 /*****************************************************************************/
 
 #if NM_MORE_ASSERTS
 static void
-_nmtst_connection_unchanging_changed_cb (NMConnection *connection, gpointer user_data)
+_nmtst_connection_unchanging_changed_cb(NMConnection *connection, gpointer user_data)
 {
-	nm_assert_not_reached ();
+    nm_assert_not_reached();
 }
 
 static void
-_nmtst_connection_unchanging_secrets_updated_cb (NMConnection *connection, const char *setting_name, gpointer user_data)
+_nmtst_connection_unchanging_secrets_updated_cb(NMConnection *connection,
+                                                const char *  setting_name,
+                                                gpointer      user_data)
 {
-	nm_assert_not_reached ();
+    nm_assert_not_reached();
 }
 
 const char _nmtst_connection_unchanging_user_data = 0;
 
 void
-nmtst_connection_assert_unchanging (NMConnection *connection)
-{
-	if (!connection)
-		return;
-
-	nm_assert (NM_IS_CONNECTION (connection));
-
-	if (g_signal_handler_find (connection,
-	                           G_SIGNAL_MATCH_DATA,
-	                           0,
-	                           0,
-	                           NULL,
-	                           NULL,
-	                           (gpointer) &_nmtst_connection_unchanging_user_data) != 0) {
-		/* avoid connecting the assertion handler multiple times. */
-		return;
-	}
-
-	g_signal_connect (connection,
-	                  NM_CONNECTION_CHANGED,
-	                  G_CALLBACK (_nmtst_connection_unchanging_changed_cb),
-	                  (gpointer) &_nmtst_connection_unchanging_user_data);
-	g_signal_connect (connection,
-	                  NM_CONNECTION_SECRETS_CLEARED,
-	                  G_CALLBACK (_nmtst_connection_unchanging_changed_cb),
-	                  (gpointer) &_nmtst_connection_unchanging_user_data);
-	g_signal_connect (connection,
-	                  NM_CONNECTION_SECRETS_UPDATED,
-	                  G_CALLBACK (_nmtst_connection_unchanging_secrets_updated_cb),
-	                  (gpointer) &_nmtst_connection_unchanging_user_data);
+nmtst_connection_assert_unchanging(NMConnection *connection)
+{
+    if (!connection)
+        return;
+
+    nm_assert(NM_IS_CONNECTION(connection));
+
+    if (g_signal_handler_find(connection,
+                              G_SIGNAL_MATCH_DATA,
+                              0,
+                              0,
+                              NULL,
+                              NULL,
+                              (gpointer) &_nmtst_connection_unchanging_user_data)
+        != 0) {
+        /* avoid connecting the assertion handler multiple times. */
+        return;
+    }
+
+    g_signal_connect(connection,
+                     NM_CONNECTION_CHANGED,
+                     G_CALLBACK(_nmtst_connection_unchanging_changed_cb),
+                     (gpointer) &_nmtst_connection_unchanging_user_data);
+    g_signal_connect(connection,
+                     NM_CONNECTION_SECRETS_CLEARED,
+                     G_CALLBACK(_nmtst_connection_unchanging_changed_cb),
+                     (gpointer) &_nmtst_connection_unchanging_user_data);
+    g_signal_connect(connection,
+                     NM_CONNECTION_SECRETS_UPDATED,
+                     G_CALLBACK(_nmtst_connection_unchanging_secrets_updated_cb),
+                     (gpointer) &_nmtst_connection_unchanging_user_data);
 }
 #endif
 
@@ -1860,117 +1857,116 @@ nmtst_connection_assert_unchanging (NMConnection *connection)
  * failed (tried to update secrets for a setting that doesn't exist, etc)
  **/
 gboolean
-nm_connection_update_secrets (NMConnection *connection,
-                              const char *setting_name,
-                              GVariant *secrets,
-                              GError **error)
-{
-	NMSetting *setting;
-	gboolean success = TRUE;
-	gboolean updated = FALSE;
-	GVariant *setting_dict = NULL;
-	GVariantIter iter;
-	const char *key;
-	gboolean full_connection;
-	int success_detail;
-
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
-
-	full_connection = g_variant_is_of_type (secrets, NM_VARIANT_TYPE_CONNECTION);
-
-	g_return_val_if_fail (   full_connection
-	                      || g_variant_is_of_type (secrets, NM_VARIANT_TYPE_SETTING), FALSE);
-	g_return_val_if_fail (!error || !*error, FALSE);
-	g_return_val_if_fail (setting_name || full_connection, FALSE);
-
-	/* Empty @secrets means success */
-	if (g_variant_n_children (secrets) == 0)
-		return TRUE;
-
-	if (setting_name) {
-		/* Update just one setting's secrets */
-		setting = nm_connection_get_setting_by_name (connection, setting_name);
-		if (!setting) {
-			g_set_error_literal (error,
-			                     NM_CONNECTION_ERROR,
-			                     NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
-			                     setting_name);
-			return FALSE;
-		}
-
-		if (full_connection) {
-			setting_dict = g_variant_lookup_value (secrets, setting_name, NM_VARIANT_TYPE_SETTING);
-			if (!setting_dict) {
-				/* The connection dictionary didn't contain any secrets for
-				 * @setting_name; just return success.
-				 */
-				return TRUE;
-			}
-		}
-
-		g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
-		success_detail = _nm_setting_update_secrets (setting,
-		                                             setting_dict ?: secrets,
-		                                             error);
-		g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
-
-		nm_clear_pointer (&setting_dict, g_variant_unref);
-
-		if (success_detail == NM_SETTING_UPDATE_SECRET_ERROR) {
-			nm_assert (!error || *error);
-			return FALSE;
-		}
-		if (success_detail == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
-			updated = TRUE;
-	} else {
-		/* check first, whether all the settings exist... */
-		g_variant_iter_init (&iter, secrets);
-		while (g_variant_iter_next (&iter, "{&s@a{sv}}", &key, NULL)) {
-			setting = nm_connection_get_setting_by_name (connection, key);
-			if (!setting) {
-				g_set_error_literal (error,
-				                     NM_CONNECTION_ERROR,
-				                     NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
-				                     key);
-				return FALSE;
-			}
-		}
-
-		/* Update each setting with any secrets from the connection dictionary */
-		g_variant_iter_init (&iter, secrets);
-		while (g_variant_iter_next (&iter, "{&s@a{sv}}", &key, &setting_dict)) {
-			gs_free_error GError *local = NULL;
-
-			/* Update the secrets for this setting */
-			setting = nm_connection_get_setting_by_name (connection, key);
-
-			g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
-			success_detail = _nm_setting_update_secrets (setting, setting_dict, error ? &local : NULL);
-			g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
-
-			g_variant_unref (setting_dict);
-
-			if (success_detail == NM_SETTING_UPDATE_SECRET_ERROR) {
-				if (success) {
-					if (error) {
-						nm_assert (local);
-						g_propagate_error (error, g_steal_pointer (&local));
-						error = NULL;
-					} else
-						nm_assert (!local);
-					success = FALSE;
-				}
-				break;
-			}
-			if (success_detail == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
-				updated = TRUE;
-		}
-	}
-
-	if (updated)
-		g_signal_emit (connection, signals[SECRETS_UPDATED], 0, setting_name);
-
-	return success;
+nm_connection_update_secrets(NMConnection *connection,
+                             const char *  setting_name,
+                             GVariant *    secrets,
+                             GError **     error)
+{
+    NMSetting *  setting;
+    gboolean     success      = TRUE;
+    gboolean     updated      = FALSE;
+    GVariant *   setting_dict = NULL;
+    GVariantIter iter;
+    const char * key;
+    gboolean     full_connection;
+    int          success_detail;
+
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE);
+
+    full_connection = g_variant_is_of_type(secrets, NM_VARIANT_TYPE_CONNECTION);
+
+    g_return_val_if_fail(full_connection || g_variant_is_of_type(secrets, NM_VARIANT_TYPE_SETTING),
+                         FALSE);
+    g_return_val_if_fail(!error || !*error, FALSE);
+    g_return_val_if_fail(setting_name || full_connection, FALSE);
+
+    /* Empty @secrets means success */
+    if (g_variant_n_children(secrets) == 0)
+        return TRUE;
+
+    if (setting_name) {
+        /* Update just one setting's secrets */
+        setting = nm_connection_get_setting_by_name(connection, setting_name);
+        if (!setting) {
+            g_set_error_literal(error,
+                                NM_CONNECTION_ERROR,
+                                NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
+                                setting_name);
+            return FALSE;
+        }
+
+        if (full_connection) {
+            setting_dict = g_variant_lookup_value(secrets, setting_name, NM_VARIANT_TYPE_SETTING);
+            if (!setting_dict) {
+                /* The connection dictionary didn't contain any secrets for
+                 * @setting_name; just return success.
+                 */
+                return TRUE;
+            }
+        }
+
+        g_signal_handlers_block_by_func(setting, (GCallback) setting_changed_cb, connection);
+        success_detail = _nm_setting_update_secrets(setting, setting_dict ?: secrets, error);
+        g_signal_handlers_unblock_by_func(setting, (GCallback) setting_changed_cb, connection);
+
+        nm_clear_pointer(&setting_dict, g_variant_unref);
+
+        if (success_detail == NM_SETTING_UPDATE_SECRET_ERROR) {
+            nm_assert(!error || *error);
+            return FALSE;
+        }
+        if (success_detail == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
+            updated = TRUE;
+    } else {
+        /* check first, whether all the settings exist... */
+        g_variant_iter_init(&iter, secrets);
+        while (g_variant_iter_next(&iter, "{&s@a{sv}}", &key, NULL)) {
+            setting = nm_connection_get_setting_by_name(connection, key);
+            if (!setting) {
+                g_set_error_literal(error,
+                                    NM_CONNECTION_ERROR,
+                                    NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
+                                    key);
+                return FALSE;
+            }
+        }
+
+        /* Update each setting with any secrets from the connection dictionary */
+        g_variant_iter_init(&iter, secrets);
+        while (g_variant_iter_next(&iter, "{&s@a{sv}}", &key, &setting_dict)) {
+            gs_free_error GError *local = NULL;
+
+            /* Update the secrets for this setting */
+            setting = nm_connection_get_setting_by_name(connection, key);
+
+            g_signal_handlers_block_by_func(setting, (GCallback) setting_changed_cb, connection);
+            success_detail =
+                _nm_setting_update_secrets(setting, setting_dict, error ? &local : NULL);
+            g_signal_handlers_unblock_by_func(setting, (GCallback) setting_changed_cb, connection);
+
+            g_variant_unref(setting_dict);
+
+            if (success_detail == NM_SETTING_UPDATE_SECRET_ERROR) {
+                if (success) {
+                    if (error) {
+                        nm_assert(local);
+                        g_propagate_error(error, g_steal_pointer(&local));
+                        error = NULL;
+                    } else
+                        nm_assert(!local);
+                    success = FALSE;
+                }
+                break;
+            }
+            if (success_detail == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
+                updated = TRUE;
+        }
+    }
+
+    if (updated)
+        g_signal_emit(connection, signals[SECRETS_UPDATED], 0, setting_name);
+
+    return success;
 }
 
 /**
@@ -1993,45 +1989,44 @@ nm_connection_update_secrets (NMConnection *connection,
  *   missing secrets
  **/
 const char *
-nm_connection_need_secrets (NMConnection *connection,
-                            GPtrArray **hints)
+nm_connection_need_secrets(NMConnection *connection, GPtrArray **hints)
 {
-	NMConnectionPrivate *priv;
-	GHashTableIter hiter;
-	GSList *settings = NULL;
-	GSList *iter;
-	const char *name = NULL;
-	NMSetting *setting;
+    NMConnectionPrivate *priv;
+    GHashTableIter       hiter;
+    GSList *             settings = NULL;
+    GSList *             iter;
+    const char *         name = NULL;
+    NMSetting *          setting;
 
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-	if (hints)
-		g_return_val_if_fail (*hints == NULL, NULL);
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
+    if (hints)
+        g_return_val_if_fail(*hints == NULL, NULL);
 
-	priv = NM_CONNECTION_GET_PRIVATE (connection);
+    priv = NM_CONNECTION_GET_PRIVATE(connection);
 
-	/* Get list of settings in priority order */
-	g_hash_table_iter_init (&hiter, priv->settings);
-	while (g_hash_table_iter_next (&hiter, NULL, (gpointer) &setting))
-		settings = g_slist_insert_sorted (settings, setting, _nm_setting_compare_priority);
+    /* Get list of settings in priority order */
+    g_hash_table_iter_init(&hiter, priv->settings);
+    while (g_hash_table_iter_next(&hiter, NULL, (gpointer) &setting))
+        settings = g_slist_insert_sorted(settings, setting, _nm_setting_compare_priority);
 
-	for (iter = settings; iter; iter = g_slist_next (iter)) {
-		GPtrArray *secrets;
+    for (iter = settings; iter; iter = g_slist_next(iter)) {
+        GPtrArray *secrets;
 
-		setting = NM_SETTING (iter->data);
-		secrets = _nm_setting_need_secrets (setting);
-		if (secrets) {
-			if (hints)
-				*hints = secrets;
-			else
-				g_ptr_array_free (secrets, TRUE);
+        setting = NM_SETTING(iter->data);
+        secrets = _nm_setting_need_secrets(setting);
+        if (secrets) {
+            if (hints)
+                *hints = secrets;
+            else
+                g_ptr_array_free(secrets, TRUE);
 
-			name = nm_setting_get_name (setting);
-			break;
-		}
-	}
+            name = nm_setting_get_name(setting);
+            break;
+        }
+    }
 
-	g_slist_free (settings);
-	return name;
+    g_slist_free(settings);
+    return name;
 }
 
 /**
@@ -2042,9 +2037,9 @@ nm_connection_need_secrets (NMConnection *connection,
  * keeping secret data in memory when not needed.
  **/
 void
-nm_connection_clear_secrets (NMConnection *connection)
+nm_connection_clear_secrets(NMConnection *connection)
 {
-	return nm_connection_clear_secrets_with_flags (connection, NULL, NULL);
+    return nm_connection_clear_secrets_with_flags(connection, NULL, NULL);
 }
 
 /**
@@ -2057,43 +2052,43 @@ nm_connection_clear_secrets (NMConnection *connection)
  * Clears and frees secrets determined by @func.
  **/
 void
-nm_connection_clear_secrets_with_flags (NMConnection *connection,
-                                        NMSettingClearSecretsWithFlagsFn func,
-                                        gpointer user_data)
+nm_connection_clear_secrets_with_flags(NMConnection *                   connection,
+                                       NMSettingClearSecretsWithFlagsFn func,
+                                       gpointer                         user_data)
 {
-	GHashTableIter iter;
-	NMSetting *setting;
+    GHashTableIter iter;
+    NMSetting *    setting;
 
-	g_return_if_fail (NM_IS_CONNECTION (connection));
+    g_return_if_fail(NM_IS_CONNECTION(connection));
 
-	g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
-	while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) {
-		g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
-		_nm_setting_clear_secrets (setting, func, user_data);
-		g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
-	}
+    g_hash_table_iter_init(&iter, NM_CONNECTION_GET_PRIVATE(connection)->settings);
+    while (g_hash_table_iter_next(&iter, NULL, (gpointer) &setting)) {
+        g_signal_handlers_block_by_func(setting, (GCallback) setting_changed_cb, connection);
+        _nm_setting_clear_secrets(setting, func, user_data);
+        g_signal_handlers_unblock_by_func(setting, (GCallback) setting_changed_cb, connection);
+    }
 
-	g_signal_emit (connection, signals[SECRETS_CLEARED], 0);
+    g_signal_emit(connection, signals[SECRETS_CLEARED], 0);
 }
 
 static gboolean
-_clear_secrets_by_secret_flags_cb (NMSetting *setting,
-                                   const char *secret,
-                                   NMSettingSecretFlags flags,
-                                   gpointer user_data)
+_clear_secrets_by_secret_flags_cb(NMSetting *          setting,
+                                  const char *         secret,
+                                  NMSettingSecretFlags flags,
+                                  gpointer             user_data)
 {
-	NMSettingSecretFlags filter_flags = GPOINTER_TO_UINT (user_data);
-	gboolean remove_secret;
+    NMSettingSecretFlags filter_flags = GPOINTER_TO_UINT(user_data);
+    gboolean             remove_secret;
 
-	if (filter_flags == NM_SETTING_SECRET_FLAG_NONE) {
-		/* Can't use bitops with SECRET_FLAG_NONE so handle that specifically */
-		remove_secret = (flags != NM_SETTING_SECRET_FLAG_NONE);
-	} else {
-		/* Otherwise if the secret has at least one of the desired flags keep it */
-		remove_secret = !NM_FLAGS_ANY (flags, filter_flags);
-	}
+    if (filter_flags == NM_SETTING_SECRET_FLAG_NONE) {
+        /* Can't use bitops with SECRET_FLAG_NONE so handle that specifically */
+        remove_secret = (flags != NM_SETTING_SECRET_FLAG_NONE);
+    } else {
+        /* Otherwise, if the secret has at least one of the desired flags keep it */
+        remove_secret = !NM_FLAGS_ANY(flags, filter_flags);
+    }
 
-	return remove_secret;
+    return remove_secret;
 }
 
 /**
@@ -2101,7 +2096,7 @@ _clear_secrets_by_secret_flags_cb (NMSetting *setting,
  * @self: the #NMConnection to filter (will be modified)
  * @filter_flags: the secret flags to control whether to drop/remove
  *   a secret or to keep it. The meaning of the filter flags is to
- *   preseve the secrets. The secrets that have matching (see below)
+ *   preserve the secrets. The secrets that have matching (see below)
  *   flags are kept, the others are dropped.
  *
  * Removes/drops secrets from @self according to @filter_flags.
@@ -2111,115 +2106,112 @@ _clear_secrets_by_secret_flags_cb (NMSetting *setting,
  * one of the filter flags.
  */
 void
-_nm_connection_clear_secrets_by_secret_flags (NMConnection *self,
-                                              NMSettingSecretFlags filter_flags)
+_nm_connection_clear_secrets_by_secret_flags(NMConnection *self, NMSettingSecretFlags filter_flags)
 {
-	nm_connection_clear_secrets_with_flags (self,
-	                                        _clear_secrets_by_secret_flags_cb,
-	                                        GUINT_TO_POINTER (filter_flags));
+    nm_connection_clear_secrets_with_flags(self,
+                                           _clear_secrets_by_secret_flags_cb,
+                                           GUINT_TO_POINTER(filter_flags));
 }
 
 /*****************************************************************************/
 
-
 /*****************************************************************************/
 
 /* Returns always a non-NULL, floating variant that must
  * be unrefed by the caller. */
 GVariant *
-_nm_connection_for_each_secret (NMConnection *self,
-                                GVariant *secrets,
-                                gboolean remove_non_secrets,
-                                _NMConnectionForEachSecretFunc callback,
-                                gpointer callback_data)
-{
-	GVariantBuilder secrets_builder;
-	GVariantBuilder setting_builder;
-	GVariantIter secrets_iter;
-	GVariantIter *setting_iter;
-	const char *setting_name;
-
-	/* This function, given a dict of dicts representing new secrets of
-	 * an NMConnection, walks through each toplevel dict (which represents a
-	 * NMSetting), and for each setting, walks through that setting dict's
-	 * properties.  For each property that's a secret, it will check that
-	 * secret's flags in the backing NMConnection object, and call a supplied
-	 * callback.
-	 *
-	 * The one complexity is that the VPN setting's 'secrets' property is
-	 * *also* a dict (since the key/value pairs are arbitrary and known
-	 * only to the VPN plugin itself).  That means we have three levels of
-	 * dicts that we potentially have to traverse here.  The differences
-	 * are handled by the virtual for_each_secret() function.
-	 */
-
-	g_return_val_if_fail (callback, NULL);
-
-	g_variant_iter_init (&secrets_iter, secrets);
-	g_variant_builder_init (&secrets_builder, NM_VARIANT_TYPE_CONNECTION);
-	while (g_variant_iter_next (&secrets_iter, "{&sa{sv}}", &setting_name, &setting_iter)) {
-		_nm_unused nm_auto_free_variant_iter GVariantIter *setting_iter_free = setting_iter;
-		NMSetting *setting;
-		const char *secret_name;
-		GVariant *val;
-
-		setting = nm_connection_get_setting_by_name (self, setting_name);
-		if (!setting)
-			continue;
-
-		g_variant_builder_init (&setting_builder, NM_VARIANT_TYPE_SETTING);
-		while (g_variant_iter_next (setting_iter, "{&sv}", &secret_name, &val)) {
-			_nm_unused gs_unref_variant GVariant *val_free = val;
-
-			NM_SETTING_GET_CLASS (setting)->for_each_secret (setting,
-			                                                 secret_name,
-			                                                 val,
-			                                                 remove_non_secrets,
-			                                                 callback,
-			                                                 callback_data,
-			                                                 &setting_builder);
-		}
-
-		g_variant_builder_add (&secrets_builder, "{sa{sv}}", setting_name, &setting_builder);
-	}
-
-	return g_variant_builder_end (&secrets_builder);
+_nm_connection_for_each_secret(NMConnection *                 self,
+                               GVariant *                     secrets,
+                               gboolean                       remove_non_secrets,
+                               _NMConnectionForEachSecretFunc callback,
+                               gpointer                       callback_data)
+{
+    GVariantBuilder secrets_builder;
+    GVariantBuilder setting_builder;
+    GVariantIter    secrets_iter;
+    GVariantIter *  setting_iter;
+    const char *    setting_name;
+
+    /* This function, given a dict of dicts representing new secrets of
+     * an NMConnection, walks through each toplevel dict (which represents a
+     * NMSetting), and for each setting, walks through that setting dict's
+     * properties.  For each property that's a secret, it will check that
+     * secret's flags in the backing NMConnection object, and call a supplied
+     * callback.
+     *
+     * The one complexity is that the VPN setting's 'secrets' property is
+     * *also* a dict (since the key/value pairs are arbitrary and known
+     * only to the VPN plugin itself).  That means we have three levels of
+     * dicts that we potentially have to traverse here.  The differences
+     * are handled by the virtual for_each_secret() function.
+     */
+
+    g_return_val_if_fail(callback, NULL);
+
+    g_variant_iter_init(&secrets_iter, secrets);
+    g_variant_builder_init(&secrets_builder, NM_VARIANT_TYPE_CONNECTION);
+    while (g_variant_iter_next(&secrets_iter, "{&sa{sv}}", &setting_name, &setting_iter)) {
+        _nm_unused nm_auto_free_variant_iter GVariantIter *setting_iter_free = setting_iter;
+        NMSetting *                                        setting;
+        const char *                                       secret_name;
+        GVariant *                                         val;
+
+        setting = nm_connection_get_setting_by_name(self, setting_name);
+        if (!setting)
+            continue;
+
+        g_variant_builder_init(&setting_builder, NM_VARIANT_TYPE_SETTING);
+        while (g_variant_iter_next(setting_iter, "{&sv}", &secret_name, &val)) {
+            _nm_unused gs_unref_variant GVariant *val_free = val;
+
+            NM_SETTING_GET_CLASS(setting)->for_each_secret(setting,
+                                                           secret_name,
+                                                           val,
+                                                           remove_non_secrets,
+                                                           callback,
+                                                           callback_data,
+                                                           &setting_builder);
+        }
+
+        g_variant_builder_add(&secrets_builder, "{sa{sv}}", setting_name, &setting_builder);
+    }
+
+    return g_variant_builder_end(&secrets_builder);
 }
 
 /*****************************************************************************/
 
 typedef struct {
-	NMConnectionFindSecretFunc find_func;
-	gpointer find_func_data;
-	gboolean found;
+    NMConnectionFindSecretFunc find_func;
+    gpointer                   find_func_data;
+    gboolean                   found;
 } FindSecretData;
 
 static gboolean
-find_secret_for_each_func (NMSettingSecretFlags flags,
-                           gpointer user_data)
+find_secret_for_each_func(NMSettingSecretFlags flags, gpointer user_data)
 {
-	FindSecretData *data = user_data;
+    FindSecretData *data = user_data;
 
-	if (!data->found)
-		data->found = data->find_func (flags, data->find_func_data);
-	return FALSE;
+    if (!data->found)
+        data->found = data->find_func(flags, data->find_func_data);
+    return FALSE;
 }
 
 gboolean
-_nm_connection_find_secret (NMConnection *self,
-                            GVariant *secrets,
-                            NMConnectionFindSecretFunc callback,
-                            gpointer callback_data)
+_nm_connection_find_secret(NMConnection *             self,
+                           GVariant *                 secrets,
+                           NMConnectionFindSecretFunc callback,
+                           gpointer                   callback_data)
 {
-	gs_unref_variant GVariant *dummy = NULL;
-	FindSecretData data = {
-		.find_func      = callback,
-		.find_func_data = callback_data,
-		.found          = FALSE,
-	};
+    gs_unref_variant GVariant *dummy = NULL;
+    FindSecretData             data  = {
+        .find_func      = callback,
+        .find_func_data = callback_data,
+        .found          = FALSE,
+    };
 
-	dummy = _nm_connection_for_each_secret (self, secrets, FALSE, find_secret_for_each_func, &data);
-	return data.found;
+    dummy = _nm_connection_for_each_secret(self, secrets, FALSE, find_secret_for_each_func, &data);
+    return data.found;
 }
 
 /*****************************************************************************/
@@ -2237,44 +2229,43 @@ _nm_connection_find_secret (NMConnection *self,
  * its settings, and each setting's properties.
  **/
 GVariant *
-nm_connection_to_dbus (NMConnection *connection,
-                       NMConnectionSerializationFlags flags)
+nm_connection_to_dbus(NMConnection *connection, NMConnectionSerializationFlags flags)
 {
-	return nm_connection_to_dbus_full (connection, flags, NULL);
+    return nm_connection_to_dbus_full(connection, flags, NULL);
 }
 
 GVariant *
-nm_connection_to_dbus_full (NMConnection *connection,
-                            NMConnectionSerializationFlags flags,
-                            const NMConnectionSerializationOptions *options)
+nm_connection_to_dbus_full(NMConnection *                          connection,
+                           NMConnectionSerializationFlags          flags,
+                           const NMConnectionSerializationOptions *options)
 {
-	GVariantBuilder builder;
-	gboolean any = FALSE;
-	gs_free NMSetting **settings = NULL;
-	guint settings_len;
-	guint i;
+    GVariantBuilder builder;
+    gboolean        any              = FALSE;
+    gs_free NMSetting **settings     = NULL;
+    guint               settings_len = 0;
+    guint               i;
 
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
 
-	settings = nm_connection_get_settings (connection, &settings_len);
-	for (i = 0; i < settings_len; i++) {
-		NMSetting *setting = settings[i];
-		GVariant *setting_dict;
+    settings = nm_connection_get_settings(connection, &settings_len);
+    for (i = 0; i < settings_len; i++) {
+        NMSetting *setting = settings[i];
+        GVariant * setting_dict;
 
-		setting_dict = _nm_setting_to_dbus (setting, connection, flags, options);
-		if (!setting_dict)
-			continue;
-		if (!any) {
-			any = TRUE;
-			g_variant_builder_init (&builder, NM_VARIANT_TYPE_CONNECTION);
-		}
-		g_variant_builder_add (&builder, "{s@a{sv}}", nm_setting_get_name (setting), setting_dict);
-	}
+        setting_dict = _nm_setting_to_dbus(setting, connection, flags, options);
+        if (!setting_dict)
+            continue;
+        if (!any) {
+            any = TRUE;
+            g_variant_builder_init(&builder, NM_VARIANT_TYPE_CONNECTION);
+        }
+        g_variant_builder_add(&builder, "{s@a{sv}}", nm_setting_get_name(setting), setting_dict);
+    }
 
-	if (!any)
-		return NULL;
+    if (!any)
+        return NULL;
 
-	return g_variant_builder_end (&builder);
+    return g_variant_builder_end(&builder);
 }
 
 /**
@@ -2290,29 +2281,29 @@ nm_connection_to_dbus_full (NMConnection *connection,
  * Returns: %TRUE if the connection is of the given @type, %FALSE if not
  **/
 gboolean
-nm_connection_is_type (NMConnection *connection, const char *type)
+nm_connection_is_type(NMConnection *connection, const char *type)
 {
-	g_return_val_if_fail (type, FALSE);
+    g_return_val_if_fail(type, FALSE);
 
-	return nm_streq0 (type, nm_connection_get_connection_type (connection));
+    return nm_streq0(type, nm_connection_get_connection_type(connection));
 }
 
 static int
-_get_settings_sort (gconstpointer p_a, gconstpointer p_b, gpointer unused)
+_get_settings_sort(gconstpointer p_a, gconstpointer p_b, gpointer unused)
 {
-	NMSetting *a = *((NMSetting **) p_a);
-	NMSetting *b = *((NMSetting **) p_b);
+    NMSetting *a = *((NMSetting **) p_a);
+    NMSetting *b = *((NMSetting **) p_b);
 
-	nm_assert (NM_IS_SETTING (a));
-	nm_assert (NM_IS_SETTING (b));
-	nm_assert (a != b);
-	nm_assert (G_OBJECT_TYPE (a) != G_OBJECT_TYPE (b));
+    nm_assert(NM_IS_SETTING(a));
+    nm_assert(NM_IS_SETTING(b));
+    nm_assert(a != b);
+    nm_assert(G_OBJECT_TYPE(a) != G_OBJECT_TYPE(b));
 
-	NM_CMP_RETURN (_nm_setting_compare_priority (a, b));
-	NM_CMP_DIRECT_STRCMP (nm_setting_get_name (a), nm_setting_get_name (b));
+    NM_CMP_RETURN(_nm_setting_compare_priority(a, b));
+    NM_CMP_DIRECT_STRCMP(nm_setting_get_name(a), nm_setting_get_name(b));
 
-	nm_assert_not_reached ();
-	return 0;
+    nm_assert_not_reached();
+    return 0;
 }
 
 /**
@@ -2332,15 +2323,15 @@ _get_settings_sort (gconstpointer p_a, gconstpointer p_b, gpointer unused)
  * Since: 1.10
  */
 NMSetting **
-nm_connection_get_settings (NMConnection *connection,
-                            guint *out_length)
+nm_connection_get_settings(NMConnection *connection, guint *out_length)
 {
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
 
-	return (NMSetting **) nm_utils_hash_values_to_array (NM_CONNECTION_GET_PRIVATE (connection)->settings,
-	                                                     _get_settings_sort,
-	                                                     NULL,
-	                                                     out_length);
+    return (NMSetting **) nm_utils_hash_values_to_array(
+        NM_CONNECTION_GET_PRIVATE(connection)->settings,
+        _get_settings_sort,
+        NULL,
+        out_length);
 }
 
 /**
@@ -2353,25 +2344,25 @@ nm_connection_get_settings (NMConnection *connection,
  * calling the supplied user function for each property.
  **/
 void
-nm_connection_for_each_setting_value (NMConnection *connection,
-                                      NMSettingValueIterFn func,
-                                      gpointer user_data)
+nm_connection_for_each_setting_value(NMConnection *       connection,
+                                     NMSettingValueIterFn func,
+                                     gpointer             user_data)
 {
-	gs_free NMSetting **settings = NULL;
-	guint i, length = 0;
+    gs_free NMSetting **settings = NULL;
+    guint               i, length = 0;
 
-	g_return_if_fail (NM_IS_CONNECTION (connection));
-	g_return_if_fail (func);
+    g_return_if_fail(NM_IS_CONNECTION(connection));
+    g_return_if_fail(func);
 
-	settings = nm_connection_get_settings (connection, &length);
-	for (i = 0; i < length; i++)
-		nm_setting_enumerate_values (settings[i], func, user_data);
+    settings = nm_connection_get_settings(connection, &length);
+    for (i = 0; i < length; i++)
+        nm_setting_enumerate_values(settings[i], func, user_data);
 }
 
 /**
  * _nm_connection_aggregate:
- * @connecition: the #NMConnection for which values are to be aggregated.
- * @type: one of the supported aggrate types.
+ * @connection: the #NMConnection for which values are to be aggregated.
+ * @type: one of the supported aggregate types.
  * @arg: the input/output argument that depends on @type.
  *
  * For example, with %NM_CONNECTION_AGGREGATE_ANY_SECRETS and
@@ -2385,54 +2376,51 @@ nm_connection_for_each_setting_value (NMConnection *connection,
  *   type @type.
  */
 gboolean
-_nm_connection_aggregate (NMConnection *connection,
-                          NMConnectionAggregateType type,
-                          gpointer arg)
-{
-	NMConnectionPrivate *priv;
-	GHashTableIter iter;
-	NMSetting *setting;
-	gboolean arg_boolean;
-	gboolean completed_early;
-	gpointer my_arg;
-
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
-
-	switch (type) {
-	case NM_CONNECTION_AGGREGATE_ANY_SECRETS:
-		arg_boolean = FALSE;
-		my_arg = &arg_boolean;
-		goto good;
-	case NM_CONNECTION_AGGREGATE_ANY_SYSTEM_SECRET_FLAGS:
-		arg_boolean = FALSE;
-		my_arg = &arg_boolean;
-		goto good;
-	}
-	g_return_val_if_reached (FALSE);
+_nm_connection_aggregate(NMConnection *connection, NMConnectionAggregateType type, gpointer arg)
+{
+    NMConnectionPrivate *priv;
+    GHashTableIter       iter;
+    NMSetting *          setting;
+    gboolean             arg_boolean;
+    gboolean             completed_early;
+    gpointer             my_arg;
+
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE);
+
+    switch (type) {
+    case NM_CONNECTION_AGGREGATE_ANY_SECRETS:
+        arg_boolean = FALSE;
+        my_arg      = &arg_boolean;
+        goto good;
+    case NM_CONNECTION_AGGREGATE_ANY_SYSTEM_SECRET_FLAGS:
+        arg_boolean = FALSE;
+        my_arg      = &arg_boolean;
+        goto good;
+    }
+    g_return_val_if_reached(FALSE);
 
 good:
-	priv = NM_CONNECTION_GET_PRIVATE (connection);
+    priv = NM_CONNECTION_GET_PRIVATE(connection);
 
-	completed_early = FALSE;
-	g_hash_table_iter_init (&iter, priv->settings);
-	while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) {
-		if (_nm_setting_aggregate (setting, type, my_arg)) {
-			completed_early = TRUE;
-			break;
-		}
-		nm_assert (   my_arg != &arg_boolean
-		           || !arg_boolean);
-	}
+    completed_early = FALSE;
+    g_hash_table_iter_init(&iter, priv->settings);
+    while (g_hash_table_iter_next(&iter, NULL, (gpointer) &setting)) {
+        if (_nm_setting_aggregate(setting, type, my_arg)) {
+            completed_early = TRUE;
+            break;
+        }
+        nm_assert(my_arg != &arg_boolean || !arg_boolean);
+    }
 
-	if (my_arg == &arg_boolean) {
-		nm_assert (completed_early == arg_boolean);
-		if (arg)
-			*((gboolean *) arg) = arg_boolean;
-		return arg_boolean;
-	}
+    if (my_arg == &arg_boolean) {
+        nm_assert(completed_early == arg_boolean);
+        if (arg)
+            *((gboolean *) arg) = arg_boolean;
+        return arg_boolean;
+    }
 
-	nm_assert_not_reached ();
-	return FALSE;
+    nm_assert_not_reached();
+    return FALSE;
 }
 
 /**
@@ -2445,21 +2433,21 @@ good:
  * be stable and may change at any time.
  **/
 void
-nm_connection_dump (NMConnection *connection)
+nm_connection_dump(NMConnection *connection)
 {
-	GHashTableIter iter;
-	NMSetting *setting;
-	char *str;
+    GHashTableIter iter;
+    NMSetting *    setting;
+    char *         str;
 
-	if (!connection)
-		return;
+    if (!connection)
+        return;
 
-	g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
-	while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) {
-		str = nm_setting_to_string (setting);
-		g_print ("%s\n", str);
-		g_free (str);
-	}
+    g_hash_table_iter_init(&iter, NM_CONNECTION_GET_PRIVATE(connection)->settings);
+    while (g_hash_table_iter_next(&iter, NULL, (gpointer) &setting)) {
+        str = nm_setting_to_string(setting);
+        g_print("%s\n", str);
+        g_free(str);
+    }
 }
 
 /**
@@ -2473,16 +2461,16 @@ nm_connection_dump (NMConnection *connection)
  * property.
  **/
 void
-nm_connection_set_path (NMConnection *connection, const char *path)
+nm_connection_set_path(NMConnection *connection, const char *path)
 {
-	NMConnectionPrivate *priv;
+    NMConnectionPrivate *priv;
 
-	g_return_if_fail (NM_IS_CONNECTION (connection));
+    g_return_if_fail(NM_IS_CONNECTION(connection));
 
-	priv = NM_CONNECTION_GET_PRIVATE (connection);
+    priv = NM_CONNECTION_GET_PRIVATE(connection);
 
-	g_free (priv->path);
-	priv->path = g_strdup (path);
+    g_free(priv->path);
+    priv->path = g_strdup(path);
 }
 
 /**
@@ -2495,11 +2483,11 @@ nm_connection_set_path (NMConnection *connection, const char *path)
  * nm_connection_set_path().
  **/
 const char *
-nm_connection_get_path (NMConnection *connection)
+nm_connection_get_path(NMConnection *connection)
 {
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
 
-	return NM_CONNECTION_GET_PRIVATE (connection)->path;
+    return NM_CONNECTION_GET_PRIVATE(connection)->path;
 }
 
 /**
@@ -2516,59 +2504,59 @@ nm_connection_get_path (NMConnection *connection)
  * Returns: Name of the kernel interface or %NULL
  */
 const char *
-nm_connection_get_interface_name (NMConnection *connection)
+nm_connection_get_interface_name(NMConnection *connection)
 {
-	NMSettingConnection *s_con;
+    NMSettingConnection *s_con;
 
-	s_con = nm_connection_get_setting_connection (connection);
-	return s_con ? nm_setting_connection_get_interface_name (s_con) : NULL;
+    s_con = nm_connection_get_setting_connection(connection);
+    return s_con ? nm_setting_connection_get_interface_name(s_con) : NULL;
 }
 
 NMConnectionMultiConnect
-_nm_connection_get_multi_connect (NMConnection *connection)
+_nm_connection_get_multi_connect(NMConnection *connection)
 {
-	NMSettingConnection *s_con;
-	NMConnectionMultiConnect multi_connect;
-	const NMConnectionMultiConnect DEFAULT = NM_CONNECTION_MULTI_CONNECT_SINGLE;
+    NMSettingConnection *          s_con;
+    NMConnectionMultiConnect       multi_connect;
+    const NMConnectionMultiConnect DEFAULT = NM_CONNECTION_MULTI_CONNECT_SINGLE;
 
-	/* connection.multi_connect property cannot be specified via regular
-	 * connection defaults in NetworkManager.conf, because those are per-device,
-	 * and we need to determine the multi_connect independent of a particular
-	 * device.
-	 *
-	 * There is however still a default-value, so theoretically, the default
-	 * value could be specified in NetworkManager.conf. Just not as [connection*]
-	 * and indepdented of a device. */
+    /* connection.multi_connect property cannot be specified via regular
+     * connection defaults in NetworkManager.conf, because those are per-device,
+     * and we need to determine the multi_connect independent of a particular
+     * device.
+     *
+     * There is however still a default-value, so theoretically, the default
+     * value could be specified in NetworkManager.conf. Just not as [connection*]
+     * and indepdented of a device. */
 
-	s_con = nm_connection_get_setting_connection (connection);
-	if (!s_con)
-		return DEFAULT;
+    s_con = nm_connection_get_setting_connection(connection);
+    if (!s_con)
+        return DEFAULT;
 
-	multi_connect = nm_setting_connection_get_multi_connect (s_con);
-	return multi_connect == NM_CONNECTION_MULTI_CONNECT_DEFAULT
-	       ? DEFAULT
-	       : multi_connect;
+    multi_connect = nm_setting_connection_get_multi_connect(s_con);
+    return multi_connect == NM_CONNECTION_MULTI_CONNECT_DEFAULT ? DEFAULT : multi_connect;
 }
 
 gboolean
-_nm_connection_verify_required_interface_name (NMConnection *connection,
-                                               GError **error)
+_nm_connection_verify_required_interface_name(NMConnection *connection, GError **error)
 {
-	const char *interface_name;
+    const char *interface_name;
 
-	if (!connection)
-		return TRUE;
+    if (!connection)
+        return TRUE;
 
-	interface_name = nm_connection_get_interface_name (connection);
-	if (interface_name)
-		return TRUE;
+    interface_name = nm_connection_get_interface_name(connection);
+    if (interface_name)
+        return TRUE;
 
-	g_set_error_literal (error,
-	                     NM_CONNECTION_ERROR,
-	                     NM_CONNECTION_ERROR_MISSING_PROPERTY,
-	                     _("property is missing"));
-	g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
-	return FALSE;
+    g_set_error_literal(error,
+                        NM_CONNECTION_ERROR,
+                        NM_CONNECTION_ERROR_MISSING_PROPERTY,
+                        _("property is missing"));
+    g_prefix_error(error,
+                   "%s.%s: ",
+                   NM_SETTING_CONNECTION_SETTING_NAME,
+                   NM_SETTING_CONNECTION_INTERFACE_NAME);
+    return FALSE;
 }
 
 /**
@@ -2580,12 +2568,12 @@ _nm_connection_verify_required_interface_name (NMConnection *connection,
  * Returns: the UUID from the connection's 'connection' setting
  **/
 const char *
-nm_connection_get_uuid (NMConnection *connection)
+nm_connection_get_uuid(NMConnection *connection)
 {
-	NMSettingConnection *s_con;
+    NMSettingConnection *s_con;
 
-	s_con = nm_connection_get_setting_connection (connection);
-	return s_con ? nm_setting_connection_get_uuid (s_con) : NULL;
+    s_con = nm_connection_get_setting_connection(connection);
+    return s_con ? nm_setting_connection_get_uuid(s_con) : NULL;
 }
 
 /**
@@ -2597,12 +2585,12 @@ nm_connection_get_uuid (NMConnection *connection)
  * Returns: the ID from the connection's 'connection' setting
  **/
 const char *
-nm_connection_get_id (NMConnection *connection)
+nm_connection_get_id(NMConnection *connection)
 {
-	NMSettingConnection *s_con;
+    NMSettingConnection *s_con;
 
-	s_con = nm_connection_get_setting_connection (connection);
-	return s_con ? nm_setting_connection_get_id (s_con) : NULL;
+    s_con = nm_connection_get_setting_connection(connection);
+    return s_con ? nm_setting_connection_get_id(s_con) : NULL;
 }
 
 /**
@@ -2614,12 +2602,12 @@ nm_connection_get_id (NMConnection *connection)
  * Returns: the type from the connection's 'connection' setting
  **/
 const char *
-nm_connection_get_connection_type (NMConnection *connection)
+nm_connection_get_connection_type(NMConnection *connection)
 {
-	NMSettingConnection *s_con;
+    NMSettingConnection *s_con;
 
-	s_con = nm_connection_get_setting_connection (connection);
-	return s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
+    s_con = nm_connection_get_setting_connection(connection);
+    return s_con ? nm_setting_connection_get_connection_type(s_con) : NULL;
 }
 
 /**
@@ -2632,50 +2620,51 @@ nm_connection_get_connection_type (NMConnection *connection)
  * Returns: whether @connection refers to a virtual device
  */
 gboolean
-nm_connection_is_virtual (NMConnection *connection)
+nm_connection_is_virtual(NMConnection *connection)
 {
-	const char *type;
+    const char *type;
 
-	type = nm_connection_get_connection_type (connection);
-	if (!type)
-		return FALSE;
+    type = nm_connection_get_connection_type(connection);
+    if (!type)
+        return FALSE;
 
-	if (NM_IN_STRSET (type, NM_SETTING_6LOWPAN_SETTING_NAME,
-	                        NM_SETTING_BOND_SETTING_NAME,
-	                        NM_SETTING_BRIDGE_SETTING_NAME,
-	                        NM_SETTING_DUMMY_SETTING_NAME,
-	                        NM_SETTING_IP_TUNNEL_SETTING_NAME,
-	                        NM_SETTING_MACSEC_SETTING_NAME,
-	                        NM_SETTING_MACVLAN_SETTING_NAME,
-	                        NM_SETTING_OVS_BRIDGE_SETTING_NAME,
-	                        NM_SETTING_OVS_INTERFACE_SETTING_NAME,
-	                        NM_SETTING_OVS_PORT_SETTING_NAME,
-	                        NM_SETTING_TEAM_SETTING_NAME,
-	                        NM_SETTING_TUN_SETTING_NAME,
-	                        NM_SETTING_VLAN_SETTING_NAME,
-	                        NM_SETTING_VRF_SETTING_NAME,
-	                        NM_SETTING_VXLAN_SETTING_NAME,
-	                        NM_SETTING_WIREGUARD_SETTING_NAME))
-		return TRUE;
+    if (NM_IN_STRSET(type,
+                     NM_SETTING_6LOWPAN_SETTING_NAME,
+                     NM_SETTING_BOND_SETTING_NAME,
+                     NM_SETTING_BRIDGE_SETTING_NAME,
+                     NM_SETTING_DUMMY_SETTING_NAME,
+                     NM_SETTING_IP_TUNNEL_SETTING_NAME,
+                     NM_SETTING_MACSEC_SETTING_NAME,
+                     NM_SETTING_MACVLAN_SETTING_NAME,
+                     NM_SETTING_OVS_BRIDGE_SETTING_NAME,
+                     NM_SETTING_OVS_INTERFACE_SETTING_NAME,
+                     NM_SETTING_OVS_PORT_SETTING_NAME,
+                     NM_SETTING_TEAM_SETTING_NAME,
+                     NM_SETTING_TUN_SETTING_NAME,
+                     NM_SETTING_VLAN_SETTING_NAME,
+                     NM_SETTING_VRF_SETTING_NAME,
+                     NM_SETTING_VXLAN_SETTING_NAME,
+                     NM_SETTING_WIREGUARD_SETTING_NAME))
+        return TRUE;
 
-	if (nm_streq (type, NM_SETTING_INFINIBAND_SETTING_NAME)) {
-		NMSettingInfiniband *s_ib;
+    if (nm_streq(type, NM_SETTING_INFINIBAND_SETTING_NAME)) {
+        NMSettingInfiniband *s_ib;
 
-		s_ib = nm_connection_get_setting_infiniband (connection);
-		return s_ib && nm_setting_infiniband_get_virtual_interface_name (s_ib);
-	}
+        s_ib = nm_connection_get_setting_infiniband(connection);
+        return s_ib && nm_setting_infiniband_get_virtual_interface_name(s_ib);
+    }
 
-	if (nm_streq (type, NM_SETTING_BLUETOOTH_SETTING_NAME))
-		return !!_nm_connection_get_setting_bluetooth_for_nap (connection);
+    if (nm_streq(type, NM_SETTING_BLUETOOTH_SETTING_NAME))
+        return !!_nm_connection_get_setting_bluetooth_for_nap(connection);
 
-	if (nm_streq (type, NM_SETTING_PPPOE_SETTING_NAME)) {
-		NMSettingPppoe *s_pppoe;
+    if (nm_streq(type, NM_SETTING_PPPOE_SETTING_NAME)) {
+        NMSettingPppoe *s_pppoe;
 
-		s_pppoe = nm_connection_get_setting_pppoe (connection);
-		return !!nm_setting_pppoe_get_parent (s_pppoe);
-	}
+        s_pppoe = nm_connection_get_setting_pppoe(connection);
+        return !!nm_setting_pppoe_get_parent(s_pppoe);
+    }
 
-	return FALSE;
+    return FALSE;
 }
 
 /**
@@ -2690,35 +2679,36 @@ nm_connection_is_virtual (NMConnection *connection)
  *   or %NULL if @connection is not a virtual connection type
  */
 char *
-nm_connection_get_virtual_device_description (NMConnection *connection)
+nm_connection_get_virtual_device_description(NMConnection *connection)
 {
-	const char *type;
-	const char *iface = NULL, *display_type = NULL;
+    const char *type;
+    const char *iface = NULL, *display_type = NULL;
 
-	type = nm_connection_get_connection_type (connection);
-	if (!type)
-		return NULL;
+    type = nm_connection_get_connection_type(connection);
+    if (!type)
+        return NULL;
 
-	iface = nm_connection_get_interface_name (connection);
+    iface = nm_connection_get_interface_name(connection);
 
-	if (!strcmp (type, NM_SETTING_BOND_SETTING_NAME))
-		display_type = _("Bond");
-	else if (!strcmp (type, NM_SETTING_TEAM_SETTING_NAME))
-		display_type = _("Team");
-	else if (!strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME))
-		display_type = _("Bridge");
-	else if (!strcmp (type, NM_SETTING_VLAN_SETTING_NAME))
-		display_type = _("VLAN");
-	else if (!strcmp (type, NM_SETTING_INFINIBAND_SETTING_NAME)) {
-		display_type = _("InfiniBand");
-		iface = nm_setting_infiniband_get_virtual_interface_name (nm_connection_get_setting_infiniband (connection));
-	} else if (!strcmp (type, NM_SETTING_IP_TUNNEL_SETTING_NAME))
-		display_type = _("IP Tunnel");
+    if (!strcmp(type, NM_SETTING_BOND_SETTING_NAME))
+        display_type = _("Bond");
+    else if (!strcmp(type, NM_SETTING_TEAM_SETTING_NAME))
+        display_type = _("Team");
+    else if (!strcmp(type, NM_SETTING_BRIDGE_SETTING_NAME))
+        display_type = _("Bridge");
+    else if (!strcmp(type, NM_SETTING_VLAN_SETTING_NAME))
+        display_type = _("VLAN");
+    else if (!strcmp(type, NM_SETTING_INFINIBAND_SETTING_NAME)) {
+        display_type = _("InfiniBand");
+        iface        = nm_setting_infiniband_get_virtual_interface_name(
+            nm_connection_get_setting_infiniband(connection));
+    } else if (!strcmp(type, NM_SETTING_IP_TUNNEL_SETTING_NAME))
+        display_type = _("IP Tunnel");
 
-	if (!iface || !display_type)
-		return NULL;
+    if (!iface || !display_type)
+        return NULL;
 
-	return g_strdup_printf ("%s (%s)", display_type, iface);
+    return g_strdup_printf("%s (%s)", display_type, iface);
 }
 
 /*****************************************************************************/
@@ -2732,9 +2722,9 @@ nm_connection_get_virtual_device_description (NMConnection *connection)
  * Returns: (transfer none): an #NMSetting8021x if the connection contains one, otherwise %NULL
  **/
 NMSetting8021x *
-nm_connection_get_setting_802_1x (NMConnection *connection)
+nm_connection_get_setting_802_1x(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_802_1X);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_802_1X);
 }
 
 /**
@@ -2746,9 +2736,9 @@ nm_connection_get_setting_802_1x (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingBluetooth if the connection contains one, otherwise %NULL
  **/
 NMSettingBluetooth *
-nm_connection_get_setting_bluetooth (NMConnection *connection)
+nm_connection_get_setting_bluetooth(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_BLUETOOTH);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_BLUETOOTH);
 }
 
 /**
@@ -2760,9 +2750,9 @@ nm_connection_get_setting_bluetooth (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingBond if the connection contains one, otherwise %NULL
  **/
 NMSettingBond *
-nm_connection_get_setting_bond (NMConnection *connection)
+nm_connection_get_setting_bond(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_BOND);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_BOND);
 }
 
 /**
@@ -2774,9 +2764,9 @@ nm_connection_get_setting_bond (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingTeam if the connection contains one, otherwise %NULL
  **/
 NMSettingTeam *
-nm_connection_get_setting_team (NMConnection *connection)
+nm_connection_get_setting_team(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_TEAM);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_TEAM);
 }
 
 /**
@@ -2788,9 +2778,9 @@ nm_connection_get_setting_team (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingTeamPort if the connection contains one, otherwise %NULL
  **/
 NMSettingTeamPort *
-nm_connection_get_setting_team_port (NMConnection *connection)
+nm_connection_get_setting_team_port(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_TEAM_PORT);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_TEAM_PORT);
 }
 
 /**
@@ -2802,9 +2792,9 @@ nm_connection_get_setting_team_port (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingBridge if the connection contains one, otherwise %NULL
  **/
 NMSettingBridge *
-nm_connection_get_setting_bridge (NMConnection *connection)
+nm_connection_get_setting_bridge(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_BRIDGE);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_BRIDGE);
 }
 
 /**
@@ -2816,9 +2806,9 @@ nm_connection_get_setting_bridge (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingCdma if the connection contains one, otherwise %NULL
  **/
 NMSettingCdma *
-nm_connection_get_setting_cdma (NMConnection *connection)
+nm_connection_get_setting_cdma(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_CDMA);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_CDMA);
 }
 
 /**
@@ -2830,9 +2820,9 @@ nm_connection_get_setting_cdma (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingConnection if the connection contains one, otherwise %NULL
  **/
 NMSettingConnection *
-nm_connection_get_setting_connection (NMConnection *connection)
+nm_connection_get_setting_connection(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_CONNECTION);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_CONNECTION);
 }
 
 /**
@@ -2844,9 +2834,9 @@ nm_connection_get_setting_connection (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingDcb if the connection contains one, otherwise NULL
  **/
 NMSettingDcb *
-nm_connection_get_setting_dcb (NMConnection *connection)
+nm_connection_get_setting_dcb(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_DCB);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_DCB);
 }
 
 /**
@@ -2860,9 +2850,9 @@ nm_connection_get_setting_dcb (NMConnection *connection)
  * Since: 1.8
  **/
 NMSettingDummy *
-nm_connection_get_setting_dummy (NMConnection *connection)
+nm_connection_get_setting_dummy(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_DUMMY);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_DUMMY);
 }
 
 /**
@@ -2874,9 +2864,9 @@ nm_connection_get_setting_dummy (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingGeneric if the connection contains one, otherwise NULL
  **/
 NMSettingGeneric *
-nm_connection_get_setting_generic (NMConnection *connection)
+nm_connection_get_setting_generic(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_GENERIC);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_GENERIC);
 }
 
 /**
@@ -2888,9 +2878,9 @@ nm_connection_get_setting_generic (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingGsm if the connection contains one, otherwise %NULL
  **/
 NMSettingGsm *
-nm_connection_get_setting_gsm (NMConnection *connection)
+nm_connection_get_setting_gsm(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_GSM);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_GSM);
 }
 
 /**
@@ -2902,9 +2892,9 @@ nm_connection_get_setting_gsm (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingInfiniband if the connection contains one, otherwise %NULL
  **/
 NMSettingInfiniband *
-nm_connection_get_setting_infiniband (NMConnection *connection)
+nm_connection_get_setting_infiniband(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_INFINIBAND);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_INFINIBAND);
 }
 
 /**
@@ -2921,9 +2911,9 @@ nm_connection_get_setting_infiniband (NMConnection *connection)
  * connection contains one, otherwise %NULL
  **/
 NMSettingIPConfig *
-nm_connection_get_setting_ip4_config (NMConnection *connection)
+nm_connection_get_setting_ip4_config(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_IP4_CONFIG);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_IP4_CONFIG);
 }
 
 /**
@@ -2937,9 +2927,9 @@ nm_connection_get_setting_ip4_config (NMConnection *connection)
  * Since: 1.2
  **/
 NMSettingIPTunnel *
-nm_connection_get_setting_ip_tunnel (NMConnection *connection)
+nm_connection_get_setting_ip_tunnel(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_IP_TUNNEL);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_IP_TUNNEL);
 }
 
 /**
@@ -2956,9 +2946,9 @@ nm_connection_get_setting_ip_tunnel (NMConnection *connection)
  * connection contains one, otherwise %NULL
  **/
 NMSettingIPConfig *
-nm_connection_get_setting_ip6_config (NMConnection *connection)
+nm_connection_get_setting_ip6_config(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_IP6_CONFIG);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_IP6_CONFIG);
 }
 
 /**
@@ -2972,9 +2962,9 @@ nm_connection_get_setting_ip6_config (NMConnection *connection)
  * Since: 1.6
  **/
 NMSettingMacsec *
-nm_connection_get_setting_macsec (NMConnection *connection)
+nm_connection_get_setting_macsec(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_MACSEC);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_MACSEC);
 }
 
 /**
@@ -2988,9 +2978,9 @@ nm_connection_get_setting_macsec (NMConnection *connection)
  * Since: 1.2
  **/
 NMSettingMacvlan *
-nm_connection_get_setting_macvlan (NMConnection *connection)
+nm_connection_get_setting_macvlan(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_MACVLAN);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_MACVLAN);
 }
 
 /**
@@ -3002,9 +2992,9 @@ nm_connection_get_setting_macvlan (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingOlpcMesh if the connection contains one, otherwise %NULL
  **/
 NMSettingOlpcMesh *
-nm_connection_get_setting_olpc_mesh (NMConnection *connection)
+nm_connection_get_setting_olpc_mesh(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_OLPC_MESH);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_OLPC_MESH);
 }
 
 /**
@@ -3018,9 +3008,9 @@ nm_connection_get_setting_olpc_mesh (NMConnection *connection)
  * Since: 1.10
  **/
 NMSettingOvsBridge *
-nm_connection_get_setting_ovs_bridge (NMConnection *connection)
+nm_connection_get_setting_ovs_bridge(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_OVS_BRIDGE);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_OVS_BRIDGE);
 }
 
 /**
@@ -3034,9 +3024,9 @@ nm_connection_get_setting_ovs_bridge (NMConnection *connection)
  * Since: 1.10
  **/
 NMSettingOvsInterface *
-nm_connection_get_setting_ovs_interface (NMConnection *connection)
+nm_connection_get_setting_ovs_interface(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_OVS_INTERFACE);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_OVS_INTERFACE);
 }
 
 /**
@@ -3050,9 +3040,9 @@ nm_connection_get_setting_ovs_interface (NMConnection *connection)
  * Since: 1.10
  **/
 NMSettingOvsPatch *
-nm_connection_get_setting_ovs_patch (NMConnection *connection)
+nm_connection_get_setting_ovs_patch(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_OVS_PATCH);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_OVS_PATCH);
 }
 
 /**
@@ -3066,9 +3056,9 @@ nm_connection_get_setting_ovs_patch (NMConnection *connection)
  * Since: 1.10
  **/
 NMSettingOvsPort *
-nm_connection_get_setting_ovs_port (NMConnection *connection)
+nm_connection_get_setting_ovs_port(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_OVS_PORT);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_OVS_PORT);
 }
 
 /**
@@ -3080,9 +3070,9 @@ nm_connection_get_setting_ovs_port (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingPpp if the connection contains one, otherwise %NULL
  **/
 NMSettingPpp *
-nm_connection_get_setting_ppp (NMConnection *connection)
+nm_connection_get_setting_ppp(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_PPP);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_PPP);
 }
 
 /**
@@ -3094,9 +3084,9 @@ nm_connection_get_setting_ppp (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingPppoe if the connection contains one, otherwise %NULL
  **/
 NMSettingPppoe *
-nm_connection_get_setting_pppoe (NMConnection *connection)
+nm_connection_get_setting_pppoe(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_PPPOE);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_PPPOE);
 }
 
 /**
@@ -3110,9 +3100,9 @@ nm_connection_get_setting_pppoe (NMConnection *connection)
  * Since: 1.6
  **/
 NMSettingProxy *
-nm_connection_get_setting_proxy (NMConnection *connection)
+nm_connection_get_setting_proxy(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_PROXY);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_PROXY);
 }
 
 /**
@@ -3124,9 +3114,9 @@ nm_connection_get_setting_proxy (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingSerial if the connection contains one, otherwise %NULL
  **/
 NMSettingSerial *
-nm_connection_get_setting_serial (NMConnection *connection)
+nm_connection_get_setting_serial(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_SERIAL);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_SERIAL);
 }
 
 /**
@@ -3140,9 +3130,9 @@ nm_connection_get_setting_serial (NMConnection *connection)
  * Since: 1.12
  **/
 NMSettingTCConfig *
-nm_connection_get_setting_tc_config (NMConnection *connection)
+nm_connection_get_setting_tc_config(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_TC_CONFIG);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_TC_CONFIG);
 }
 
 /**
@@ -3156,9 +3146,9 @@ nm_connection_get_setting_tc_config (NMConnection *connection)
  * Since: 1.2
  **/
 NMSettingTun *
-nm_connection_get_setting_tun (NMConnection *connection)
+nm_connection_get_setting_tun(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_TUN);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_TUN);
 }
 
 /**
@@ -3170,9 +3160,9 @@ nm_connection_get_setting_tun (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingVpn if the connection contains one, otherwise %NULL
  **/
 NMSettingVpn *
-nm_connection_get_setting_vpn (NMConnection *connection)
+nm_connection_get_setting_vpn(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_VPN);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_VPN);
 }
 
 /**
@@ -3186,9 +3176,9 @@ nm_connection_get_setting_vpn (NMConnection *connection)
  * Since: 1.2
  **/
 NMSettingVxlan *
-nm_connection_get_setting_vxlan (NMConnection *connection)
+nm_connection_get_setting_vxlan(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_VXLAN);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_VXLAN);
 }
 
 /**
@@ -3200,9 +3190,9 @@ nm_connection_get_setting_vxlan (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingWimax if the connection contains one, otherwise %NULL
  **/
 NMSettingWimax *
-nm_connection_get_setting_wimax (NMConnection *connection)
+nm_connection_get_setting_wimax(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_WIMAX);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_WIMAX);
 }
 
 /**
@@ -3214,9 +3204,9 @@ nm_connection_get_setting_wimax (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingWired if the connection contains one, otherwise %NULL
  **/
 NMSettingWired *
-nm_connection_get_setting_wired (NMConnection *connection)
+nm_connection_get_setting_wired(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_WIRED);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_WIRED);
 }
 
 /**
@@ -3228,9 +3218,9 @@ nm_connection_get_setting_wired (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingAdsl if the connection contains one, otherwise %NULL
  **/
 NMSettingAdsl *
-nm_connection_get_setting_adsl (NMConnection *connection)
+nm_connection_get_setting_adsl(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_ADSL);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_ADSL);
 }
 
 /**
@@ -3242,9 +3232,9 @@ nm_connection_get_setting_adsl (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingWireless if the connection contains one, otherwise %NULL
  **/
 NMSettingWireless *
-nm_connection_get_setting_wireless (NMConnection *connection)
+nm_connection_get_setting_wireless(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_WIRELESS);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_WIRELESS);
 }
 
 /**
@@ -3256,9 +3246,9 @@ nm_connection_get_setting_wireless (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingWirelessSecurity if the connection contains one, otherwise %NULL
  **/
 NMSettingWirelessSecurity *
-nm_connection_get_setting_wireless_security (NMConnection *connection)
+nm_connection_get_setting_wireless_security(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
 }
 
 /**
@@ -3270,9 +3260,9 @@ nm_connection_get_setting_wireless_security (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingBridgePort if the connection contains one, otherwise %NULL
  **/
 NMSettingBridgePort *
-nm_connection_get_setting_bridge_port (NMConnection *connection)
+nm_connection_get_setting_bridge_port(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_BRIDGE_PORT);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_BRIDGE_PORT);
 }
 
 /**
@@ -3284,114 +3274,116 @@ nm_connection_get_setting_bridge_port (NMConnection *connection)
  * Returns: (transfer none): an #NMSettingVlan if the connection contains one, otherwise %NULL
  **/
 NMSettingVlan *
-nm_connection_get_setting_vlan (NMConnection *connection)
+nm_connection_get_setting_vlan(NMConnection *connection)
 {
-	return _connection_get_setting_check (connection, NM_TYPE_SETTING_VLAN);
+    return _connection_get_setting_check(connection, NM_TYPE_SETTING_VLAN);
 }
 
 NMSettingBluetooth *
-_nm_connection_get_setting_bluetooth_for_nap (NMConnection *connection)
+_nm_connection_get_setting_bluetooth_for_nap(NMConnection *connection)
 {
-	NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth (connection);
+    NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth(connection);
 
-	if (   s_bt
-	    && nm_streq0 (nm_setting_bluetooth_get_connection_type (s_bt), NM_SETTING_BLUETOOTH_TYPE_NAP))
-		return s_bt;
-	return NULL;
+    if (s_bt
+        && nm_streq0(nm_setting_bluetooth_get_connection_type(s_bt), NM_SETTING_BLUETOOTH_TYPE_NAP))
+        return s_bt;
+    return NULL;
 }
 
 /*****************************************************************************/
 
 static void
-nm_connection_private_free (NMConnectionPrivate *priv)
+nm_connection_private_free(NMConnectionPrivate *priv)
 {
-	NMConnection *self = priv->self;
+    NMConnection *self = priv->self;
 
-	g_hash_table_foreach_remove (priv->settings, _setting_release_hfr, self);
-	g_hash_table_destroy (priv->settings);
-	g_free (priv->path);
+    g_hash_table_foreach_remove(priv->settings, _setting_release_hfr, self);
+    g_hash_table_destroy(priv->settings);
+    g_free(priv->path);
 
-	g_slice_free (NMConnectionPrivate, priv);
+    g_slice_free(NMConnectionPrivate, priv);
 }
 
 static NMConnectionPrivate *
-nm_connection_get_private (NMConnection *connection)
+nm_connection_get_private(NMConnection *connection)
 {
-	GQuark key;
-	NMConnectionPrivate *priv;
+    GQuark               key;
+    NMConnectionPrivate *priv;
 
-	nm_assert (NM_IS_CONNECTION (connection));
+    nm_assert(NM_IS_CONNECTION(connection));
 
-	key = NM_CACHED_QUARK ("NMConnectionPrivate");
+    key = NM_CACHED_QUARK("NMConnectionPrivate");
 
-	priv = g_object_get_qdata ((GObject *) connection, key);
-	if (G_UNLIKELY (!priv)) {
-		priv = g_slice_new0 (NMConnectionPrivate);
-		g_object_set_qdata_full ((GObject *) connection, key,
-		                         priv, (GDestroyNotify) nm_connection_private_free);
+    priv = g_object_get_qdata((GObject *) connection, key);
+    if (G_UNLIKELY(!priv)) {
+        priv = g_slice_new0(NMConnectionPrivate);
+        g_object_set_qdata_full((GObject *) connection,
+                                key,
+                                priv,
+                                (GDestroyNotify) nm_connection_private_free);
 
-		priv->self = connection;
-		priv->settings = g_hash_table_new_full (nm_direct_hash,
-		                                        NULL,
-		                                        NULL,
-		                                        g_object_unref);
-	}
+        priv->self     = connection;
+        priv->settings = g_hash_table_new_full(nm_direct_hash, NULL, NULL, g_object_unref);
+    }
 
-	return priv;
+    return priv;
 }
 
 static void
-nm_connection_default_init (NMConnectionInterface *iface)
-{
-	/**
-	 * NMConnection::secrets-updated:
-	 * @connection: the object on which the signal is emitted
-	 * @setting_name: the setting name of the #NMSetting for which secrets were
-	 * updated
-	 *
-	 * The ::secrets-updated signal is emitted when the secrets of a setting
-	 * have been changed.
-	 */
-	signals[SECRETS_UPDATED] =
-	    g_signal_new (NM_CONNECTION_SECRETS_UPDATED,
-	                  NM_TYPE_CONNECTION,
-	                  G_SIGNAL_RUN_FIRST,
-	                  G_STRUCT_OFFSET (NMConnectionInterface, secrets_updated),
-	                  NULL, NULL,
-	                  g_cclosure_marshal_VOID__STRING,
-	                  G_TYPE_NONE, 1,
-	                  G_TYPE_STRING);
-
-	/**
-	 * NMConnection::secrets-cleared:
-	 * @connection: the object on which the signal is emitted
-	 *
-	 * The ::secrets-cleared signal is emitted when the secrets of a connection
-	 * are cleared.
-	 */
-	signals[SECRETS_CLEARED] =
-	    g_signal_new (NM_CONNECTION_SECRETS_CLEARED,
-	                  NM_TYPE_CONNECTION,
-	                  G_SIGNAL_RUN_FIRST,
-	                  G_STRUCT_OFFSET (NMConnectionInterface, secrets_cleared),
-	                  NULL, NULL,
-	                  g_cclosure_marshal_VOID__VOID,
-	                  G_TYPE_NONE, 0);
-
-	/**
-	 * NMConnection::changed:
-	 * @connection: the object on which the signal is emitted
-	 *
-	 * The ::changed signal is emitted when any property of any property
-	 * (including secrets) of any setting of the connection is modified,
-	 * or when settings are added or removed.
-	 */
-	signals[CHANGED] =
-	    g_signal_new (NM_CONNECTION_CHANGED,
-	                  NM_TYPE_CONNECTION,
-	                  G_SIGNAL_RUN_FIRST,
-	                  G_STRUCT_OFFSET (NMConnectionInterface, changed),
-	                  NULL, NULL,
-	                  g_cclosure_marshal_VOID__VOID,
-	                  G_TYPE_NONE, 0);
+nm_connection_default_init(NMConnectionInterface *iface)
+{
+    /**
+     * NMConnection::secrets-updated:
+     * @connection: the object on which the signal is emitted
+     * @setting_name: the setting name of the #NMSetting for which secrets were
+     * updated
+     *
+     * The ::secrets-updated signal is emitted when the secrets of a setting
+     * have been changed.
+     */
+    signals[SECRETS_UPDATED] = g_signal_new(NM_CONNECTION_SECRETS_UPDATED,
+                                            NM_TYPE_CONNECTION,
+                                            G_SIGNAL_RUN_FIRST,
+                                            G_STRUCT_OFFSET(NMConnectionInterface, secrets_updated),
+                                            NULL,
+                                            NULL,
+                                            g_cclosure_marshal_VOID__STRING,
+                                            G_TYPE_NONE,
+                                            1,
+                                            G_TYPE_STRING);
+
+    /**
+     * NMConnection::secrets-cleared:
+     * @connection: the object on which the signal is emitted
+     *
+     * The ::secrets-cleared signal is emitted when the secrets of a connection
+     * are cleared.
+     */
+    signals[SECRETS_CLEARED] = g_signal_new(NM_CONNECTION_SECRETS_CLEARED,
+                                            NM_TYPE_CONNECTION,
+                                            G_SIGNAL_RUN_FIRST,
+                                            G_STRUCT_OFFSET(NMConnectionInterface, secrets_cleared),
+                                            NULL,
+                                            NULL,
+                                            g_cclosure_marshal_VOID__VOID,
+                                            G_TYPE_NONE,
+                                            0);
+
+    /**
+     * NMConnection::changed:
+     * @connection: the object on which the signal is emitted
+     *
+     * The ::changed signal is emitted when any property of any property
+     * (including secrets) of any setting of the connection is modified,
+     * or when settings are added or removed.
+     */
+    signals[CHANGED] = g_signal_new(NM_CONNECTION_CHANGED,
+                                    NM_TYPE_CONNECTION,
+                                    G_SIGNAL_RUN_FIRST,
+                                    G_STRUCT_OFFSET(NMConnectionInterface, changed),
+                                    NULL,
+                                    NULL,
+                                    g_cclosure_marshal_VOID__VOID,
+                                    G_TYPE_NONE,
+                                    0);
 }