mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 10:30:13 +01:00
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.
(cherry picked from commit 5412fd389b)
This commit is contained in:
parent
0e2f08165d
commit
2c7f986b81
1 changed files with 17 additions and 7 deletions
|
|
@ -13544,6 +13544,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,
|
||||
|
|
@ -13601,18 +13614,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue