From 4e105c5012667d5722d69e2a697ab085e62c7e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 8 Sep 2014 16:20:58 +0200 Subject: [PATCH] core: add NM_UNMANAGED_PARENT flag for a dependency on parent device VLAN device depends on its parent, for instance. If the parent is not managed, then the VLAN can't be either. --- src/devices/nm-device-vlan.c | 19 +++++++++---------- src/devices/nm-device.h | 2 ++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index d5f123c48a..a245a434b2 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -408,16 +408,7 @@ parent_state_changed (NMDevice *parent, if (reason == NM_DEVICE_STATE_REASON_CARRIER) return; - if (new_state < NM_DEVICE_STATE_DISCONNECTED) { - /* If the parent becomes unavailable or unmanaged so does the VLAN */ - nm_device_state_changed (NM_DEVICE (self), new_state, reason); - } else if ( new_state == NM_DEVICE_STATE_DISCONNECTED - && old_state < NM_DEVICE_STATE_DISCONNECTED) { - /* Mark VLAN interface as available/disconnected when the parent - * becomes available as a result of becoming initialized. - */ - nm_device_state_changed (NM_DEVICE (self), new_state, reason); - } + nm_device_set_unmanaged (NM_DEVICE (self), NM_UNMANAGED_PARENT, !nm_device_get_managed (parent), reason); } /******************************************************************/ @@ -639,6 +630,10 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error) device = NULL; } + /* Set initial parent-dependent unmanaged flag */ + if (device) + nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_PARENT, !nm_device_get_managed (parent)); + return device; } @@ -690,6 +685,10 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, device = NULL; } + /* Set initial parent-dependent unmanaged flag */ + if (device) + nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_PARENT, !nm_device_get_managed (parent)); + return device; } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 9d0ff78179..ab54262623 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -301,12 +301,14 @@ RfKillType nm_device_get_rfkill_type (NMDevice *device); * @NM_UNMANAGED_INTERNAL: %TRUE when unmanaged by internal decision (ie, * because NM is sleeping or not managed for some other reason) * @NM_UNMANAGED_USER: %TRUE when unmanaged by user decision (via unmanaged-specs) + * @NM_UNMANAGED_PARENT: %TRUE when unmanaged due to parent device being unmanaged */ typedef enum { NM_UNMANAGED_NONE = 0x00, NM_UNMANAGED_DEFAULT = 0x01, NM_UNMANAGED_INTERNAL = 0x02, NM_UNMANAGED_USER = 0x04, + NM_UNMANAGED_PARENT = 0x08, /* Boundary value */ __NM_UNMANAGED_LAST,