wwan/device-modem: disabled but not enable-able modem is unavailable

If a modem is disabled, and it has no method to enable it, then by no
mean it's "available" to NM.
This commit is contained in:
Ratchanan Srirattanamet 2022-09-21 19:26:25 +07:00 committed by Thomas Haller
parent f914df4f79
commit 580453d376
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -273,6 +273,15 @@ modem_state_cb(NMModem *modem, int new_state_i, int old_state_i, gpointer user_d
/* Called when the ModemManager modem enabled state is changed externally
* to NetworkManager (eg something using MM's D-Bus API directly).
*/
if (!NM_MODEM_GET_CLASS(priv->modem)->set_mm_enabled) {
/* We cannot re-enable this modem, thus device becomes unavailable. */
nm_device_state_changed(device,
NM_DEVICE_STATE_UNAVAILABLE,
NM_DEVICE_STATE_REASON_USER_REQUESTED);
return;
}
if (nm_device_is_activating(device) || dev_state == NM_DEVICE_STATE_ACTIVATED) {
/* user-initiated action, hence DISCONNECTED not FAILED */
nm_device_state_changed(device,
@ -435,6 +444,13 @@ check_connection_available(NMDevice *device,
return FALSE;
}
if (!NM_MODEM_GET_CLASS(priv->modem)->set_mm_enabled && state <= NM_MODEM_STATE_DISABLING) {
nm_utils_error_set_literal(error,
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
"modem is disabled and NM cannot enable it");
return FALSE;
}
if (state == NM_MODEM_STATE_LOCKED) {
if (!nm_connection_get_setting_gsm(connection)) {
nm_utils_error_set_literal(error,
@ -617,6 +633,9 @@ is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
if (modem_state <= NM_MODEM_STATE_INITIALIZING)
return FALSE;
if (!NM_MODEM_GET_CLASS(priv->modem)->set_mm_enabled && modem_state <= NM_MODEM_STATE_DISABLING)
return FALSE;
return TRUE;
}