From 2e8f43e379c61d79b6dd1b27ee1d9cb950447ad5 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 1 Mar 2019 17:43:37 +0100 Subject: [PATCH] wwan/device-modem: don't enter available state until registered Based on Ubuntu's "Modify NMDeviceModem's available logic" patch by Tony Espy . The original commit message: This patch modifies NMDeviceModem's available logic such that the device is only considered available if the modem_state is >= NM_MODEM_STATE_REGISTERED. NMDevice defines 'available' as meaning the device is in such a state that it can be activated. This change prevents NM from trying to activate a modem which is not yet ready to be activated. Bug-Ubuntu: https://bugs.launchpad.net/bugs/1445080 https://github.com/NetworkManager/NetworkManager/pull/312 --- src/devices/wwan/nm-device-modem.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index 1e3162808..876f75d7e 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -473,11 +473,6 @@ check_connection_available (NMDevice *device, } state = nm_modem_get_state (priv->modem); - if (state <= NM_MODEM_STATE_INITIALIZING) { - nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY, - "modem not initialized"); - return FALSE; - } if (state == NM_MODEM_STATE_LOCKED) { if (!nm_connection_get_setting_gsm (connection)) { @@ -487,6 +482,12 @@ check_connection_available (NMDevice *device, } } + if (state < NM_MODEM_STATE_REGISTERED) { + nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY, + "modem not registered"); + return FALSE; + } + return TRUE; } @@ -658,7 +659,7 @@ is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) g_assert (priv->modem); modem_state = nm_modem_get_state (priv->modem); - if (modem_state <= NM_MODEM_STATE_INITIALIZING) + if (modem_state < NM_MODEM_STATE_REGISTERED) return FALSE; return TRUE;