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
This commit is contained in:

committed by
Lubomir Rintel

parent
de5d98197f
commit
b3b0b46250
@@ -87,6 +87,7 @@ enum {
|
|||||||
REMOVED,
|
REMOVED,
|
||||||
RECHECK_AUTO_ACTIVATE,
|
RECHECK_AUTO_ACTIVATE,
|
||||||
RECHECK_ASSUME,
|
RECHECK_ASSUME,
|
||||||
|
LINK_INITIALIZED,
|
||||||
LAST_SIGNAL,
|
LAST_SIGNAL,
|
||||||
};
|
};
|
||||||
static guint signals[LAST_SIGNAL] = { 0 };
|
static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
@@ -1475,6 +1476,8 @@ device_link_changed (NMDevice *self)
|
|||||||
NM_UNMANAGED_PLATFORM_INIT,
|
NM_UNMANAGED_PLATFORM_INIT,
|
||||||
FALSE,
|
FALSE,
|
||||||
NM_DEVICE_STATE_REASON_NOW_MANAGED);
|
NM_DEVICE_STATE_REASON_NOW_MANAGED);
|
||||||
|
|
||||||
|
g_signal_emit (self, signals[LINK_INITIALIZED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
@@ -9852,6 +9855,13 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||||||
0, NULL, NULL, NULL,
|
0, NULL, NULL, NULL,
|
||||||
G_TYPE_NONE, 0);
|
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),
|
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||||
NMDBUS_TYPE_DEVICE_SKELETON,
|
NMDBUS_TYPE_DEVICE_SKELETON,
|
||||||
"Disconnect", impl_device_disconnect,
|
"Disconnect", impl_device_disconnect,
|
||||||
|
@@ -73,6 +73,7 @@
|
|||||||
#define NM_DEVICE_REMOVED "removed"
|
#define NM_DEVICE_REMOVED "removed"
|
||||||
#define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate"
|
#define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate"
|
||||||
#define NM_DEVICE_RECHECK_ASSUME "recheck-assume"
|
#define NM_DEVICE_RECHECK_ASSUME "recheck-assume"
|
||||||
|
#define NM_DEVICE_LINK_INITIALIZED "link-initialized"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@@ -796,6 +796,14 @@ device_removed_cb (NMDevice *device, gpointer user_data)
|
|||||||
remove_device (NM_MANAGER (user_data), device, FALSE, TRUE);
|
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
|
NMState
|
||||||
nm_manager_get_state (NMManager *manager)
|
nm_manager_get_state (NMManager *manager)
|
||||||
{
|
{
|
||||||
@@ -1727,6 +1735,10 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
|
|||||||
G_CALLBACK (device_removed_cb),
|
G_CALLBACK (device_removed_cb),
|
||||||
self);
|
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_signal_connect (device, "notify::" NM_DEVICE_IP_IFACE,
|
||||||
G_CALLBACK (device_ip_iface_changed),
|
G_CALLBACK (device_ip_iface_changed),
|
||||||
self);
|
self);
|
||||||
@@ -1787,6 +1799,9 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
|
|||||||
NM_DEVICE_STATE_REASON_NOW_MANAGED);
|
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);
|
nm_settings_device_added (priv->settings, device);
|
||||||
g_signal_emit (self, signals[DEVICE_ADDED], 0, device);
|
g_signal_emit (self, signals[DEVICE_ADDED], 0, device);
|
||||||
g_object_notify (G_OBJECT (self), NM_MANAGER_DEVICES);
|
g_object_notify (G_OBJECT (self), NM_MANAGER_DEVICES);
|
||||||
|
Reference in New Issue
Block a user