summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-10-17 12:26:35 +0200
committerThomas Haller <thaller@redhat.com>2018-10-17 12:36:43 +0200
commit12bf77685b1c4550cf7e6ea10a947694efc1e5d7 (patch)
treedf90d23437de662881f24eba635fd3907ac441cf
parent71da14441cffe2df3beb3d058621cab2004d6da4 (diff)
downloadNetworkManager-12bf77685b1c4550cf7e6ea10a947694efc1e5d7.tar.gz
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.
-rw-r--r--src/devices/nm-device.c11
-rw-r--r--src/devices/nm-device.h12
2 files changed, 15 insertions, 8 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index ef14c21d48..c1fe2c0f40 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -13669,16 +13669,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)) {
+ 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");
+ "device is strictly unmanaged");
return FALSE;
}
- } else {
- if (!nm_device_get_managed (self, 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 unmanaged for internal request");
+ "device is currently unmanaged");
return FALSE;
}
}
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 2c43e277e2..2ae35a0cb2 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -182,12 +182,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-autorative reasons can be overrulde 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;