Blame SOURCES/0011-fix-assertion-delete-volatile-connection-rh1506552.patch

c48088
From abef55ece4d33b1a7e887bdf5452a48040d8ee8c Mon Sep 17 00:00:00 2001
c48088
From: Beniamino Galvani <bgalvani@redhat.com>
c48088
Date: Mon, 18 Dec 2017 17:25:10 +0100
c48088
Subject: [PATCH 1/1] settings: avoid assertion when deleting connections
c48088
c48088
If a volatile connection is deleted by user when it was already being
c48088
deleted internally because the device vanished, we may hit the
c48088
following failed assertion:
c48088
c48088
 file src/settings/nm-settings-connection.c: line 2196
c48088
 (nm_settings_connection_signal_remove): should not be reached
c48088
c48088
The @removed flag keeps track of whether we already signaled the
c48088
connection removal. Instead of throwing an assertion if we try to emit
c48088
the signal again, just return without action because this can happen
c48088
in the situation described above.
c48088
c48088
While at it, remove the @allow_reuse argument from
c48088
nm_settings_connection_signal_remove(): we should never emit the
c48088
signal twice. Instead, we should reset the @removed flag when the
c48088
connection is added.
c48088
c48088
Fixes: a9384452ed61ca3f1c6e1db175f499307da9c388
c48088
c48088
https://bugzilla.redhat.com/show_bug.cgi?id=1506552
c48088
(cherry picked from commit 98ac0f404ed8103324b7d03cf04c24946f4543ff)
c48088
(cherry picked from commit 39e1c65494d489b2cd9d63140c98d4fb4185003a)
c48088
---
c48088
 src/settings/nm-settings-connection.c              | 23 +++++++++++++++-------
c48088
 src/settings/nm-settings-connection.h              |  4 +++-
c48088
 src/settings/nm-settings.c                         |  2 ++
c48088
 .../plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c         |  4 ++--
c48088
 src/settings/plugins/ifnet/nms-ifnet-plugin.c      |  4 ++--
c48088
 src/settings/plugins/keyfile/nms-keyfile-plugin.c  |  2 +-
c48088
 6 files changed, 26 insertions(+), 13 deletions(-)
c48088
c48088
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
c48088
index 62f2de399..37a0b3a6c 100644
c48088
--- a/src/settings/nm-settings-connection.c
c48088
+++ b/src/settings/nm-settings-connection.c
c48088
@@ -794,7 +794,7 @@ nm_settings_connection_delete (NMSettingsConnection *self,
c48088
 	/* Remove connection from seen-bssids database file */
c48088
 	remove_entry_from_db (self, "seen-bssids");
c48088
 
c48088
-	nm_settings_connection_signal_remove (self, FALSE);
c48088
+	nm_settings_connection_signal_remove (self);
c48088
 	return TRUE;
c48088
 }
c48088
 
c48088
@@ -2188,15 +2188,24 @@ impl_settings_connection_clear_secrets (NMSettingsConnection *self,
c48088
 /*****************************************************************************/
c48088
 
c48088
 void
c48088
-nm_settings_connection_signal_remove (NMSettingsConnection *self, gboolean allow_reuse)
c48088
+nm_settings_connection_added (NMSettingsConnection *self)
c48088
 {
c48088
 	NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
c48088
 
c48088
-	if (!allow_reuse) {
c48088
-		if (priv->removed)
c48088
-			g_return_if_reached ();
c48088
-		priv->removed = TRUE;
c48088
-	}
c48088
+	/* FIXME: we should always dispose connections that are removed
c48088
+	 * and not reuse them, but currently plugins keep alive unmanaged
c48088
+	 * (e.g. NM_CONTROLLED=no) connections. */
c48088
+	priv->removed = FALSE;
c48088
+}
c48088
+
c48088
+void
c48088
+nm_settings_connection_signal_remove (NMSettingsConnection *self)
c48088
+{
c48088
+	NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
c48088
+
c48088
+	if (priv->removed)
c48088
+		return;
c48088
+	priv->removed = TRUE;
c48088
 	g_signal_emit_by_name (self, NM_SETTINGS_CONNECTION_REMOVED);
c48088
 }
c48088
 
c48088
diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h
c48088
index d7a999697..29ec05dd1 100644
c48088
--- a/src/settings/nm-settings-connection.h
c48088
+++ b/src/settings/nm-settings-connection.h
c48088
@@ -193,7 +193,9 @@ void nm_settings_connection_recheck_visibility (NMSettingsConnection *self);
c48088
 gboolean nm_settings_connection_check_permission (NMSettingsConnection *self,
c48088
                                                   const char *permission);
c48088
 
c48088
-void nm_settings_connection_signal_remove (NMSettingsConnection *self, gboolean allow_reuse);
c48088
+void nm_settings_connection_added (NMSettingsConnection *self);
c48088
+
c48088
+void nm_settings_connection_signal_remove (NMSettingsConnection *self);
c48088
 
c48088
 gboolean nm_settings_connection_get_unsaved (NMSettingsConnection *self);
c48088
 
c48088
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
c48088
index 21fdf9e06..d54305c13 100644
c48088
--- a/src/settings/nm-settings.c
c48088
+++ b/src/settings/nm-settings.c
c48088
@@ -1004,6 +1004,8 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
c48088
 		/* Exported D-Bus signal */
c48088
 		g_signal_emit (self, signals[NEW_CONNECTION], 0, connection);
c48088
 	}
