device: reorder checks in check_connection_available()

No change in behavior. Just reorder, so that the checks that can be
reviewed in place are handled first.
This commit is contained in:
Thomas Haller 2023-06-12 15:14:11 +02:00
parent b3b8323499
commit 42f20a4edf
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -15324,10 +15324,7 @@ check_connection_available(NMDevice *self,
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
/* Connections which require a network connection are not available when
* the device has no carrier, even with ignore-carrer=TRUE.
*/
if (priv->carrier || !connection_requires_carrier(connection))
if (priv->carrier)
return TRUE;
if (NM_FLAGS_HAS(flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER)
@ -15339,12 +15336,6 @@ check_connection_available(NMDevice *self,
return TRUE;
}
/* master types are always available even without carrier.
* Making connection non-available would un-enslave slaves which
* is not desired. */
if (nm_device_is_master(self))
return TRUE;
if (!priv->up) {
/* If the device is !IFF_UP it also has no carrier. But we assume that if we
* would start activating the device (and thereby set the device IFF_UP),
@ -15354,6 +15345,18 @@ check_connection_available(NMDevice *self,
return TRUE;
}
if (!connection_requires_carrier(connection)) {
/* Connections that don't require carrier are available. */
return TRUE;
}
if (nm_device_is_master(self)) {
/* master types are always available even without carrier.
* Making connection non-available would un-enslave slaves which
* is not desired. */
return TRUE;
}
nm_utils_error_set_literal(error,
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
"device has no carrier");