mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 03:48:09 +02:00
merge: branch 'bg/rh1945282' into main
https://bugzilla.redhat.com/show_bug.cgi?id=1945282
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/803
(cherry picked from commit 1186d5e5cd)
This commit is contained in:
commit
da0c6dbc93
2 changed files with 58 additions and 31 deletions
|
|
@ -125,7 +125,6 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
guint idle_add_id;
|
guint idle_add_id;
|
||||||
int ifindex;
|
|
||||||
} DeleteOnDeactivateData;
|
} DeleteOnDeactivateData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -12141,28 +12140,19 @@ nm_device_is_nm_owned(NMDevice *self)
|
||||||
static gboolean
|
static gboolean
|
||||||
delete_on_deactivate_link_delete(gpointer user_data)
|
delete_on_deactivate_link_delete(gpointer user_data)
|
||||||
{
|
{
|
||||||
DeleteOnDeactivateData *data = user_data;
|
DeleteOnDeactivateData *data = user_data;
|
||||||
NMDevice * self = data->device;
|
nm_auto_unref_object NMDevice *self = data->device;
|
||||||
|
NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self);
|
||||||
|
gs_free_error GError *error = NULL;
|
||||||
|
|
||||||
_LOGD(LOGD_DEVICE,
|
_LOGD(LOGD_DEVICE,
|
||||||
"delete_on_deactivate: cleanup and delete virtual link #%d (id=%u)",
|
"delete_on_deactivate: cleanup and delete virtual link (id=%u)",
|
||||||
data->ifindex,
|
|
||||||
data->idle_add_id);
|
data->idle_add_id);
|
||||||
|
|
||||||
if (data->device) {
|
priv->delete_on_deactivate_data = NULL;
|
||||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(data->device);
|
|
||||||
gs_free_error GError *error = NULL;
|
|
||||||
|
|
||||||
g_object_remove_weak_pointer(G_OBJECT(data->device), (void **) &data->device);
|
if (!nm_device_unrealize(self, TRUE, &error))
|
||||||
priv->delete_on_deactivate_data = NULL;
|
_LOGD(LOGD_DEVICE, "delete_on_deactivate: unrealizing failed (%s)", error->message);
|
||||||
|
|
||||||
if (!nm_device_unrealize(data->device, TRUE, &error))
|
|
||||||
_LOGD(LOGD_DEVICE,
|
|
||||||
"delete_on_deactivate: unrealizing %d failed (%s)",
|
|
||||||
data->ifindex,
|
|
||||||
error->message);
|
|
||||||
} else if (data->ifindex > 0)
|
|
||||||
nm_platform_link_delete(nm_device_get_platform(self), data->ifindex);
|
|
||||||
|
|
||||||
nm_device_emit_recheck_auto_activate(self);
|
nm_device_emit_recheck_auto_activate(self);
|
||||||
|
|
||||||
|
|
@ -12181,17 +12171,16 @@ delete_on_deactivate_unschedule(NMDevice *self)
|
||||||
priv->delete_on_deactivate_data = NULL;
|
priv->delete_on_deactivate_data = NULL;
|
||||||
|
|
||||||
g_source_remove(data->idle_add_id);
|
g_source_remove(data->idle_add_id);
|
||||||
g_object_remove_weak_pointer(G_OBJECT(self), (void **) &data->device);
|
|
||||||
_LOGD(LOGD_DEVICE,
|
_LOGD(LOGD_DEVICE,
|
||||||
"delete_on_deactivate: cancel cleanup and delete virtual link #%d (id=%u)",
|
"delete_on_deactivate: cancel cleanup and delete virtual link (id=%u)",
|
||||||
data->ifindex,
|
|
||||||
data->idle_add_id);
|
data->idle_add_id);
|
||||||
|
g_object_unref(data->device);
|
||||||
g_free(data);
|
g_free(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
delete_on_deactivate_check_and_schedule(NMDevice *self, int ifindex)
|
delete_on_deactivate_check_and_schedule(NMDevice *self)
|
||||||
{
|
{
|
||||||
NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self);
|
NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self);
|
||||||
DeleteOnDeactivateData *data;
|
DeleteOnDeactivateData *data;
|
||||||
|
|
@ -12208,16 +12197,13 @@ delete_on_deactivate_check_and_schedule(NMDevice *self, int ifindex)
|
||||||
return;
|
return;
|
||||||
delete_on_deactivate_unschedule(self); /* always cancel and reschedule */
|
delete_on_deactivate_unschedule(self); /* always cancel and reschedule */
|
||||||
|
|
||||||
data = g_new(DeleteOnDeactivateData, 1);
|
data = g_new(DeleteOnDeactivateData, 1);
|
||||||
g_object_add_weak_pointer(G_OBJECT(self), (void **) &data->device);
|
data->device = g_object_ref(self);
|
||||||
data->device = self;
|
|
||||||
data->ifindex = ifindex;
|
|
||||||
data->idle_add_id = g_idle_add(delete_on_deactivate_link_delete, data);
|
data->idle_add_id = g_idle_add(delete_on_deactivate_link_delete, data);
|
||||||
priv->delete_on_deactivate_data = data;
|
priv->delete_on_deactivate_data = data;
|
||||||
|
|
||||||
_LOGD(LOGD_DEVICE,
|
_LOGD(LOGD_DEVICE,
|
||||||
"delete_on_deactivate: schedule cleanup and delete virtual link #%d (id=%u)",
|
"delete_on_deactivate: schedule cleanup and delete virtual link (id=%u)",
|
||||||
ifindex,
|
|
||||||
data->idle_add_id);
|
data->idle_add_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -15854,7 +15840,7 @@ _cleanup_generic_post(NMDevice *self, CleanupType cleanup_type)
|
||||||
/* Check if the device was deactivated, and if so, delete_link.
|
/* Check if the device was deactivated, and if so, delete_link.
|
||||||
* Don't call delete_link synchronously because we are currently
|
* Don't call delete_link synchronously because we are currently
|
||||||
* handling a state change -- which is not reentrant. */
|
* handling a state change -- which is not reentrant. */
|
||||||
delete_on_deactivate_check_and_schedule(self, nm_device_get_ip_ifindex(self));
|
delete_on_deactivate_check_and_schedule(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ip_iface should be cleared after flushing all routes and addresses, since
|
/* ip_iface should be cleared after flushing all routes and addresses, since
|
||||||
|
|
|
||||||
|
|
@ -3509,6 +3509,45 @@ typedef struct {
|
||||||
guint idle_id;
|
guint idle_id;
|
||||||
} PlatformLinkCbData;
|
} PlatformLinkCbData;
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_check_remove_dev_on_link_deleted(NMManager *self, NMDevice *device)
|
||||||
|
{
|
||||||
|
NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self);
|
||||||
|
NMSettingsConnection *const *scons = NULL;
|
||||||
|
NMConnection * con;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
nm_assert(nm_device_is_software(device));
|
||||||
|
|
||||||
|
/* In general, software devices stick around as unrealized
|
||||||
|
* until their connection is removed. However, we don't want
|
||||||
|
* that a NM-generated connection keeps the device alive.
|
||||||
|
* If there are no other compatible connections, the device
|
||||||
|
* should be also removed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
scons = nm_settings_get_connections(priv->settings, NULL);
|
||||||
|
|
||||||
|
for (i = 0; scons[i]; i++) {
|
||||||
|
con = nm_settings_connection_get_connection(scons[i]);
|
||||||
|
if (!nm_connection_is_virtual(con))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (NM_FLAGS_HAS(nm_settings_connection_get_flags(scons[i]),
|
||||||
|
NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!nm_device_check_connection_compatible(device, con, NULL))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Found a virtual connection compatible, the device must
|
||||||
|
* stay around unrealized. */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_platform_link_cb_idle(PlatformLinkCbData *data)
|
_platform_link_cb_idle(PlatformLinkCbData *data)
|
||||||
{
|
{
|
||||||
|
|
@ -3534,13 +3573,15 @@ _platform_link_cb_idle(PlatformLinkCbData *data)
|
||||||
if (device) {
|
if (device) {
|
||||||
if (nm_device_is_software(device)) {
|
if (nm_device_is_software(device)) {
|
||||||
nm_device_sys_iface_state_set(device, NM_DEVICE_SYS_IFACE_STATE_REMOVED);
|
nm_device_sys_iface_state_set(device, NM_DEVICE_SYS_IFACE_STATE_REMOVED);
|
||||||
/* Our software devices stick around until their connection is removed */
|
|
||||||
if (!nm_device_unrealize(device, FALSE, &error)) {
|
if (!nm_device_unrealize(device, FALSE, &error)) {
|
||||||
_LOG2W(LOGD_DEVICE, device, "failed to unrealize: %s", error->message);
|
_LOG2W(LOGD_DEVICE, device, "failed to unrealize: %s", error->message);
|
||||||
g_clear_error(&error);
|
g_clear_error(&error);
|
||||||
remove_device(self, device, FALSE);
|
remove_device(self, device, FALSE);
|
||||||
} else {
|
} else {
|
||||||
nm_device_update_from_platform_link(device, NULL);
|
if (_check_remove_dev_on_link_deleted(self, device))
|
||||||
|
remove_device(self, device, FALSE);
|
||||||
|
else
|
||||||
|
nm_device_update_from_platform_link(device, NULL);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Hardware and external devices always get removed when their kernel link is gone */
|
/* Hardware and external devices always get removed when their kernel link is gone */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue