summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-09-03 16:51:39 +0200
committerLubomir Rintel <lkundrak@v3.sk>2015-09-03 17:59:51 +0200
commitb3b0b4625053d5647e2756bbe745652889684a21 (patch)
treef502e6e6d91cc42b45769b532ee8ab8b75eaa42d
parentde5d98197f751c4ff4eed36af27131a024e47b73 (diff)
downloadNetworkManager-b3b0b4625053d5647e2756bbe745652889684a21.tar.gz
device: retry creation of default connection after link is initialized
When a new link is detected, NM tries to generate a default "Wired connection" in nm_settings_device_added(), but if the link has not been initialized by udev yet the function returns early because priv->unmanaged_flags = UNMANAGED_PLATFORM_INIT. To be sure that a default connection is created is such situation, we need to call again nm_settings_device_added() after link initialization. https://bugzilla.redhat.com/show_bug.cgi?id=1254089
-rw-r--r--src/devices/nm-device.c10
-rw-r--r--src/devices/nm-device.h1
-rw-r--r--src/nm-manager.c15
3 files changed, 26 insertions, 0 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index bf800342a4..e1e8030b54 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -87,6 +87,7 @@ enum {
REMOVED,
RECHECK_AUTO_ACTIVATE,
RECHECK_ASSUME,
+ LINK_INITIALIZED,
LAST_SIGNAL,
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -1475,6 +1476,8 @@ device_link_changed (NMDevice *self)
NM_UNMANAGED_PLATFORM_INIT,
FALSE,
NM_DEVICE_STATE_REASON_NOW_MANAGED);
+
+ g_signal_emit (self, signals[LINK_INITIALIZED], 0);
}
return G_SOURCE_REMOVE;
@@ -9852,6 +9855,13 @@ nm_device_class_init (NMDeviceClass *klass)
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
+ signals[LINK_INITIALIZED] =
+ g_signal_new (NM_DEVICE_LINK_INITIALIZED,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_SKELETON,
"Disconnect", impl_device_disconnect,
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 0995377ad2..29d521353a 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -73,6 +73,7 @@
#define NM_DEVICE_REMOVED "removed"
#define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate"
#define NM_DEVICE_RECHECK_ASSUME "recheck-assume"
+#define NM_DEVICE_LINK_INITIALIZED "link-initialized"
G_BEGIN_DECLS
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 71b9d7074f..871bda39d3 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -796,6 +796,14 @@ device_removed_cb (NMDevice *device, gpointer user_data)
remove_device (NM_MANAGER (user_data), device, FALSE, TRUE);
}
+static void
+device_link_initialized_cb (NMDevice *device, gpointer user_data)
+{
+ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (user_data);
+
+ nm_settings_device_added (priv->settings, device);
+}
+
NMState
nm_manager_get_state (NMManager *manager)
{
@@ -1727,6 +1735,10 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
G_CALLBACK (device_removed_cb),
self);
+ g_signal_connect (device, NM_DEVICE_LINK_INITIALIZED,
+ G_CALLBACK (device_link_initialized_cb),
+ self);
+
g_signal_connect (device, "notify::" NM_DEVICE_IP_IFACE,
G_CALLBACK (device_ip_iface_changed),
self);
@@ -1787,6 +1799,9 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
NM_DEVICE_STATE_REASON_NOW_MANAGED);
}
+ /* Try to generate a default connection. If this fails because the link is
+ * not initialized, we will retry again in device_link_initialized_cb().
+ */
nm_settings_device_added (priv->settings, device);
g_signal_emit (self, signals[DEVICE_ADDED], 0, device);
g_object_notify (G_OBJECT (self), NM_MANAGER_DEVICES);