summary refs log tree commit diff
path: root/src/core/nm-checkpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/nm-checkpoint.c')
-rw-r--r--src/core/nm-checkpoint.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/core/nm-checkpoint.c b/src/core/nm-checkpoint.c
index cd0e17fa..5c4d4e53 100644
--- a/src/core/nm-checkpoint.c
+++ b/src/core/nm-checkpoint.c
@@ -259,17 +259,19 @@ restore_and_activate_connection(NMCheckpoint *self, DeviceCheckpoint *dev_checkp
             g_clear_error(&local_error);
             return FALSE;
         }
-
-        /* If the device is software, a brand new NMDevice may have been created */
-        if (dev_checkpoint->is_software && !dev_checkpoint->device) {
-            dev_checkpoint->device = nm_manager_get_device(priv->manager,
-                                                           dev_checkpoint->original_dev_name,
-                                                           dev_checkpoint->dev_type);
-            nm_g_object_ref(dev_checkpoint->device);
-        }
         need_activation = TRUE;
     }
 
+    /* If the device is software, a brand new NMDevice may have been created
+     * after adding the new connection; or the old device might have been
+     * deleted and we need to fetch it again. */
+    if (dev_checkpoint->is_software && !dev_checkpoint->device) {
+        dev_checkpoint->device = nm_manager_get_device(priv->manager,
+                                                       dev_checkpoint->original_dev_name,
+                                                       dev_checkpoint->dev_type);
+        nm_g_object_ref(dev_checkpoint->device);
+    }
+
     if (!dev_checkpoint->device) {
         _LOGD("rollback: device cannot be restored");
         return FALSE;
@@ -368,7 +370,7 @@ nm_checkpoint_rollback(NMCheckpoint *self)
                 _LOGD("rollback: device was not realized, unmanage it");
                 nm_device_set_unmanaged_by_flags_queue(device,
                                                        NM_UNMANAGED_USER_EXPLICIT,
-                                                       TRUE,
+                                                       NM_UNMAN_FLAG_OP_SET_UNMANAGED,
                                                        NM_DEVICE_STATE_REASON_NOW_UNMANAGED);
                 goto next_dev;
             }
@@ -402,7 +404,7 @@ nm_checkpoint_rollback(NMCheckpoint *self)
                 _LOGD("rollback: explicitly unmanage device");
                 nm_device_set_unmanaged_by_flags_queue(device,
                                                        NM_UNMANAGED_USER_EXPLICIT,
-                                                       TRUE,
+                                                       NM_UNMAN_FLAG_OP_SET_UNMANAGED,
                                                        NM_DEVICE_STATE_REASON_NOW_UNMANAGED);
             }
             goto next_dev;
@@ -458,8 +460,25 @@ next_dev:
         NMDeviceState state;
 
         nm_manager_for_each_device (priv->manager, device, tmp_lst) {
+            gboolean found = FALSE;
+
             if (g_hash_table_contains(priv->devices, device))
                 continue;
+
+            /* Also ignore devices that were in the checkpoint initially and
+             * were moved to 'removed_devices' because they got removed from
+             * the system. */
+            for (i = 0; i < priv->removed_devices->len; i++) {
+                dev_checkpoint = priv->removed_devices->pdata[i];
+                if (dev_checkpoint->dev_type == nm_device_get_device_type(device)
+                    && nm_streq0(dev_checkpoint->original_dev_name, nm_device_get_iface(device))) {
+                    found = TRUE;
+                    break;
+                }
+            }
+            if (found)
+                continue;
+
             state = nm_device_get_state(device);
             if (state > NM_DEVICE_STATE_DISCONNECTED && state < NM_DEVICE_STATE_DEACTIVATING) {
                 _LOGD("rollback: disconnecting new device %s", nm_device_get_iface(device));