From 1d1947b25ea190a17fcd149fdbeadcdd6c73bdc2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 20 Feb 2015 23:45:23 +0100 Subject: [PATCH 01/13] device: fix leaking queued NMActiveConnection The queued activation request must transition state to DEACTIVATED, otherwise it is not removed from the list of active_connections in NMManager. (cherry picked from commit b9da094da90a54a591f25245a2d703a2bac3aab9) --- src/devices/nm-device.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index dd8fd8f380..dc41341c63 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -5578,6 +5578,15 @@ disconnect_cb (NMDevice *self, } } +static void +_clear_queued_act_request (NMDevicePrivate *priv) +{ + if (priv->queued_act_request) { + nm_active_connection_set_state ((NMActiveConnection *) priv->queued_act_request, NM_ACTIVE_CONNECTION_STATE_DEACTIVATED); + g_clear_object (&priv->queued_act_request); + } +} + static void impl_device_disconnect (NMDevice *self, DBusGMethodInvocation *context) { @@ -5692,7 +5701,7 @@ nm_device_queue_activation (NMDevice *self, NMActRequest *req) } /* supercede any already-queued request */ - g_clear_object (&priv->queued_act_request); + _clear_queued_act_request (priv); priv->queued_act_request = g_object_ref (req); /* Deactivate existing activation request first */ @@ -7489,7 +7498,7 @@ _set_state_full (NMDevice *self, if (state <= NM_DEVICE_STATE_UNAVAILABLE) { _clear_available_connections (self, TRUE); - g_clear_object (&priv->queued_act_request); + _clear_queued_act_request (priv); } /* Update the available connections list when a device first becomes available */ @@ -8201,7 +8210,7 @@ dispose (GObject *object) priv->carrier_wait_id = 0; } - g_clear_object (&priv->queued_act_request); + _clear_queued_act_request (priv); platform = nm_platform_get (); g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (device_ip_changed), self); From b09b501766c3d4deac2f1b5f02648529809611e6 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 16 Jan 2015 18:11:10 +0100 Subject: [PATCH 02/13] device: don't add dummy value to @available_connections hash GHashTable is optimized for usage of a set, where the key equals the value. Don't add a dummy value. (cherry picked from commit 3cb5d20c34d592b0face47b06823cd5739f0597d) --- src/devices/nm-device.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index dc41341c63..c2c2a3f63f 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6874,9 +6874,8 @@ _try_add_available_connection (NMDevice *self, NMConnection *connection) if (nm_device_check_connection_compatible (self, connection)) { if (NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NULL)) { - g_hash_table_insert (NM_DEVICE_GET_PRIVATE (self)->available_connections, - g_object_ref (connection), - GUINT_TO_POINTER (1)); + g_hash_table_add (NM_DEVICE_GET_PRIVATE (self)->available_connections, + g_object_ref (connection)); return TRUE; } } From b2d0bd8afe770ed1ea386a1082ed387ccbe1857a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 6 Dec 2014 14:59:25 +0100 Subject: [PATCH 03/13] device: don't remove and re-add pending action in nm_device_bring_up() (cherry picked from commit dba5e8e7318e10ea7db8f5a5ae58fa5d6a84d60c) --- src/devices/nm-device.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index c2c2a3f63f..c8d742a6ce 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6314,12 +6314,11 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) * a timeout is reached. */ if (device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) { - if (priv->carrier_wait_id) { + if (priv->carrier_wait_id) g_source_remove (priv->carrier_wait_id); - nm_device_remove_pending_action (self, "carrier wait", TRUE); - } + else + nm_device_add_pending_action (self, "carrier wait", TRUE); priv->carrier_wait_id = g_timeout_add_seconds (5, carrier_wait_timeout, self); - nm_device_add_pending_action (self, "carrier wait", TRUE); } /* Can only get HW address of some devices when they are up */ From 1158fd4f5b54baca015f59050e8ebd13fbb3a52f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 20 Jan 2015 20:44:46 +0100 Subject: [PATCH 04/13] device: add special NM_UNMANAGED_ALL flag (cherry picked from commit aefd269308b6f50c90883bf315510ad7d3d7a414) --- src/devices/nm-device.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index b3855c7446..519ccc48ff 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -316,7 +316,8 @@ typedef enum { /* Boundary value */ __NM_UNMANAGED_LAST, - NM_UNMANAGED_LAST = __NM_UNMANAGED_LAST - 1, + NM_UNMANAGED_LAST = __NM_UNMANAGED_LAST - 1, + NM_UNMANAGED_ALL = ((NM_UNMANAGED_LAST << 1) - 1), } NMUnmanagedFlags; gboolean nm_device_get_managed (NMDevice *device); From a042cec8a9dd046f37d0efaeebd75cd5fe425e1b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 8 Dec 2014 11:30:48 +0100 Subject: [PATCH 05/13] device/trivial: rename argument in nm_device_connection_is_available() The argument name should express what the caller wants (he wants to know, whether the connection can be activated for an internal or external activation request). Whether that involves checking device-specific overrides, is not the point -- nm_device_check_connection_compatible() is also a virtual function with device-specific overrides. (cherry picked from commit a7e0a038bf35e7d19ef859ff5035019c1bc0cad3) --- src/devices/nm-device.c | 10 ++++++---- src/devices/nm-device.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index c8d742a6ce..461be3f50e 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6809,11 +6809,13 @@ nm_device_set_dhcp_anycast_address (NMDevice *self, const char *addr) * nm_device_connection_is_available(): * @self: the #NMDevice * @connection: the #NMConnection to check for availability - * @allow_device_override: set to %TRUE to let the device do specific checks + * @for_user_activation_request: set to %TRUE if we are checking whether + * the connection is available on an explicit user request. This + * also checks for device specific overrides. * * Check if @connection is available to be activated on @self. Normally this * only checks if the connection is in @self's AvailableConnections property. - * If @allow_device_override is %TRUE then the device is asked to do specific + * If @for_user_activation_request is %TRUE then the device is asked to do specific * checks that may bypass the AvailableConnections property. * * Returns: %TRUE if @connection can be activated on @self @@ -6821,7 +6823,7 @@ nm_device_set_dhcp_anycast_address (NMDevice *self, const char *addr) gboolean nm_device_connection_is_available (NMDevice *self, NMConnection *connection, - gboolean allow_device_override) + gboolean for_user_activation_request) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); gboolean available = FALSE; @@ -6836,7 +6838,7 @@ nm_device_connection_is_available (NMDevice *self, } available = !!g_hash_table_lookup (priv->available_connections, connection); - if (!available && allow_device_override) { + if (!available && for_user_activation_request) { /* FIXME: hack for hidden WiFi becuase clients didn't consistently * set the 'hidden' property to indicate hidden SSID networks. If * activating but the network isn't available let the device recheck diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 519ccc48ff..3ba23d9400 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -363,7 +363,7 @@ GPtrArray *nm_device_get_available_connections (NMDevice *device, gboolean nm_device_connection_is_available (NMDevice *device, NMConnection *connection, - gboolean allow_device_override); + gboolean for_user_activation_request); gboolean nm_device_notify_component_added (NMDevice *device, GObject *component); From e7c8affef54f71dff7f8b4c6906d7c4109754817 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 8 Dec 2014 12:15:02 +0100 Subject: [PATCH 06/13] device: refactor nm_device_connection_is_available() No functional change, but refactor the function to return early. (cherry picked from commit 364c4476e392cad1ef076a473e0462174cf14bd0) --- src/devices/nm-device.c | 48 ++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 461be3f50e..27c150c58e 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6826,30 +6826,44 @@ nm_device_connection_is_available (NMDevice *self, gboolean for_user_activation_request) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - gboolean available = FALSE; + gboolean is_default_unmanaged; - if (nm_device_get_default_unmanaged (self) && (priv->state == NM_DEVICE_STATE_UNMANAGED)) { + if (g_hash_table_contains (priv->available_connections, connection)) + return TRUE; + + is_default_unmanaged = priv->state == NM_DEVICE_STATE_UNMANAGED && nm_device_get_default_unmanaged (self); + + if (!for_user_activation_request && !is_default_unmanaged) { + /* Shortcut: there are only additional checks for either @for_user_activation_request + * or @is_default_unmanaged. Return FALSE right away. */ + return FALSE; + } + + if (!nm_device_check_connection_compatible (self, connection)) { + /* An incompatilbe connection is never available. */ + return FALSE; + } + + if ( is_default_unmanaged + && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NULL)) { /* default-unmanaged devices in UNMANAGED state have no available connections - * so we must manually check whether the connection is available here. - */ - if ( nm_device_check_connection_compatible (self, connection) - && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NULL)) - return TRUE; + * so we must manually check whether the connection is available here. */ + return TRUE; } - available = !!g_hash_table_lookup (priv->available_connections, connection); - if (!available && for_user_activation_request) { - /* FIXME: hack for hidden WiFi becuase clients didn't consistently - * set the 'hidden' property to indicate hidden SSID networks. If - * activating but the network isn't available let the device recheck - * availability. + if ( for_user_activation_request + && NM_DEVICE_GET_CLASS (self)->check_connection_available_wifi_hidden + && NM_DEVICE_GET_CLASS (self)->check_connection_available_wifi_hidden (self, connection)) { + /* Connections for an explicit user activation request might only be available after + * additional checking. + * + * For example in case of hidden Wi-Fi, the connection might not have the 'hidden' property + * set. Support this by allowing device specific overrides. */ - if ( nm_device_check_connection_compatible (self, connection) - && NM_DEVICE_GET_CLASS (self)->check_connection_available_wifi_hidden) - available = NM_DEVICE_GET_CLASS (self)->check_connection_available_wifi_hidden (self, connection); + return TRUE; } - return available; + return FALSE; } static void From 2799d502a1d437ed9f9f51ef1ada2ea893f1b1af Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 8 Dec 2014 12:39:45 +0100 Subject: [PATCH 07/13] device: merge check_connection_available_wifi_hidden() into check_connection_available() Only refactoring, no behavioral change. (cherry picked from commit 5a042737152b928f5cd9d0e874df5952be219c12) --- src/devices/bluetooth/nm-device-bt.c | 1 + src/devices/nm-device-bond.c | 1 + src/devices/nm-device-bridge.c | 1 + src/devices/nm-device.c | 11 ++++---- src/devices/nm-device.h | 14 +++++----- src/devices/team/nm-device-team.c | 1 + src/devices/wifi/nm-device-wifi.c | 39 ++++++++++------------------ src/devices/wimax/nm-device-wimax.c | 1 + src/devices/wwan/nm-device-modem.c | 1 + 9 files changed, 33 insertions(+), 37 deletions(-) diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index 689f37c9b4..7b1b3fde5e 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -187,6 +187,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, + gboolean for_user_activation_request, const char *specific_object) { NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 9d9fe426b2..50793f6268 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -77,6 +77,7 @@ is_available (NMDevice *dev) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, + gboolean for_user_activation_request, const char *specific_object) { /* Connections are always available because the carrier state is determined diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index a70cfd9571..53d5bef33b 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -76,6 +76,7 @@ is_available (NMDevice *dev) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, + gboolean for_user_activation_request, const char *specific_object) { /* Connections are always available because the carrier state is determined diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 27c150c58e..fc9ac1b18e 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6845,15 +6845,15 @@ nm_device_connection_is_available (NMDevice *self, } if ( is_default_unmanaged - && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NULL)) { + && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, NULL)) { /* default-unmanaged devices in UNMANAGED state have no available connections * so we must manually check whether the connection is available here. */ return TRUE; } if ( for_user_activation_request - && NM_DEVICE_GET_CLASS (self)->check_connection_available_wifi_hidden - && NM_DEVICE_GET_CLASS (self)->check_connection_available_wifi_hidden (self, connection)) { + && NM_DEVICE_GET_CLASS (self)->check_connection_available_has_user_override + && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, TRUE, NULL)) { /* Connections for an explicit user activation request might only be available after * additional checking. * @@ -6888,7 +6888,7 @@ _try_add_available_connection (NMDevice *self, NMConnection *connection) return FALSE; if (nm_device_check_connection_compatible (self, connection)) { - if (NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NULL)) { + if (NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, NULL)) { g_hash_table_add (NM_DEVICE_GET_PRIVATE (self)->available_connections, g_object_ref (connection)); return TRUE; @@ -6906,6 +6906,7 @@ _del_available_connection (NMDevice *self, NMConnection *connection) static gboolean check_connection_available (NMDevice *self, NMConnection *connection, + gboolean for_user_activation_request, const char *specific_object) { /* Connections which require a network connection are not available when @@ -6967,7 +6968,7 @@ nm_device_get_available_connections (NMDevice *self, const char *specific_object * compatible with it. */ if ( !specific_object - || NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, specific_object)) + || NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, specific_object)) g_ptr_array_add (array, connection); } } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 3ba23d9400..631345fdf5 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -136,18 +136,18 @@ typedef struct { * including any live network information like scan lists. The connection * is checked against the object defined by @specific_object, if given. * Returns TRUE if the connection is available; FALSE if not. + * + * If @for_user_activation_request, a connection might be considered + * available under additional circumstances. That means, if a connection + * is available for an internal, non-user request, it also must be available + * for an external, user request. */ gboolean (* check_connection_available) (NMDevice *self, NMConnection *connection, + gboolean for_user_activation_request, const char *specific_object); - /* Same as check_connection_available() but called if the connection - * is not present in the activating-connections array during activation, - * to give the device a chance to allow/deny the activation. This is a - * hack only meant for hidden WiFi networks. - */ - gboolean (* check_connection_available_wifi_hidden) (NMDevice *self, - NMConnection *connection); + gboolean check_connection_available_has_user_override; gboolean (* complete_connection) (NMDevice *self, NMConnection *connection, diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index ab58c9daec..8cda5a85b2 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -85,6 +85,7 @@ is_available (NMDevice *device) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, + gboolean for_user_activation_request, const char *specific_object) { /* Connections are always available because the carrier state is determined diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index dd7754b33e..9fdf53968f 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -863,10 +863,10 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) static gboolean -_internal_check_connection_available (NMDevice *device, - NMConnection *connection, - const char *specific_object, - gboolean ignore_ap_list) +check_connection_available (NMDevice *device, + NMConnection *connection, + gboolean for_user_activation_request, + const char *specific_object) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device); NMSettingWireless *s_wifi; @@ -891,8 +891,15 @@ _internal_check_connection_available (NMDevice *device, || g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_AP) == 0) return TRUE; - /* Hidden SSIDs obviously don't always appear in the scan list either */ - if (nm_setting_wireless_get_hidden (s_wifi) || ignore_ap_list) + /* Hidden SSIDs obviously don't always appear in the scan list either. + * + * For an explict user-activation-request, a connection is considered + * available because for hidden Wi-Fi, clients didn't consistently + * set the 'hidden' property to indicate hidden SSID networks. If + * activating but the network isn't available let the device recheck + * availability. + */ + if (nm_setting_wireless_get_hidden (s_wifi) || for_user_activation_request) return TRUE; /* check if its visible */ @@ -904,24 +911,6 @@ _internal_check_connection_available (NMDevice *device, return FALSE; } -static gboolean -check_connection_available (NMDevice *device, - NMConnection *connection, - const char *specific_object) -{ - return _internal_check_connection_available (device, connection, specific_object, FALSE); -} - -/* FIXME: remove this function when we require the 'hidden' property to be - * set before a hidden connection can be activated. - */ -static gboolean -check_connection_available_wifi_hidden (NMDevice *device, - NMConnection *connection) -{ - return _internal_check_connection_available (device, connection, NULL, TRUE); -} - /* * List of manufacturer default SSIDs that are often unchanged by users. * @@ -3335,7 +3324,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) parent_class->is_available = is_available; parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_available = check_connection_available; - parent_class->check_connection_available_wifi_hidden = check_connection_available_wifi_hidden; + parent_class->check_connection_available_has_user_override = TRUE; parent_class->complete_connection = complete_connection; parent_class->set_enabled = set_enabled; diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c index 466cd97930..a7f63fdc97 100644 --- a/src/devices/wimax/nm-device-wimax.c +++ b/src/devices/wimax/nm-device-wimax.c @@ -334,6 +334,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, + gboolean for_user_activation_request, const char *specific_object) { NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device); diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index 0ca1056edf..4cf7901320 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -394,6 +394,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, + gboolean for_user_activation_request, const char *specific_object) { NMDeviceModem *self = NM_DEVICE_MODEM (device); From 3a5cee2a99495179b303cfafc28d756cc6002b9b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 16 Jan 2015 14:54:11 +0100 Subject: [PATCH 08/13] device: add flags argument to check_connection_available() (cherry picked from commit e96af59444eb2f449271bd3896c47c68ebb33a5c) --- src/devices/bluetooth/nm-device-bt.c | 2 +- src/devices/nm-device-bond.c | 2 +- src/devices/nm-device-bridge.c | 2 +- src/devices/nm-device.c | 10 +++++----- src/devices/nm-device.h | 24 +++++++++++++++++++----- src/devices/team/nm-device-team.c | 2 +- src/devices/wifi/nm-device-wifi.c | 7 +++++-- src/devices/wimax/nm-device-wimax.c | 5 ++++- src/devices/wwan/nm-device-modem.c | 2 +- 9 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index 7b1b3fde5e..8a89cc83da 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -187,7 +187,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, - gboolean for_user_activation_request, + NMDeviceCheckConAvailableFlags flags, const char *specific_object) { NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 50793f6268..2637f5c7b9 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -77,7 +77,7 @@ is_available (NMDevice *dev) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, - gboolean for_user_activation_request, + NMDeviceCheckConAvailableFlags flags, const char *specific_object) { /* Connections are always available because the carrier state is determined diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 53d5bef33b..92c29387c4 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -76,7 +76,7 @@ is_available (NMDevice *dev) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, - gboolean for_user_activation_request, + NMDeviceCheckConAvailableFlags flags, const char *specific_object) { /* Connections are always available because the carrier state is determined diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index fc9ac1b18e..860c81add9 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6845,7 +6845,7 @@ nm_device_connection_is_available (NMDevice *self, } if ( is_default_unmanaged - && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, NULL)) { + && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL)) { /* default-unmanaged devices in UNMANAGED state have no available connections * so we must manually check whether the connection is available here. */ return TRUE; @@ -6853,7 +6853,7 @@ nm_device_connection_is_available (NMDevice *self, if ( for_user_activation_request && NM_DEVICE_GET_CLASS (self)->check_connection_available_has_user_override - && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, TRUE, NULL)) { + && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, NULL)) { /* Connections for an explicit user activation request might only be available after * additional checking. * @@ -6888,7 +6888,7 @@ _try_add_available_connection (NMDevice *self, NMConnection *connection) return FALSE; if (nm_device_check_connection_compatible (self, connection)) { - if (NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, NULL)) { + if (NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL)) { g_hash_table_add (NM_DEVICE_GET_PRIVATE (self)->available_connections, g_object_ref (connection)); return TRUE; @@ -6906,7 +6906,7 @@ _del_available_connection (NMDevice *self, NMConnection *connection) static gboolean check_connection_available (NMDevice *self, NMConnection *connection, - gboolean for_user_activation_request, + NMDeviceCheckConAvailableFlags flags, const char *specific_object) { /* Connections which require a network connection are not available when @@ -6968,7 +6968,7 @@ nm_device_get_available_connections (NMDevice *self, const char *specific_object * compatible with it. */ if ( !specific_object - || NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, specific_object)) + || NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, specific_object)) g_ptr_array_add (array, connection); } } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 631345fdf5..5ba79d0042 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -85,6 +85,19 @@ G_BEGIN_DECLS typedef enum NMActStageReturn NMActStageReturn; +/* These flags affect whether a connection is considered available on a device + * (check_connection_available()). The flags should have the meaning of relaxing + * a condition, so that adding a flag might make a connection available that would + * not be available otherwise. Adding a flag should never make a connection + * not available if it would be available otherwise. */ +typedef enum { + NM_DEVICE_CHECK_CON_AVAILABLE_NONE = 0, + NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST = (1L << 0), + + __NM_DEVICE_CHECK_CON_AVAILABLE_ALL, + NM_DEVICE_CHECK_CON_AVAILABLE_ALL = (((__NM_DEVICE_CHECK_CON_AVAILABLE_ALL - 1) << 1) - 1), +} NMDeviceCheckConAvailableFlags; + struct _NMDevice { GObject parent; }; @@ -137,14 +150,15 @@ typedef struct { * is checked against the object defined by @specific_object, if given. * Returns TRUE if the connection is available; FALSE if not. * - * If @for_user_activation_request, a connection might be considered - * available under additional circumstances. That means, if a connection - * is available for an internal, non-user request, it also must be available - * for an external, user request. + * The passed @flags affect whether a connection is considered + * available or not. Adding more flags, means the connection is + * *more* available. + * + * Specifying @specific_object can only reduce the availability of a connection. */ gboolean (* check_connection_available) (NMDevice *self, NMConnection *connection, - gboolean for_user_activation_request, + NMDeviceCheckConAvailableFlags flags, const char *specific_object); gboolean check_connection_available_has_user_override; diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 8cda5a85b2..29a6401646 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -85,7 +85,7 @@ is_available (NMDevice *device) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, - gboolean for_user_activation_request, + NMDeviceCheckConAvailableFlags flags, const char *specific_object) { /* Connections are always available because the carrier state is determined diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 9fdf53968f..5c57a60086 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -865,7 +865,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, - gboolean for_user_activation_request, + NMDeviceCheckConAvailableFlags flags, const char *specific_object) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device); @@ -876,6 +876,9 @@ check_connection_available (NMDevice *device, s_wifi = nm_connection_get_setting_wireless (connection); g_return_val_if_fail (s_wifi, FALSE); + /* a connection that is available for a certain @specific_object, MUST + * also be available in general (without @specific_object). */ + if (specific_object) { NMAccessPoint *ap; @@ -899,7 +902,7 @@ check_connection_available (NMDevice *device, * activating but the network isn't available let the device recheck * availability. */ - if (nm_setting_wireless_get_hidden (s_wifi) || for_user_activation_request) + if (nm_setting_wireless_get_hidden (s_wifi) || NM_FLAGS_HAS (flags, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST)) return TRUE; /* check if its visible */ diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c index a7f63fdc97..2611186964 100644 --- a/src/devices/wimax/nm-device-wimax.c +++ b/src/devices/wimax/nm-device-wimax.c @@ -334,13 +334,16 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, - gboolean for_user_activation_request, + NMDeviceCheckConAvailableFlags flags, const char *specific_object) { NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device); const GSList *ns_iter = NULL; NMWimaxNsp *nsp; + /* a connection that is available for a certain @specific_object, MUST + * also be available in general (without @specific_object). */ + if (specific_object) { nsp = get_nsp_by_path (NM_DEVICE_WIMAX (device), specific_object); return nsp ? nm_wimax_nsp_check_compatible (nsp, connection) : FALSE; diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index 4cf7901320..c3175566ef 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -394,7 +394,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) static gboolean check_connection_available (NMDevice *device, NMConnection *connection, - gboolean for_user_activation_request, + NMDeviceCheckConAvailableFlags flags, const char *specific_object) { NMDeviceModem *self = NM_DEVICE_MODEM (device); From ba52457f4df8fc15df29d5b333e6dcdd76a440f0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 20 Jan 2015 20:25:25 +0100 Subject: [PATCH 09/13] device: add flags to nm_device_is_available() (cherry picked from commit 52dbb2398a89134fe2c0bc19d032b985c7464c08) --- src/devices/bluetooth/nm-device-bt.c | 6 +++--- src/devices/nm-device-bond.c | 2 +- src/devices/nm-device-bridge.c | 2 +- src/devices/nm-device.c | 10 ++++++---- src/devices/nm-device.h | 13 +++++++++++-- src/devices/team/nm-device-team.c | 2 +- src/devices/wifi/nm-device-olpc-mesh.c | 2 +- src/devices/wifi/nm-device-wifi.c | 4 ++-- src/devices/wimax/nm-device-wimax.c | 10 +++++----- src/devices/wwan/nm-device-modem.c | 6 +++--- src/nm-manager.c | 2 +- 11 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index 8a89cc83da..61371dddec 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -930,7 +930,7 @@ bluez_device_removed (NMBluezDevice *bdev, gpointer user_data) /*****************************************************************************/ static gboolean -is_available (NMDevice *dev) +is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags) { NMDeviceBt *self = NM_DEVICE_BT (dev); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self); @@ -958,7 +958,7 @@ handle_availability_change (NMDeviceBt *self, return; } - available = nm_device_is_available (device); + available = nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE); if (available == old_available) return; @@ -988,7 +988,7 @@ set_mm_running (NMDeviceBt *self, gboolean running) _LOGD (LOGD_BT, "ModemManager now %s", running ? "available" : "unavailable"); - old_available = nm_device_is_available (NM_DEVICE (self)); + old_available = nm_device_is_available (NM_DEVICE (self), NM_DEVICE_CHECK_DEV_AVAILABLE_NONE); priv->mm_running = running; handle_availability_change (self, old_available, NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE); diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 2637f5c7b9..0b2c97d148 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -67,7 +67,7 @@ get_generic_capabilities (NMDevice *dev) } static gboolean -is_available (NMDevice *dev) +is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags) { if (NM_DEVICE_GET_CLASS (dev)->is_up) return NM_DEVICE_GET_CLASS (dev)->is_up (dev); diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 92c29387c4..a2ed4b4176 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -66,7 +66,7 @@ get_generic_capabilities (NMDevice *dev) } static gboolean -is_available (NMDevice *dev) +is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags) { if (NM_DEVICE_GET_CLASS (dev)->is_up) return NM_DEVICE_GET_CLASS (dev)->is_up (dev); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 860c81add9..28ea5ecdcd 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1726,7 +1726,7 @@ nm_device_removed (NMDevice *self) static gboolean -is_available (NMDevice *self) +is_available (NMDevice *self, NMDeviceCheckDevAvailableFlags flags) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); @@ -1736,6 +1736,8 @@ is_available (NMDevice *self) /** * nm_device_is_available: * @self: the #NMDevice + * @flags: additional flags to influence the check. Flags have the + * meaning to increase the availability of a device. * * Checks if @self would currently be capable of activating a * connection. In particular, it checks that the device is ready (eg, @@ -1751,14 +1753,14 @@ is_available (NMDevice *self) * Returns: %TRUE or %FALSE */ gboolean -nm_device_is_available (NMDevice *self) +nm_device_is_available (NMDevice *self, NMDeviceCheckDevAvailableFlags flags) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); if (priv->firmware_missing) return FALSE; - return NM_DEVICE_GET_CLASS (self)->is_available (self); + return NM_DEVICE_GET_CLASS (self)->is_available (self, flags); } gboolean @@ -7609,7 +7611,7 @@ _set_state_full (NMDevice *self, * we can't change states again from the state handler for a variety of * reasons. */ - if (nm_device_is_available (self)) { + if (nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) { _LOGD (LOGD_DEVICE, "device is available, will transition to DISCONNECTED"); nm_device_queue_state (self, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE); } else { diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 5ba79d0042..bfded2f0e8 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -102,6 +102,15 @@ struct _NMDevice { GObject parent; }; +/* The flags have an relaxing meaning, that means, specifying more flags, can make + * a device appear more available. It can never make a device less available. */ +typedef enum { + NM_DEVICE_CHECK_DEV_AVAILABLE_NONE = 0, + + __NM_DEVICE_CHECK_DEV_AVAILABLE_ALL, + NM_DEVICE_CHECK_DEV_AVAILABLE_ALL = (((__NM_DEVICE_CHECK_DEV_AVAILABLE_ALL - 1) << 1) - 1), +} NMDeviceCheckDevAvailableFlags; + typedef struct { GObjectClass parent; @@ -129,7 +138,7 @@ typedef struct { guint32 (* get_generic_capabilities) (NMDevice *self); - gboolean (* is_available) (NMDevice *self); + gboolean (* is_available) (NMDevice *self, NMDeviceCheckDevAvailableFlags flags); gboolean (* get_enabled) (NMDevice *self); @@ -271,7 +280,7 @@ NMConnection * nm_device_get_connection (NMDevice *dev); void nm_device_removed (NMDevice *dev); -gboolean nm_device_is_available (NMDevice *dev); +gboolean nm_device_is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags); gboolean nm_device_has_carrier (NMDevice *dev); NMConnection * nm_device_generate_connection (NMDevice *self, NMDevice *master); diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 29a6401646..2d0e6e0af3 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -75,7 +75,7 @@ get_generic_capabilities (NMDevice *device) } static gboolean -is_available (NMDevice *device) +is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { if (NM_DEVICE_GET_CLASS (device)->is_up) return NM_DEVICE_GET_CLASS (device)->is_up (device); diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 0f5aa16487..dc3dfbc659 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -235,7 +235,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) } static gboolean -is_available (NMDevice *device) +is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 5c57a60086..caebdf53e5 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -1135,7 +1135,7 @@ complete_connection (NMDevice *device, } static gboolean -is_available (NMDevice *device) +is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); @@ -2161,7 +2161,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, /* If the interface can now be activated because the supplicant is now * available, transition to DISCONNECTED. */ - if ((devstate == NM_DEVICE_STATE_UNAVAILABLE) && nm_device_is_available (device)) { + if ((devstate == NM_DEVICE_STATE_UNAVAILABLE) && nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) { nm_device_state_changed (device, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE); diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c index 2611186964..0394617589 100644 --- a/src/devices/wimax/nm-device-wimax.c +++ b/src/devices/wimax/nm-device-wimax.c @@ -239,7 +239,7 @@ update_availability (NMDeviceWimax *self, gboolean old_available) NMDeviceState state; gboolean new_available, changed = FALSE; - new_available = nm_device_is_available (device); + new_available = nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE); if (new_available == old_available) return FALSE; @@ -281,7 +281,7 @@ set_enabled (NMDevice *device, gboolean enabled) if (priv->enabled == enabled) return; - old_available = nm_device_is_available (NM_DEVICE (device)); + old_available = nm_device_is_available (NM_DEVICE (device), NM_DEVICE_CHECK_DEV_AVAILABLE_NONE); priv->enabled = enabled; nm_log_dbg (LOGD_WIMAX, "(%s): radio now %s", @@ -488,7 +488,7 @@ can_auto_connect (NMDevice *device, } static gboolean -is_available (NMDevice *device) +is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device); const char *iface = nm_device_get_iface (device); @@ -716,7 +716,7 @@ wmx_state_change_cb (struct wmxsdk *wmxsdk, return; state = nm_device_get_state (NM_DEVICE (self)); - old_available = nm_device_is_available (NM_DEVICE (self)); + old_available = nm_device_is_available (NM_DEVICE (self), NM_DEVICE_CHECK_DEV_AVAILABLE_NONE); priv->status = new_status; if (priv->current_nsp) @@ -1157,7 +1157,7 @@ static gboolean sdk_action_defer_cb (gpointer user_data) { NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data); - gboolean old_available = nm_device_is_available (NM_DEVICE (self)); + gboolean old_available = nm_device_is_available (NM_DEVICE (self), NM_DEVICE_CHECK_DEV_AVAILABLE_NONE); NM_DEVICE_WIMAX_GET_PRIVATE (self)->sdk_action_defer_id = 0; update_availability (self, old_available); diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index c3175566ef..f45abc5cf7 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -300,14 +300,14 @@ modem_state_cb (NMModem *modem, nm_device_recheck_available_connections (device); } - if ((dev_state >= NM_DEVICE_STATE_DISCONNECTED) && !nm_device_is_available (device)) { + if ((dev_state >= NM_DEVICE_STATE_DISCONNECTED) && !nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) { nm_device_state_changed (device, NM_DEVICE_STATE_UNAVAILABLE, NM_DEVICE_STATE_REASON_MODEM_FAILED); return; } - if ((dev_state == NM_DEVICE_STATE_UNAVAILABLE) && nm_device_is_available (device)) { + if ((dev_state == NM_DEVICE_STATE_UNAVAILABLE) && nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) { nm_device_state_changed (device, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_MODEM_AVAILABLE); @@ -540,7 +540,7 @@ set_enabled (NMDevice *device, gboolean enabled) } static gboolean -is_available (NMDevice *device) +is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { NMDeviceModem *self = NM_DEVICE_MODEM (device); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); diff --git a/src/nm-manager.c b/src/nm-manager.c index 7f4e0b02b4..398b0059ca 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2684,7 +2684,7 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * * in the UNAVAILABLE state here. To ensure it can be activated * immediately, we transition it to DISCONNECTED. */ - if ( nm_device_is_available (device) + if ( nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE) && (nm_device_get_state (device) == NM_DEVICE_STATE_UNAVAILABLE)) { nm_device_state_changed (device, NM_DEVICE_STATE_DISCONNECTED, From 60641b0fa7326c62074c01287227b701247bc1c7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 20 Jan 2015 21:06:31 +0100 Subject: [PATCH 10/13] device: implement flag NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER for is_available() (cherry picked from commit 37ebeccaa7247664d69cdfbdb20861bf78f8d72d) --- src/devices/nm-device.c | 8 +++++++- src/devices/nm-device.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 28ea5ecdcd..f42ce615ec 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1730,7 +1730,13 @@ is_available (NMDevice *self, NMDeviceCheckDevAvailableFlags flags) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - return priv->carrier || priv->ignore_carrier; + if (priv->carrier || priv->ignore_carrier) + return TRUE; + + if (NM_FLAGS_HAS (flags, NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER)) + return TRUE; + + return FALSE; } /** diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index bfded2f0e8..2a7a22a98e 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -92,6 +92,7 @@ typedef enum NMActStageReturn NMActStageReturn; * not available if it would be available otherwise. */ typedef enum { NM_DEVICE_CHECK_CON_AVAILABLE_NONE = 0, + NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST = (1L << 0), __NM_DEVICE_CHECK_CON_AVAILABLE_ALL, @@ -106,6 +107,7 @@ struct _NMDevice { * a device appear more available. It can never make a device less available. */ typedef enum { NM_DEVICE_CHECK_DEV_AVAILABLE_NONE = 0, + NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER = (1L << 0), __NM_DEVICE_CHECK_DEV_AVAILABLE_ALL, NM_DEVICE_CHECK_DEV_AVAILABLE_ALL = (((__NM_DEVICE_CHECK_DEV_AVAILABLE_ALL - 1) << 1) - 1), From 92f42583267d109129b531e689a119984cd66384 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 20 Jan 2015 21:20:32 +0100 Subject: [PATCH 11/13] device: remove debug logging from is_available() Having logging statements in a simple getter (or is_*()) means you cannot call these functions without cluttering the log. Another approach would be to add an @out_reason argument, and callers who actually care log the reason. For now, just get rid of the messages. (cherry picked from commit e524be2c345431c53bc34af6e114c73def1d5891) --- src/devices/wifi/nm-device-wifi.c | 12 +++--------- src/devices/wimax/nm-device-wimax.c | 17 ++++------------- src/devices/wwan/nm-device-modem.c | 11 +++-------- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index caebdf53e5..e4877ea354 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -1141,22 +1141,16 @@ is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); guint32 state; - if (!priv->enabled) { - _LOGD (LOGD_WIFI, "not available because not enabled"); + if (!priv->enabled) return FALSE; - } - if (!priv->sup_iface) { - _LOGD (LOGD_WIFI, "not available because supplicant not running"); + if (!priv->sup_iface) return FALSE; - } state = nm_supplicant_interface_get_state (priv->sup_iface); if ( state < NM_SUPPLICANT_INTERFACE_STATE_READY - || state > NM_SUPPLICANT_INTERFACE_STATE_COMPLETED) { - _LOGD (LOGD_WIFI, "not available because supplicant interface not ready"); + || state > NM_SUPPLICANT_INTERFACE_STATE_COMPLETED) return FALSE; - } return TRUE; } diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c index 0394617589..0c8f1cbbe3 100644 --- a/src/devices/wimax/nm-device-wimax.c +++ b/src/devices/wimax/nm-device-wimax.c @@ -491,27 +491,18 @@ static gboolean is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device); - const char *iface = nm_device_get_iface (device); - if (!priv->enabled) { - nm_log_dbg (LOGD_WIMAX, "(%s): not available because not enabled", iface); + if (!priv->enabled) return FALSE; - } - if (!priv->wimaxd_enabled) { - nm_log_dbg (LOGD_WIMAX, "(%s): not available because not enabled in wimaxd", iface); + if (!priv->wimaxd_enabled) return FALSE; - } - if (!nm_wimax_util_sdk_is_initialized ()) { - nm_log_dbg (LOGD_WIMAX, "(%s): not available because WiMAX SDK not initialized", iface); + if (!nm_wimax_util_sdk_is_initialized ()) return FALSE; - } - if (!priv->sdk) { - nm_log_dbg (LOGD_WIMAX, "(%s): not available because not known to WiMAX SDK", iface); + if (!priv->sdk) return FALSE; - } return iwmxsdk_status_get (priv->sdk) >= WIMAX_API_DEVICE_STATUS_Ready; } diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index f45abc5cf7..8fbbb9a455 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -543,21 +543,16 @@ static gboolean is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) { NMDeviceModem *self = NM_DEVICE_MODEM (device); - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (self); NMModemState modem_state; - if (!priv->rf_enabled) { - _LOGD (LOGD_MB, "not available because WWAN airplane mode is on"); + if (!priv->rf_enabled) return FALSE; - } g_assert (priv->modem); modem_state = nm_modem_get_state (priv->modem); - if (modem_state <= NM_MODEM_STATE_INITIALIZING) { - _LOGD (LOGD_MB, "not available because modem is not ready (%s)", - nm_modem_state_to_string (modem_state)); + if (modem_state <= NM_MODEM_STATE_INITIALIZING) return FALSE; - } return TRUE; } From b6495b500091593c90cad958ce6501c89019ccaa Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 16 Jan 2015 16:43:48 +0100 Subject: [PATCH 12/13] device: eliminate direct calls to check_connection_available() in favor of nm_device_check_connection_available() It was confusing to understand the difference between calling nm_device_connection_is_available() and check_connection_available(), they behaved similar, but not really the same. Especially nm_device_connection_is_available() would look first into @available_connetions, and might call check_connection_available() itself. Whereas @available_connetions was also populated by testing check_connection_available(). This interrelation makes it hard to understand when nm_device_connection_is_available() returned true. Rename nm_device_connection_is_available() to nm_device_check_connection_available() and remove all direct calls of check_connection_available() in favor of the wrapper nm_device_check_connection_available(). Now we only call nm_device_check_connection_available() with different parameters (@flags and @specific_object). We also have the additional guarantee that specifying more @flags will widen the result and making a connection "more" available, while specifying a @specific_object will restrict it. This also changes behavior in several cases. For example before nm_device_connection_is_available() for user-requests would always declare matching connections available on Wi-Fi devices (only) regardless of the device state. Now the device state gets consistently considered. For default-unmanaged devices it also changes behavior in complicated ways, because before we would put connections into @available_connetions for every device-state, but nm_device_connection_is_available() had a special over-ride only for unmanaged-state. This also fixes a bug, that user can activate an unavailable Wi-Fi device: nmcli radio wifi off nmcli connection up wlan0 (cherry picked from commit d80f1bf4f09e884db1d4e9da1f339283ef9a66f9) --- src/devices/nm-device.c | 88 +++++++++++-------------------- src/devices/nm-device.h | 9 ++-- src/devices/wifi/nm-device-wifi.c | 1 - src/nm-manager.c | 6 +-- 4 files changed, 37 insertions(+), 67 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index f42ce615ec..45a4b69160 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1890,7 +1890,7 @@ can_auto_connect (NMDevice *self, if (!nm_setting_connection_get_autoconnect (s_con)) return FALSE; - return nm_device_connection_is_available (self, connection, FALSE); + return nm_device_check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL); } /** @@ -6814,64 +6814,42 @@ nm_device_set_dhcp_anycast_address (NMDevice *self, const char *addr) } /** - * nm_device_connection_is_available(): + * nm_device_check_connection_available(): * @self: the #NMDevice * @connection: the #NMConnection to check for availability - * @for_user_activation_request: set to %TRUE if we are checking whether - * the connection is available on an explicit user request. This - * also checks for device specific overrides. + * @flags: flags to affect the decision making of whether a connection + * is available. Adding a flag can only make a connection more available, + * not less. + * @specific_object: a device type dependent argument to further + * filter the result. Passing a non %NULL specific object can only reduce + * the availability of a connection. * - * Check if @connection is available to be activated on @self. Normally this - * only checks if the connection is in @self's AvailableConnections property. - * If @for_user_activation_request is %TRUE then the device is asked to do specific - * checks that may bypass the AvailableConnections property. + * Check if @connection is available to be activated on @self. * * Returns: %TRUE if @connection can be activated on @self */ gboolean -nm_device_connection_is_available (NMDevice *self, - NMConnection *connection, - gboolean for_user_activation_request) +nm_device_check_connection_available (NMDevice *self, + NMConnection *connection, + NMDeviceCheckConAvailableFlags flags, + const char *specific_object) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - gboolean is_default_unmanaged; + NMDeviceState state; - if (g_hash_table_contains (priv->available_connections, connection)) - return TRUE; - - is_default_unmanaged = priv->state == NM_DEVICE_STATE_UNMANAGED && nm_device_get_default_unmanaged (self); - - if (!for_user_activation_request && !is_default_unmanaged) { - /* Shortcut: there are only additional checks for either @for_user_activation_request - * or @is_default_unmanaged. Return FALSE right away. */ + state = nm_device_get_state (self); + if (state < NM_DEVICE_STATE_UNMANAGED) return FALSE; - } - - if (!nm_device_check_connection_compatible (self, connection)) { - /* An incompatilbe connection is never available. */ + if ( state < NM_DEVICE_STATE_UNAVAILABLE + && nm_device_get_unmanaged_flag (self, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT)) + return FALSE; + if ( state < NM_DEVICE_STATE_DISCONNECTED + && !nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) return FALSE; - } - if ( is_default_unmanaged - && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL)) { - /* default-unmanaged devices in UNMANAGED state have no available connections - * so we must manually check whether the connection is available here. */ - return TRUE; - } + if (!nm_device_check_connection_compatible (self, connection)) + return FALSE; - if ( for_user_activation_request - && NM_DEVICE_GET_CLASS (self)->check_connection_available_has_user_override - && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, NULL)) { - /* Connections for an explicit user activation request might only be available after - * additional checking. - * - * For example in case of hidden Wi-Fi, the connection might not have the 'hidden' property - * set. Support this by allowing device specific overrides. - */ - return TRUE; - } - - return FALSE; + return NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, flags, specific_object); } static void @@ -6891,16 +6869,10 @@ _clear_available_connections (NMDevice *self, gboolean do_signal) static gboolean _try_add_available_connection (NMDevice *self, NMConnection *connection) { - if ( nm_device_get_state (self) < NM_DEVICE_STATE_DISCONNECTED - && !nm_device_get_default_unmanaged (self)) - return FALSE; - - if (nm_device_check_connection_compatible (self, connection)) { - if (NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL)) { - g_hash_table_add (NM_DEVICE_GET_PRIVATE (self)->available_connections, - g_object_ref (connection)); - return TRUE; - } + if (nm_device_check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL)) { + g_hash_table_add (NM_DEVICE_GET_PRIVATE (self)->available_connections, + g_object_ref (connection)); + return TRUE; } return FALSE; } @@ -6975,8 +6947,8 @@ nm_device_get_available_connections (NMDevice *self, const char *specific_object /* If a specific object is given, only include connections that are * compatible with it. */ - if ( !specific_object - || NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, specific_object)) + if ( !specific_object /* << Optimization: we know that the connection is available without @specific_object. */ + || nm_device_check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, specific_object)) g_ptr_array_add (array, connection); } } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 2a7a22a98e..3b5df8e4a8 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -172,8 +172,6 @@ typedef struct { NMDeviceCheckConAvailableFlags flags, const char *specific_object); - gboolean check_connection_available_has_user_override; - gboolean (* complete_connection) (NMDevice *self, NMConnection *connection, const char *specific_object, @@ -386,9 +384,10 @@ gboolean nm_device_has_pending_action (NMDevice *device); GPtrArray *nm_device_get_available_connections (NMDevice *device, const char *specific_object); -gboolean nm_device_connection_is_available (NMDevice *device, - NMConnection *connection, - gboolean for_user_activation_request); +gboolean nm_device_check_connection_available (NMDevice *device, + NMConnection *connection, + NMDeviceCheckConAvailableFlags flags, + const char *specific_object); gboolean nm_device_notify_component_added (NMDevice *device, GObject *component); diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index e4877ea354..dc6d0c38f6 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -3321,7 +3321,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) parent_class->is_available = is_available; parent_class->check_connection_compatible = check_connection_compatible; parent_class->check_connection_available = check_connection_available; - parent_class->check_connection_available_has_user_override = TRUE; parent_class->complete_connection = complete_connection; parent_class->set_enabled = set_enabled; diff --git a/src/nm-manager.c b/src/nm-manager.c index 398b0059ca..bf99ffc57a 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2526,7 +2526,7 @@ ensure_master_active_connection (NMManager *self, if (!is_compatible_with_slave (candidate, connection)) continue; - if (nm_device_connection_is_available (master_device, candidate, TRUE)) { + if (nm_device_check_connection_available (master_device, candidate, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, NULL)) { master_ac = nm_manager_activate_connection (self, candidate, NULL, @@ -2567,7 +2567,7 @@ ensure_master_active_connection (NMManager *self, continue; } - if (!nm_device_connection_is_available (candidate, master_connection, TRUE)) + if (!nm_device_check_connection_available (candidate, master_connection, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, NULL)) continue; found_device = TRUE; @@ -2718,7 +2718,7 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * } /* Final connection must be available on device */ - if (!nm_device_connection_is_available (device, connection, TRUE)) { + if (!nm_device_check_connection_available (device, connection, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, NULL)) { g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION, "Connection '%s' is not available on the device %s at this time.", nm_connection_get_id (connection), nm_device_get_iface (device)); From b8f40f969b20524f3fefa3ca5284d70c868329d6 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 8 Dec 2014 12:50:10 +0100 Subject: [PATCH 13/13] device: accept user activation request while waiting for carrier https://bugzilla.redhat.com/show_bug.cgi?id=1079353 (cherry picked from commit 0bfe635119facb8514e8f5824f599f4c4c3514e2) --- src/devices/nm-device.c | 116 +++++++++++++++++++++++++++--- src/devices/nm-device.h | 5 +- src/devices/wifi/nm-device-wifi.c | 2 +- 3 files changed, 110 insertions(+), 13 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 45a4b69160..2704531c1f 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -209,6 +209,7 @@ typedef struct { guint32 ip4_address; NMActRequest * queued_act_request; + gboolean queued_act_request_is_waiting_for_carrier; NMActRequest * act_request; guint act_source_id; gpointer act_source_func; @@ -337,6 +338,8 @@ static gboolean addrconf6_start_with_link_ready (NMDevice *self); static gboolean dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection); 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, @@ -1137,6 +1140,7 @@ nm_device_set_carrier (NMDevice *self, gboolean carrier) g_source_remove (priv->carrier_wait_id); priv->carrier_wait_id = 0; nm_device_remove_pending_action (self, "carrier wait", TRUE); + _carrier_wait_check_queued_act_request (self); } } else if (state <= NM_DEVICE_STATE_DISCONNECTED) { _LOGI (LOGD_DEVICE, "link disconnected"); @@ -5697,12 +5701,78 @@ _device_activate (NMDevice *self, NMActRequest *req) nm_device_activate_schedule_stage1_device_prepare (self); } +static void +_carrier_wait_check_queued_act_request (NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMActRequest *queued_req; + + if ( !priv->queued_act_request + || !priv->queued_act_request_is_waiting_for_carrier) + return; + + priv->queued_act_request_is_waiting_for_carrier = FALSE; + if (!priv->carrier) { + _LOGD (LOGD_DEVICE, "Cancel queued activation request as we have no carrier after timeout"); + g_clear_object (&priv->queued_act_request); + } else { + _LOGD (LOGD_DEVICE, "Activate queued activation request as we now have carrier"); + queued_req = priv->queued_act_request; + priv->queued_act_request = NULL; + _device_activate (self, queued_req); + g_object_unref (queued_req); + } +} + +static gboolean +_carrier_wait_check_act_request_must_queue (NMDevice *self, NMActRequest *req) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMConnection *connection; + + /* If we have carrier or if we are not waiting for it, the activation + * request is not blocked waiting for carrier. */ + if (priv->carrier) + return FALSE; + if (priv->carrier_wait_id == 0) + return FALSE; + + connection = nm_act_request_get_connection (req); + + if (!nm_device_check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_ALL, NULL)) { + /* We passed all @flags we have, and no @specific_object. + * This equals maximal availability, if a connection is not available + * in this case, it is not waiting for carrier. + * + * Actually, why are we even trying to activate it? Strange, but whatever + * the reason, don't wait for carrier. + */ + return FALSE; + } + + if (nm_device_check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_ALL & ~_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER, NULL)) { + /* The connection was available with flags ALL, and it is still available + * if we pretend not to wait for carrier. That means that the + * connection is available now, and does not wait for carrier. + * + * Since the flags increase the availability of a connection, when checking + * ALL&~WAITING_CARRIER, it means that we certainly would wait for carrier. */ + return FALSE; + } + + /* The activation request must wait for carrier. */ + return TRUE; +} + void nm_device_queue_activation (NMDevice *self, NMActRequest *req) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + gboolean must_queue; - if (!priv->act_request) { + must_queue = _carrier_wait_check_act_request_must_queue (self, req); + + if (!priv->act_request && !must_queue) { /* Just activate immediately */ _device_activate (self, req); return; @@ -5711,12 +5781,17 @@ nm_device_queue_activation (NMDevice *self, NMActRequest *req) /* supercede any already-queued request */ _clear_queued_act_request (priv); priv->queued_act_request = g_object_ref (req); + priv->queued_act_request_is_waiting_for_carrier = must_queue; - /* Deactivate existing activation request first */ - _LOGI (LOGD_DEVICE, "disconnecting for new activation request."); - nm_device_state_changed (self, - NM_DEVICE_STATE_DEACTIVATING, - NM_DEVICE_STATE_REASON_NONE); + _LOGD (LOGD_DEVICE, "queue activation request waiting for %s", must_queue ? "carrier" : "currently active connection to disconnect"); + + if (priv->act_request) { + /* Deactivate existing activation request first */ + _LOGI (LOGD_DEVICE, "disconnecting for new activation request."); + nm_device_state_changed (self, + NM_DEVICE_STATE_DEACTIVATING, + NM_DEVICE_STATE_REASON_NONE); + } } /* @@ -6258,6 +6333,9 @@ carrier_wait_timeout (gpointer user_data) NM_DEVICE_GET_PRIVATE (self)->carrier_wait_id = 0; nm_device_remove_pending_action (self, "carrier wait", TRUE); + + _carrier_wait_check_queued_act_request (self); + return G_SOURCE_REMOVE; } @@ -6843,7 +6921,10 @@ nm_device_check_connection_available (NMDevice *self, && nm_device_get_unmanaged_flag (self, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT)) return FALSE; if ( state < NM_DEVICE_STATE_DISCONNECTED - && !nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) + && ( ( !NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER) + && !nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) + || ( NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER) + && !nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER)))) return FALSE; if (!nm_device_check_connection_compatible (self, connection)) @@ -6889,13 +6970,25 @@ check_connection_available (NMDevice *self, NMDeviceCheckConAvailableFlags flags, const char *specific_object) { + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + /* Connections which require a network connection are not available when * the device has no carrier, even with ignore-carrer=TRUE. */ - if (NM_DEVICE_GET_PRIVATE (self)->carrier == FALSE) - return connection_requires_carrier (connection) ? FALSE : TRUE; + if ( priv->carrier + || !connection_requires_carrier (connection)) + return TRUE; - return TRUE; + if ( NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER) + && priv->carrier_wait_id != 0) { + /* The device has no carrier though the connection requires it. + * + * If we are still waiting for carrier, the connection is available + * for an explicit user-request. */ + return TRUE; + } + + return FALSE; } void @@ -7620,7 +7713,8 @@ _set_state_full (NMDevice *self, } break; case NM_DEVICE_STATE_DISCONNECTED: - if (priv->queued_act_request) { + if ( priv->queued_act_request + && !priv->queued_act_request_is_waiting_for_carrier) { NMActRequest *queued_req; queued_req = priv->queued_act_request; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 3b5df8e4a8..ccdade9b13 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -93,7 +93,10 @@ typedef enum NMActStageReturn NMActStageReturn; typedef enum { NM_DEVICE_CHECK_CON_AVAILABLE_NONE = 0, - NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST = (1L << 0), + _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER = (1L << 0), + _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP = (1L << 1), + NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST = _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER + | _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP, __NM_DEVICE_CHECK_CON_AVAILABLE_ALL, NM_DEVICE_CHECK_CON_AVAILABLE_ALL = (((__NM_DEVICE_CHECK_CON_AVAILABLE_ALL - 1) << 1) - 1), diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index dc6d0c38f6..9633175f48 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -902,7 +902,7 @@ check_connection_available (NMDevice *device, * activating but the network isn't available let the device recheck * availability. */ - if (nm_setting_wireless_get_hidden (s_wifi) || NM_FLAGS_HAS (flags, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST)) + if (nm_setting_wireless_get_hidden (s_wifi) || NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP)) return TRUE; /* check if its visible */