summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-03-25 15:59:45 +0100
committerThomas Haller <thaller@redhat.com>2020-03-28 11:01:05 +0100
commitff814923ebfa434ba0ffaa13f0d61a4bb8ad6ec4 (patch)
tree95b3db4be7118ca9f258f7f1a05e7ed7fb8dd2bc
parentc84a4579b2995bb04a3d08619d60093bf541ba10 (diff)
core: prevent multiple attempts to create default wired connection
Scenario: - have ethernet connection as unmanaged. - create (or have) a suitable profile for the connection. - make the device as managed. No default wired connection gets created. - delete the profile. Note that NMManager does in manager_device_state_changed(): »···if (NM_IN_SET (new_state, »··· NM_DEVICE_STATE_UNAVAILABLE, »··· NM_DEVICE_STATE_DISCONNECTED)) »···»···nm_settings_device_added (priv->settings, device); that means, when the device the next time goes through UNAVAILABLE/DISCONNECTED states, we will suddenly create the default "Wired connection 1" profile. That doesn't seem right. When a device is suitable to have a default-wired connection, we should only check once whether to create it. We should not retry that later. The !no-auto-default mechanism exists so we can start NetworkManager without a profile for the device. It doesn't mean that we later one (after previously deciding not to create a profile), we still create it. https://bugzilla.redhat.com/show_bug.cgi?id=1687937 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/450
-rw-r--r--src/settings/nm-settings.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index 78361804db..874efbfc2b 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -70,6 +70,9 @@
static
NM_CACHED_QUARK_FCN ("default-wired-connection", _default_wired_connection_quark)
+static
+NM_CACHED_QUARK_FCN ("default-wired-connection-blocked", _default_wired_connection_blocked_quark)
+
/*****************************************************************************/
typedef struct _StorageData {
@@ -3432,9 +3435,13 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self)
*/
if ( !NM_DEVICE_GET_CLASS (device)->new_default_connection
|| !nm_device_get_managed (device, FALSE)
- || g_object_get_qdata (G_OBJECT (device), _default_wired_connection_quark ()))
+ || g_object_get_qdata (G_OBJECT (device), _default_wired_connection_blocked_quark ()))
return;
+ /* we only check once whether to create the auto-default connection. If we reach this point,
+ * we mark the creation of the default-wired-connection as blocked. */
+ g_object_set_qdata (G_OBJECT (device), _default_wired_connection_blocked_quark (), device);
+
if (nm_config_get_no_auto_default_for_device (priv->config, device)) {
_LOGT ("auto-default: cannot create auto-default connection for device %s: disabled by \"no-auto-default\"",
nm_device_get_iface (device));