summaryrefslogtreecommitdiff
path: root/src/devices/wwan/nm-device-modem.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-12-11 15:50:41 +0100
committerThomas Haller <thaller@redhat.com>2018-12-14 14:25:36 +0100
commit90e9695af541d0e13c5327466f1414b35a04c73d (patch)
tree23e59e10c9ec41d9fee1fe8bc7a20a4276c7f602 /src/devices/wwan/nm-device-modem.c
parentf22492f8fc9024a87c1e2945aad80dda5368a23c (diff)
downloadNetworkManager-90e9695af541d0e13c5327466f1414b35a04c73d.tar.gz
wwan: rework when settings/device are blocked for autoconnection
The reasons to block autoconnection at settings level are not the same as the ones to block autoconnection at device level. E.g. if the SIM-PIN is wrong, you may want to block autoconnection both at settings level (as the PIN configured in settings is wrong) and at device level (so that no other setting is tried automatically). For some other reasons, you may want to block autoconnection only at setting level (e.g. wrong APN). And for some other reasons you may want to block autoconnection at device level only (e.g. SIM missing), so that the autoconnection blocking is removed when the device goes away. This is especially important with SIM hotplug events processed by ModemManager, as a device without SIM will be removed from MM when a new SIM is inserted, so that a completely new object is exposed in MM with the newly detected SIM. https://github.com/NetworkManager/NetworkManager/pull/259
Diffstat (limited to 'src/devices/wwan/nm-device-modem.c')
-rw-r--r--src/devices/wwan/nm-device-modem.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index e98118b60c..be08498608 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -125,14 +125,40 @@ modem_prepare_result (NMModem *modem,
if (success)
nm_device_activate_schedule_stage2_device_config (device);
else {
- if (nm_device_state_reason_check (reason) == NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT) {
- /* If the connect failed because the SIM PIN was wrong don't allow
- * the device to be auto-activated anymore, which would risk locking
- * the SIM if the incorrect PIN continues to be used.
- */
+ /* There are several reasons to block autoconnection at device level:
+ *
+ * - Wrong SIM-PIN: The device won't autoconnect because it doesn't make sense
+ * to retry the connection with the same PIN. This error also makes autoconnection
+ * blocked at settings level, so not even a modem unplug and replug will allow
+ * autoconnection again. It is somewhat redundant to block autoconnection at
+ * both device and setting level really.
+ *
+ * - SIM wrong or not inserted: If the modem is reporting a SIM not inserted error,
+ * we can block autoconnection at device level, so that if the same device is
+ * unplugged and replugged with a SIM (or if a SIM hotplug event happens in MM,
+ * recreating the device completely), we can try the autoconnection again.
+ *
+ * - Modem initialization failed: For some reason unknown to NM, the modem wasn't
+ * initialized correctly, which leads to an unusable device. A device unplug and
+ * replug may solve the issue, so make it a device-level autoconnection blocking
+ * reason.
+ */
+ switch (nm_device_state_reason_check (reason)) {
+ case NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED:
+ case NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED:
+ case NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT:
nm_device_autoconnect_blocked_set (device, NM_DEVICE_AUTOCONNECT_BLOCKED_WRONG_PIN);
+ break;
+ case NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED:
+ case NM_DEVICE_STATE_REASON_GSM_SIM_WRONG:
+ nm_device_autoconnect_blocked_set (device, NM_DEVICE_AUTOCONNECT_BLOCKED_SIM_MISSING);
+ break;
+ case NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED:
+ nm_device_autoconnect_blocked_set (device, NM_DEVICE_AUTOCONNECT_BLOCKED_INIT_FAILED);
+ break;
+ default:
+ break;
}
-
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
}
}