summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-09-03 16:51:39 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2015-09-16 13:14:46 +0200
commit80d4fbf4ace3d8ed4428e17b0920ec32bdaf4fe1 (patch)
tree0d768b0091c2a29da833b514a370b235e54cedc1
parentb46ed879198e911521373391c27982034699dfe5 (diff)
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 (cherry picked from commit b3b0b4625053d5647e2756bbe745652889684a21)
-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 3a7d9919b9..c5924a6b66 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -95,6 +95,7 @@ enum {
REMOVED,
RECHECK_AUTO_ACTIVATE,
RECHECK_ASSUME,
+ LINK_INITIALIZED,
LAST_SIGNAL,
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -1505,6 +1506,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;
@@ -9837,6 +9840,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_dbus_manager_register_exported_type (nm_dbus_manager_get (),
G_TYPE_FROM_CLASS (klass),
&dbus_glib_nm_device_object_info);
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index e9d5b9488d..49cef8e19c 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -74,6 +74,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 34ec0819d5..d91a0d707e 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -853,6 +853,14 @@ device_removed_cb (NMDevice *device, gpointer user_data)
}
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);
+}
+
+static void
aipd_handle_event (DBusGProxy *proxy,
const char *event,
const char *iface,
@@ -1813,6 +1821,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);
@@ -1871,6 +1883,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);