diff options
author | Thomas Haller <thaller@redhat.com> | 2018-10-17 12:02:51 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-10-17 15:06:52 +0200 |
commit | 5412fd389b051bc3598c08b9d0eb63db4f2af45d (patch) | |
tree | be475ea4c8aaa2f096f83697145300c923db5ebc | |
parent | e6523fbbbcbf348a803cb202e433f9b7eb1ffe91 (diff) | |
download | NetworkManager-5412fd389b051bc3598c08b9d0eb63db4f2af45d.tar.gz |
device: cleanup checking device avilability for ignoring carrier
The flags NMDeviceCheckConAvailableFlags and NMDeviceCheckDevAvailableFlags
both control whether a device appears available (either, available in
general, or related to a particular profile).
Also, both flag types strictly increase availability. Meaning: more flags,
more available.
There is some overlap between the flags, however they still have
their own distinct parts.
Improve the mapping from NMDeviceCheckConAvailableFlags to
NMDeviceCheckDevAvailableFlags, by picking exactly the flags
that are relevant.
-rw-r--r-- | src/devices/nm-device.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index ce21803bfa..5057f7967e 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -13615,6 +13615,19 @@ nm_device_update_metered (NMDevice *self) } } +static NMDeviceCheckDevAvailableFlags +_device_check_dev_available_flags_from_con (NMDeviceCheckConAvailableFlags con_flags) +{ + NMDeviceCheckDevAvailableFlags dev_flags; + + dev_flags = NM_DEVICE_CHECK_DEV_AVAILABLE_NONE; + + if (NM_FLAGS_HAS (con_flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER)) + dev_flags |= _NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER; + + return dev_flags; +} + static gboolean _nm_device_check_connection_available (NMDevice *self, NMConnection *connection, @@ -13672,18 +13685,15 @@ _nm_device_check_connection_available (NMDevice *self, } if ( state < NM_DEVICE_STATE_DISCONNECTED && !nm_device_is_software (self)) { - if (NM_FLAGS_ANY (flags, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST)) { - if (!nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_FOR_USER_REQUEST)) { + if (!nm_device_is_available (self, _device_check_dev_available_flags_from_con (flags))) { + if (NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST)) { nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY, "device is not available"); - return FALSE; - } - } else { - if (!nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) { + } else { nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY, "device is not available for internal request"); - return FALSE; } + return FALSE; } } |