c48088
+
c48088
+	nm_settings_connection_added (connection);
c48088
 }
c48088
 
c48088
 static gboolean
c48088
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c
c48088
index 2b388d1d9..0743fc9ff 100644
c48088
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c
c48088
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c
c48088
@@ -161,7 +161,7 @@ remove_connection (SettingsPluginIfcfg *self, NMIfcfgConnection *connection)
c48088
 	g_object_ref (connection);
c48088
 	g_hash_table_remove (priv->connections, nm_connection_get_uuid (NM_CONNECTION (connection)));
c48088
 	if (!unmanaged && !unrecognized)
c48088
-		nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection), FALSE);
c48088
+		nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection));
c48088
 	g_object_unref (connection);
c48088
 
c48088
 	/* Emit changes _after_ removing the connection */
c48088
@@ -331,7 +331,7 @@ update_connection (SettingsPluginIfcfg *self,
c48088
 					/* Unexport the connection by telling the settings service it's
c48088
 					 * been removed.
c48088
 					 */
c48088
-					nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection_by_uuid), TRUE);
c48088
+					nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection_by_uuid));
c48088
 					/* Remove the path so that claim_connection() doesn't complain later when
c48088
 					 * interface gets managed and connection is re-added. */
c48088
 					nm_connection_set_path (NM_CONNECTION (connection_by_uuid), NULL);
c48088
diff --git a/src/settings/plugins/ifnet/nms-ifnet-plugin.c b/src/settings/plugins/ifnet/nms-ifnet-plugin.c
c48088
index d89e988ba..8332358f9 100644
c48088
--- a/src/settings/plugins/ifnet/nms-ifnet-plugin.c
c48088
+++ b/src/settings/plugins/ifnet/nms-ifnet-plugin.c
c48088
@@ -262,7 +262,7 @@ reload_connections (NMSettingsPlugin *config)
c48088
 				                              NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) {
c48088
 					nm_log_info (LOGD_SETTINGS, "Auto refreshing %s", conn_name);
c48088
 
c48088
-					nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (old), FALSE);
c48088
+					nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (old));
c48088
 					track_new_connection (self, new);
c48088
 					if (is_managed_plugin () && is_managed (conn_name))
c48088
 						g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new);
c48088
@@ -305,7 +305,7 @@ reload_connections (NMSettingsPlugin *config)
c48088
 		 */
c48088
 		if (   nm_ifnet_connection_get_conn_name (NM_IFNET_CONNECTION (candidate))
c48088
 		    && !g_hash_table_lookup (new_connections, uuid)) {
c48088
-			nm_settings_connection_signal_remove (candidate, FALSE);
c48088
+			nm_settings_connection_signal_remove (candidate);
c48088
 			g_hash_table_iter_remove (&iter);
c48088
 		}
c48088
 	}
c48088
diff --git a/src/settings/plugins/keyfile/nms-keyfile-plugin.c b/src/settings/plugins/keyfile/nms-keyfile-plugin.c
c48088
index 222768db4..cb5f2c9f0 100644
c48088
--- a/src/settings/plugins/keyfile/nms-keyfile-plugin.c
c48088
+++ b/src/settings/plugins/keyfile/nms-keyfile-plugin.c
c48088
@@ -107,7 +107,7 @@ remove_connection (NMSKeyfilePlugin *self, NMSKeyfileConnection *connection)
c48088
 	g_signal_handlers_disconnect_by_func (connection, connection_removed_cb, self);
c48088
 	removed = g_hash_table_remove (NMS_KEYFILE_PLUGIN_GET_PRIVATE (self)->connections,
c48088
 	                               nm_connection_get_uuid (NM_CONNECTION (connection)));
c48088
-	nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection), FALSE);
c48088
+	nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection));
c48088
 	g_object_unref (connection);
c48088
 
c48088
 	g_return_if_fail (removed);
c48088
-- 
c48088
2.14.3
c48088