diff options
author | Thomas Haller <thaller@redhat.com> | 2015-06-29 16:20:15 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-06-30 16:45:57 +0200 |
commit | 5ad0c2ea064e6eb2d02a2c52635c58bb982042e1 (patch) | |
tree | 66d3070de50d00d8d7ebebe457d97624c95a3878 | |
parent | 008bf6ecb2706eedcd17e60c2579b8033dad529f (diff) | |
download | NetworkManager-5ad0c2ea064e6eb2d02a2c52635c58bb982042e1.tar.gz |
device: remove default-unmanagedlr/default-unmanaged-bgo746566-2
Also add an explicit unmanaged-flag "NM_UNMANAGED_LOOPBACK".
We currently cannot manager loopback because we might end up
down the interface or remove 127.0.0.1 address. Later we want
to fix that and be able to manager "lo" too.
https://bugzilla.gnome.org/show_bug.cgi?id=746566
TODO: is UNMANAGED_USER appropriate for generic / veth?
-rw-r--r-- | src/devices/nm-device-generic.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device.c | 84 | ||||
-rw-r--r-- | src/devices/nm-device.h | 4 | ||||
-rw-r--r-- | src/nm-manager.c | 34 |
4 files changed, 29 insertions, 95 deletions
diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index 5841d834ff..07c7811dea 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -112,7 +112,7 @@ nm_device_generic_new (NMPlatformLink *platform_device) static void nm_device_generic_init (NMDeviceGeneric *self) { - nm_device_set_initial_unmanaged_flag (NM_DEVICE (self), NM_UNMANAGED_DEFAULT, TRUE); + nm_device_set_initial_unmanaged_flag (NM_DEVICE (self), NM_UNMANAGED_USER, TRUE); } static void diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index da9a754b94..8345f1f564 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -362,8 +362,6 @@ static NMActStageReturn linklocal6_start (NMDevice *self); static void _carrier_wait_check_queued_act_request (NMDevice *self); -static gboolean nm_device_get_default_unmanaged (NMDevice *self); - static void _set_state_full (NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, @@ -1136,18 +1134,16 @@ nm_device_finish_init (NMDevice *self) if (priv->ifindex > 0) { if (priv->ifindex == 1) { - /* keep 'lo' as default-unmanaged. */ - - /* FIXME: either find a better way to unmange 'lo' that cannot be changed - * by user configuration (NM_UNMANGED_LOOPBACK?) or fix managing 'lo'. - * Currently it can happen that NM deletes 127.0.0.1 address. */ - nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_DEFAULT, TRUE); + /* Unmanaged the loopback device with an explicit NM_UNMANAGED_LOOPBACK flag. + * Later we might want to manage 'lo' too. Currently that doesn't work because + * NetworkManager might down the interface or remove the 127.0.0.1 address. */ + nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_LOOPBACK, TRUE); } else if (priv->platform_link_initialized || (priv->is_nm_owned && nm_device_is_software (self))) { gboolean platform_unmanaged = FALSE; if (!nm_platform_link_get_unmanaged (NM_PLATFORM_GET, priv->ifindex, &platform_unmanaged)) platform_unmanaged = FALSE; - nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_DEFAULT, platform_unmanaged); + nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_USER, platform_unmanaged); } else { /* Hardware and externally-created software links stay unmanaged * until they are fully initialized by the platform. NM created @@ -1487,7 +1483,7 @@ device_link_changed (NMDevice *self) platform_unmanaged = FALSE; nm_device_set_unmanaged (self, - NM_UNMANAGED_DEFAULT, + NM_UNMANAGED_USER, platform_unmanaged, NM_DEVICE_STATE_REASON_USER_REQUESTED); @@ -2053,18 +2049,11 @@ nm_device_set_autoconnect (NMDevice *self, gboolean autoconnect) g_return_if_fail (NM_IS_DEVICE (self)); - priv = NM_DEVICE_GET_PRIVATE (self); - if (priv->autoconnect == autoconnect) - return; + autoconnect = !!autoconnect; - if (autoconnect) { - /* Default-unmanaged devices never autoconnect */ - if (!nm_device_get_default_unmanaged (self)) { - priv->autoconnect = TRUE; - g_object_notify (G_OBJECT (self), NM_DEVICE_AUTOCONNECT); - } - } else { - priv->autoconnect = FALSE; + priv = NM_DEVICE_GET_PRIVATE (self); + if (priv->autoconnect != autoconnect) { + priv->autoconnect = autoconnect; g_object_notify (G_OBJECT (self), NM_DEVICE_AUTOCONNECT); } } @@ -6132,7 +6121,7 @@ _device_activate (NMDevice *self, NMActRequest *req) delete_on_deactivate_unschedule (self); /* Move default unmanaged devices to DISCONNECTED state here */ - if (nm_device_get_default_unmanaged (self) && priv->state == NM_DEVICE_STATE_UNMANAGED) { + if (priv->state == NM_DEVICE_STATE_UNMANAGED) { nm_device_state_changed (self, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NOW_MANAGED); @@ -7321,22 +7310,18 @@ gboolean nm_device_get_managed (NMDevice *self) { NMDevicePrivate *priv; - gboolean managed; g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); priv = NM_DEVICE_GET_PRIVATE (self); - /* Return the composite of all managed flags. However, if the device - * is a default-unmanaged device, and would be managed except for the - * default-unmanaged flag (eg, only NM_UNMANAGED_DEFAULT is set) then - * the device is managed whenever it's not in the UNMANAGED state. - */ - managed = !(priv->unmanaged_flags & ~NM_UNMANAGED_DEFAULT); - if (managed && (priv->unmanaged_flags & NM_UNMANAGED_DEFAULT)) - managed = (priv->state > NM_DEVICE_STATE_UNMANAGED); + if (priv->state > NM_DEVICE_STATE_UNMANAGED) + return TRUE; + + if (priv->unmanaged_flags) + return FALSE; - return managed; + return TRUE; } /** @@ -7351,18 +7336,6 @@ nm_device_get_unmanaged_flag (NMDevice *self, NMUnmanagedFlags flag) return NM_FLAGS_ANY (NM_DEVICE_GET_PRIVATE (self)->unmanaged_flags, flag); } -/** - * nm_device_get_default_unmanaged(): - * @self: the #NMDevice - * - * Returns: %TRUE if the device is by default unmanaged - */ -static gboolean -nm_device_get_default_unmanaged (NMDevice *self) -{ - return nm_device_get_unmanaged_flag (self, NM_UNMANAGED_DEFAULT); -} - static void _set_unmanaged_flags (NMDevice *self, NMUnmanagedFlags flags, @@ -7564,7 +7537,7 @@ nm_device_check_connection_available (NMDevice *self, if (state < NM_DEVICE_STATE_UNMANAGED) return FALSE; if ( state < NM_DEVICE_STATE_UNAVAILABLE - && nm_device_get_unmanaged_flag (self, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT)) + && nm_device_get_unmanaged_flag (self, NM_UNMANAGED_ALL)) return FALSE; if ( state < NM_DEVICE_STATE_DISCONNECTED && ( ( !NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER) @@ -8312,8 +8285,7 @@ _set_state_full (NMDevice *self, } /* Update the available connections list when a device first becomes available */ - if ( (state >= NM_DEVICE_STATE_DISCONNECTED && old_state < NM_DEVICE_STATE_DISCONNECTED) - || nm_device_get_default_unmanaged (self)) + if (state >= NM_DEVICE_STATE_DISCONNECTED && old_state < NM_DEVICE_STATE_DISCONNECTED) nm_device_recheck_available_connections (self); /* Handle the new state here; but anything that could trigger @@ -8413,11 +8385,7 @@ _set_state_full (NMDevice *self, NM_DEVICE_STATE_REASON_NONE, NM_DEVICE_STATE_REASON_NONE); } else { - if (old_state == NM_DEVICE_STATE_UNMANAGED) - _LOGD (LOGD_DEVICE, "device not yet available for transition to DISCONNECTED"); - else if ( old_state > NM_DEVICE_STATE_UNAVAILABLE - && nm_device_get_default_unmanaged (self)) - nm_device_queue_state (self, NM_DEVICE_STATE_UNMANAGED, NM_DEVICE_STATE_REASON_NONE); + _LOGD (LOGD_DEVICE, "device not yet available for transition to DISCONNECTED"); } break; case NM_DEVICE_STATE_DEACTIVATING: @@ -8461,9 +8429,6 @@ _set_state_full (NMDevice *self, break; /* fall through */ } - if ( old_state > NM_DEVICE_STATE_DISCONNECTED - && nm_device_get_default_unmanaged (self)) - nm_device_queue_state (self, NM_DEVICE_STATE_UNMANAGED, NM_DEVICE_STATE_REASON_NONE); break; case NM_DEVICE_STATE_ACTIVATED: _LOGI (LOGD_DEVICE, "Activation: successful, device activated."); @@ -8996,15 +8961,6 @@ constructed (GObject *object) G_CALLBACK (cp_connection_updated), self); - /* Update default-unmanaged device available connections immediately, - * since they don't transition from UNMANAGED (and thus the state handler - * doesn't run and update them) until something external happens. - */ - if (nm_device_get_default_unmanaged (self)) { - nm_device_set_autoconnect (self, FALSE); - nm_device_recheck_available_connections (self); - } - G_OBJECT_CLASS (nm_device_parent_class)->constructed (object); } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 469d755ed5..c03c0dbb0e 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -356,7 +356,7 @@ RfKillType nm_device_get_rfkill_type (NMDevice *device); /** * NMUnmanagedFlags: * @NM_UNMANAGED_NONE: placeholder value - * @NM_UNMANAGED_DEFAULT: %TRUE when unmanaged by default (ie, Generic devices) + * @NM_UNMANAGED_LOOPBACK: %TRUE for unmanaging loopback 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) @@ -367,7 +367,7 @@ RfKillType nm_device_get_rfkill_type (NMDevice *device); */ typedef enum { NM_UNMANAGED_NONE = 0, - NM_UNMANAGED_DEFAULT = (1LL << 0), + NM_UNMANAGED_LOOPBACK = (1LL << 0), NM_UNMANAGED_INTERNAL = (1LL << 1), NM_UNMANAGED_USER = (1LL << 2), NM_UNMANAGED_PARENT = (1LL << 3), diff --git a/src/nm-manager.c b/src/nm-manager.c index 73ddd9cd31..2a88a49088 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1611,12 +1611,12 @@ recheck_assume_connection (NMDevice *device, gpointer user_data) { NMManager *self = NM_MANAGER (user_data); NMConnection *connection; - gboolean was_unmanaged = FALSE, success, generated; + gboolean success, generated; NMDeviceState state; if (manager_sleeping (self)) return FALSE; - if (nm_device_get_unmanaged_flag (device, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT)) + if (nm_device_get_unmanaged_flag (device, NM_UNMANAGED_ALL)) return FALSE; state = nm_device_get_state (device); @@ -1630,34 +1630,12 @@ recheck_assume_connection (NMDevice *device, gpointer user_data) return FALSE; } - if (state == NM_DEVICE_STATE_UNMANAGED) { - was_unmanaged = TRUE; - nm_device_state_changed (device, - NM_DEVICE_STATE_UNAVAILABLE, - NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); - } - success = assume_connection (self, device, connection); - if (!success) { - if (was_unmanaged) { - nm_device_state_changed (device, - NM_DEVICE_STATE_UNAVAILABLE, - NM_DEVICE_STATE_REASON_CONFIG_FAILED); + if (!success && generated) { + nm_log_dbg (LOGD_DEVICE, "(%s): connection assumption failed. Deleting generated connection", + nm_device_get_iface (device)); - /* Return default-unmanaged devices to their original state */ - if (nm_device_get_unmanaged_flag (device, NM_UNMANAGED_DEFAULT)) { - nm_device_state_changed (device, - NM_DEVICE_STATE_UNMANAGED, - NM_DEVICE_STATE_REASON_CONFIG_FAILED); - } - } - - if (generated) { - nm_log_dbg (LOGD_DEVICE, "(%s): connection assumption failed. Deleting generated connection", - nm_device_get_iface (device)); - - nm_settings_connection_delete (NM_SETTINGS_CONNECTION (connection), NULL, NULL); - } + nm_settings_connection_delete (NM_SETTINGS_CONNECTION (connection), NULL, NULL); } return success; |