mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 08:30:15 +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.
This commit is contained in:
parent
e6523fbbbc
commit
5412fd389b
1 changed files with 17 additions and 7 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue