mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 09:20:08 +01:00
device: add and use overrule-unmanaged flag for nm_device_check_connection_available()
This flag is more granular in whether to consider the connection
available or not. We probably should never check for the combined
flag NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST directly, but
always explicitly for the relevant parts.
Also, improve the error message, to indicate whether the device is
strictly unmanaged or whether it could be overruled.
(cherry picked from commit 920346a5b9)
This commit is contained in:
parent
2c7f986b81
commit
de8aa07f4f
2 changed files with 17 additions and 10 deletions
|
|
@ -13598,16 +13598,15 @@ _nm_device_check_connection_available (NMDevice *self,
|
|||
return FALSE;
|
||||
}
|
||||
if (state < NM_DEVICE_STATE_UNAVAILABLE) {
|
||||
if (NM_FLAGS_ANY (flags, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST)) {
|
||||
if (!nm_device_get_managed (self, TRUE)) {
|
||||
nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_UNMANAGED_DEVICE,
|
||||
"device is unmanaged");
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
if (!nm_device_get_managed (self, TRUE)) {
|
||||
if (!nm_device_get_managed (self, FALSE)) {
|
||||
nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_UNMANAGED_DEVICE,
|
||||
"device is unmanaged for interal request");
|
||||
"device is strictly unmanaged");
|
||||
return FALSE;
|
||||
}
|
||||
if (!NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED)) {
|
||||
nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_UNMANAGED_DEVICE,
|
||||
"device is currently unmanaged");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,12 +181,20 @@ typedef enum { /*< skip >*/
|
|||
* visible. */
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP = (1L << 2),
|
||||
|
||||
/* a device can be marked as unmanaged for various reasons. Some of these reasons
|
||||
* are authorative, others not. Non-authoritative reasons can be overruled by
|
||||
* `nmcli device set $DEVICE managed yes`. Also, for an explicit user activation
|
||||
* request we may want to consider the device as managed. This flag makes devices
|
||||
* that are unmanaged appear available. */
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED = (1L << 3),
|
||||
|
||||
/* a collection of flags, that are commonly set for an explict user-request. */
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST = _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_FOR_USER_REQUEST_IGNORE_AP
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED,
|
||||
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_ALL = (1L << 3) - 1,
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_ALL = (1L << 4) - 1,
|
||||
} NMDeviceCheckConAvailableFlags;
|
||||
|
||||
struct _NMDevicePrivate;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue