diff --git a/src/core/devices/nm-device-6lowpan.c b/src/core/devices/nm-device-6lowpan.c index 870a1c14e..f3386ddb5 100644 --- a/src/core/devices/nm-device-6lowpan.c +++ b/src/core/devices/nm-device-6lowpan.c @@ -72,14 +72,22 @@ create_and_realize(NMDevice *device, s_6lowpan = NM_SETTING_6LOWPAN(nm_connection_get_setting(connection, NM_TYPE_SETTING_6LOWPAN)); g_return_val_if_fail(s_6lowpan, FALSE); - parent_ifindex = parent ? nm_device_get_ifindex(parent) : 0; + if (!parent) { + g_set_error(error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_MISSING_DEPENDENCIES, + "6LoWPAN device can not be created without a parent interface"); + return FALSE; + } + parent_ifindex = nm_device_get_ifindex(parent); if (parent_ifindex <= 0) { g_set_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES, - "6LoWPAN devices can not be created without a parent interface"); - g_return_val_if_fail(!parent, FALSE); + "cannot retrieve ifindex of interface %s (%s)", + nm_device_get_iface(parent), + nm_device_get_type_desc(parent)); return FALSE; } diff --git a/src/core/devices/nm-device-macvlan.c b/src/core/devices/nm-device-macvlan.c index 3f57bfb1f..06c0df07e 100644 --- a/src/core/devices/nm-device-macvlan.c +++ b/src/core/devices/nm-device-macvlan.c @@ -208,14 +208,22 @@ create_and_realize(NMDevice *device, s_macvlan = nm_connection_get_setting_macvlan(connection); g_return_val_if_fail(s_macvlan, FALSE); - parent_ifindex = parent ? nm_device_get_ifindex(parent) : 0; + if (!parent) { + g_set_error(error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_MISSING_DEPENDENCIES, + "MACVLAN device can not be created without a parent interface"); + return FALSE; + } + parent_ifindex = nm_device_get_ifindex(parent); if (parent_ifindex <= 0) { g_set_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES, - "MACVLAN devices can not be created without a parent interface"); - g_return_val_if_fail(!parent, FALSE); + "cannot retrieve ifindex of interface %s (%s)", + nm_device_get_iface(parent), + nm_device_get_type_desc(parent)); return FALSE; } diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 300c95874..11f900139 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -6495,13 +6495,6 @@ _dev_unmanaged_check_external_down(NMDevice *self, gboolean only_if_unmanaged, g } ext_flags = _dev_unmanaged_is_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); - } - if (now) { nm_device_set_unmanaged_by_flags(self, NM_UNMANAGED_EXTERNAL_DOWN, @@ -6966,12 +6959,6 @@ device_link_changed(gpointer user_data) } } - /* The assume check should happen before the device transitions to - * UNAVAILABLE, because in UNAVAILABLE we already clean up the IP - * configuration. Therefore, this function should never trigger a - * sync state transition. - */ - nm_device_queue_recheck_assume(self); nm_device_set_unmanaged_by_flags_queue(self, NM_UNMANAGED_PLATFORM_INIT, NM_UNMAN_FLAG_OP_SET_MANAGED, @@ -14701,6 +14688,15 @@ _set_unmanaged_flags(NMDevice *self, if (transition_state) { new_state = was_managed ? NM_DEVICE_STATE_UNMANAGED : NM_DEVICE_STATE_UNAVAILABLE; + if (new_state != NM_DEVICE_STATE_UNMANAGED) { + /* The assume check should happen before the device transitions to + * UNAVAILABLE, because in UNAVAILABLE we already clean up the IP + * configuration. Therefore, this function should never trigger a + * sync state transition. + */ + nm_device_queue_recheck_assume(self); + } + if (now) nm_device_state_changed(self, new_state, reason); else @@ -16105,8 +16101,11 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, * userspace IPv6LL enabled. */ _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); + if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_REMOVED) { + nm_device_cleanup(self, reason, CLEANUP_TYPE_REMOVED); + } else + nm_device_cleanup(self, reason, CLEANUP_TYPE_DECONFIGURE); - nm_device_cleanup(self, reason, CLEANUP_TYPE_DECONFIGURE); } else if (old_state < NM_DEVICE_STATE_DISCONNECTED) { if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED) { /* Ensure IPv6 is set up as it may not have been done when diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 5e83a0c53..b58079b59 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -7077,7 +7077,7 @@ do_sleep_wake(NMManager *self, gboolean sleeping_changed) nm_device_set_unmanaged_by_flags(device, NM_UNMANAGED_SLEEPING, NM_UNMAN_FLAG_OP_SET_MANAGED, - NM_DEVICE_STATE_REASON_NOW_MANAGED); + NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); } /* Give the connections a chance to recreate the virtual devices.