Blame SOURCES/0011-rh1254089-retry-generation-of-default-connection.patch

ab7d06
From 80d4fbf4ace3d8ed4428e17b0920ec32bdaf4fe1 Mon Sep 17 00:00:00 2001
ab7d06
From: Beniamino Galvani <bgalvani@redhat.com>
ab7d06
Date: Thu, 3 Sep 2015 16:51:39 +0200
ab7d06
Subject: [PATCH] device: retry creation of default connection after link is
ab7d06
 initialized
ab7d06
ab7d06
When a new link is detected, NM tries to generate a default "Wired
ab7d06
connection" in nm_settings_device_added(), but if the link has not
ab7d06
been initialized by udev yet the function returns early because
ab7d06
priv->unmanaged_flags = UNMANAGED_PLATFORM_INIT.
ab7d06
ab7d06
To be sure that a default connection is created is such situation, we
ab7d06
need to call again nm_settings_device_added() after link
ab7d06
initialization.
ab7d06
ab7d06
https://bugzilla.redhat.com/show_bug.cgi?id=1254089
ab7d06
(cherry picked from commit b3b0b4625053d5647e2756bbe745652889684a21)
ab7d06
---
ab7d06
 src/devices/nm-device.c | 10 ++++++++++
ab7d06
 src/devices/nm-device.h |  1 +
ab7d06
 src/nm-manager.c        | 15 +++++++++++++++
ab7d06
 3 files changed, 26 insertions(+)
ab7d06
ab7d06
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
ab7d06
index 3a7d991..c5924a6 100644
ab7d06
--- a/src/devices/nm-device.c
ab7d06
+++ b/src/devices/nm-device.c
ab7d06
@@ -95,6 +95,7 @@ enum {
ab7d06
 	REMOVED,
ab7d06
 	RECHECK_AUTO_ACTIVATE,
ab7d06
 	RECHECK_ASSUME,
ab7d06
+	LINK_INITIALIZED,
ab7d06
 	LAST_SIGNAL,
ab7d06
 };
ab7d06
 static guint signals[LAST_SIGNAL] = { 0 };
ab7d06
@@ -1505,6 +1506,8 @@ device_link_changed (NMDevice *self)
ab7d06
 		                         NM_UNMANAGED_PLATFORM_INIT,
ab7d06
 		                         FALSE,
ab7d06
 		                         NM_DEVICE_STATE_REASON_NOW_MANAGED);
ab7d06
+
ab7d06
+		g_signal_emit (self, signals[LINK_INITIALIZED], 0);
ab7d06
 	}
ab7d06
 
ab7d06
 	return G_SOURCE_REMOVE;
ab7d06
@@ -9837,6 +9840,13 @@ nm_device_class_init (NMDeviceClass *klass)
ab7d06
 		              0, NULL, NULL, NULL,
ab7d06
 		              G_TYPE_NONE, 0);
ab7d06
 
ab7d06
+	signals[LINK_INITIALIZED] =
ab7d06
+		g_signal_new (NM_DEVICE_LINK_INITIALIZED,
ab7d06
+		              G_OBJECT_CLASS_TYPE (object_class),
ab7d06
+		              G_SIGNAL_RUN_FIRST,
ab7d06
+		              0, NULL, NULL, NULL,
ab7d06
+		              G_TYPE_NONE, 0);
ab7d06
+
ab7d06
 	nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
ab7d06
 	                                        G_TYPE_FROM_CLASS (klass),
ab7d06
 	                                        &dbus_glib_nm_device_object_info);
ab7d06
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
ab7d06
index e9d5b94..49cef8e 100644
ab7d06
--- a/src/devices/nm-device.h
ab7d06
+++ b/src/devices/nm-device.h
ab7d06
@@ -74,6 +74,7 @@
ab7d06
 #define NM_DEVICE_REMOVED               "removed"
ab7d06
 #define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate"
ab7d06
 #define NM_DEVICE_RECHECK_ASSUME        "recheck-assume"
ab7d06
+#define NM_DEVICE_LINK_INITIALIZED      "link-initialized"
ab7d06
 
ab7d06
 G_BEGIN_DECLS
ab7d06
 
ab7d06
diff --git a/src/nm-manager.c b/src/nm-manager.c
ab7d06
index 34ec081..d91a0d7 100644
ab7d06
--- a/src/nm-manager.c
ab7d06
+++ b/src/nm-manager.c
ab7d06
@@ -853,6 +853,14 @@ device_removed_cb (NMDevice *device, gpointer user_data)
ab7d06
 }
ab7d06
 
ab7d06
 static void
ab7d06
+device_link_initialized_cb (NMDevice *device, gpointer user_data)
ab7d06
+{
ab7d06
+	NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (user_data);
ab7d06
+
ab7d06
+	nm_settings_device_added (priv->settings, device);
ab7d06
+}
ab7d06
+
ab7d06
+static void
ab7d06
 aipd_handle_event (DBusGProxy *proxy,
ab7d06
                    const char *event,
ab7d06
                    const char *iface,
ab7d06
@@ -1813,6 +1821,10 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
ab7d06
 	                  G_CALLBACK (device_removed_cb),
ab7d06
 	                  self);
ab7d06
 
ab7d06
+	g_signal_connect (device, NM_DEVICE_LINK_INITIALIZED,
ab7d06
+	                  G_CALLBACK (device_link_initialized_cb),
ab7d06
+	                  self);
ab7d06
+
ab7d06
 	g_signal_connect (device, "notify::" NM_DEVICE_IP_IFACE,
ab7d06
 	                  G_CALLBACK (device_ip_iface_changed),
ab7d06
 	                  self);
ab7d06
@@ -1871,6 +1883,9 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
ab7d06
 		                         NM_DEVICE_STATE_REASON_NOW_MANAGED);
ab7d06
 	}
ab7d06
 
ab7d06
+	/* Try to generate a default connection. If this fails because the link is
ab7d06
+	 * not initialized, we will retry again in device_link_initialized_cb().
ab7d06
+	 */
ab7d06
 	nm_settings_device_added (priv->settings, device);
ab7d06
 	g_signal_emit (self, signals[DEVICE_ADDED], 0, device);
ab7d06
 	g_object_notify (G_OBJECT (self), NM_MANAGER_DEVICES);
ab7d06
-- 
ab7d06
2.4.3
ab7d06