device: refactor by adding set_unmanaged_external_down() function
authorThomas Haller <thaller@redhat.com>
Thu, 24 Mar 2016 13:15:49 +0000 (14:15 +0100)
committerThomas Haller <thaller@redhat.com>
Thu, 31 Mar 2016 08:38:39 +0000 (10:38 +0200)
No functional change.

src/devices/nm-device.c

index 980b6e7..e808bf0 100644 (file)
@@ -1216,6 +1216,28 @@ is_unmanaged_external_down (NMDevice *self, gboolean consider_can)
        return NM_UNMAN_FLAG_OP_SET_MANAGED;
 }
 
+static void
+set_unmanaged_external_down (NMDevice *self)
+{
+       NMUnmanFlagOp ext_flags;
+
+       if (!nm_device_get_unmanaged_mask (self, NM_UNMANAGED_EXTERNAL_DOWN))
+               return;
+
+       ext_flags = is_unmanaged_external_down (self, FALSE);
+       if (ext_flags != NM_UNMAN_FLAG_OP_SET_UNMANAGED) {
+               /* Ensure the assume check is queued before any queued state changes
+                * from the transition to UNAVAILABLE.
+                */
+               nm_device_queue_recheck_assume (self);
+       }
+
+       nm_device_set_unmanaged_by_flags (self,
+                                         NM_UNMANAGED_EXTERNAL_DOWN,
+                                         ext_flags,
+                                         NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED);
+}
+
 static void
 update_dynamic_ip_setup (NMDevice *self)
 {
@@ -1536,22 +1558,7 @@ device_link_changed (NMDevice *self)
                nm_device_set_unmanaged_by_flags (self, NM_UNMANAGED_PLATFORM_INIT, FALSE, reason);
        }
 
-       if (nm_device_get_unmanaged_mask (self, NM_UNMANAGED_EXTERNAL_DOWN)) {
-               NMUnmanFlagOp ext_flags;
-
-               ext_flags = is_unmanaged_external_down (self, FALSE);
-               if (ext_flags != NM_UNMAN_FLAG_OP_SET_UNMANAGED) {
-                       /* Ensure the assume check is queued before any queued state changes
-                        * from the transition to UNAVAILABLE.
-                        */
-                       nm_device_queue_recheck_assume (self);
-               }
-
-               nm_device_set_unmanaged_by_flags (self,
-                                                 NM_UNMANAGED_EXTERNAL_DOWN,
-                                                 ext_flags,
-                                                 NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED);
-       }
+       set_unmanaged_external_down (self);
 
        device_recheck_slave_status (self, &info);
        return G_SOURCE_REMOVE;