aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-11-10 23:01:10 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-11-14 09:41:43 +0000
commit5d150ed23e122c06e1a4add0ca9c6f7e07502a17 (patch)
treee3d1a8b52a4a3bc0220aa2a4134f1837a5f1235a
parentda77dc7152b76728de0ce63cedf96ceb30f37046 (diff)
core,plugins: consolidate connection/disconnection timeout values
Each different plugin or protocol had a different connection attempt value. E.g. QMI and MBIM both used 60s max for the connection attempt, while the u-blox plugin had up to 180s for ECM based connection setups. This commit consolidates all plugins and protocols to use the same timeout values for commands that may take long to respond, e.g. a connection atempt under low signal quality conditions. A value of 180s for the connection attempt steps and 120s for a disconnection attempt step is considered. Note, though, that in some cases (like a IPv4v6 setup attempt using QMI) we may have more than one such long step, so this doesn't mean that a connection attempt will always take less than 180s. Users of the connection/disconnection APIs should be able to handle the case where the attempt times out in their side (e.g. with a lower DBus request timeout), and which would not mean the actual request they did really failed. E.g. a connection attempt with a DBus timeout of 30s may fail in the user with a timeout error, but the attempt would still go on for as much as the plugin/protocol needs. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/270
-rw-r--r--plugins/altair/mm-broadband-bearer-altair-lte.c4
-rw-r--r--plugins/cinterion/mm-broadband-bearer-cinterion.c4
-rw-r--r--plugins/huawei/mm-broadband-bearer-huawei.c10
-rw-r--r--plugins/icera/mm-broadband-bearer-icera.c10
-rw-r--r--plugins/iridium/mm-bearer-iridium.c2
-rw-r--r--plugins/mbm/mm-broadband-bearer-mbm.c6
-rw-r--r--plugins/novatel/mm-broadband-bearer-novatel-lte.c4
-rw-r--r--plugins/option/mm-broadband-bearer-hso.c4
-rw-r--r--plugins/sierra/mm-broadband-bearer-sierra.c4
-rw-r--r--plugins/ublox/mm-broadband-bearer-ublox.c6
-rw-r--r--src/mm-base-bearer.h11
-rw-r--r--src/mm-bearer-mbim.c6
-rw-r--r--src/mm-bearer-qmi.c12
-rw-r--r--src/mm-broadband-bearer.c4
14 files changed, 49 insertions, 38 deletions
diff --git a/plugins/altair/mm-broadband-bearer-altair-lte.c b/plugins/altair/mm-broadband-bearer-altair-lte.c
index 4a5b0573..1ce965a8 100644
--- a/plugins/altair/mm-broadband-bearer-altair-lte.c
+++ b/plugins/altair/mm-broadband-bearer-altair-lte.c
@@ -119,7 +119,7 @@ connect_3gpp_apnsettings_ready (MMBaseModem *modem,
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
"%DPDNACT=1",
- 20, /* timeout */
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT, /* timeout */
FALSE, /* allow_cached */
FALSE, /* is_raw */
g_task_get_cancellable (task),
@@ -296,7 +296,7 @@ disconnect_3gpp (MMBroadbandBearer *self,
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
"%DPDNACT=0",
- 20, /* timeout */
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT, /* timeout */
FALSE, /* allow_cached */
FALSE, /* is_raw */
NULL, /* cancellable */
diff --git a/plugins/cinterion/mm-broadband-bearer-cinterion.c b/plugins/cinterion/mm-broadband-bearer-cinterion.c
index 9072f288..464e75e9 100644
--- a/plugins/cinterion/mm-broadband-bearer-cinterion.c
+++ b/plugins/cinterion/mm-broadband-bearer-cinterion.c
@@ -356,7 +356,7 @@ dial_3gpp_context_step (GTask *task)
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
command,
- 180,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
FALSE,
FALSE,
NULL,
@@ -553,7 +553,7 @@ disconnect_3gpp_context_step (GTask *task)
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
command,
- 10,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
FALSE,
FALSE,
NULL,
diff --git a/plugins/huawei/mm-broadband-bearer-huawei.c b/plugins/huawei/mm-broadband-bearer-huawei.c
index 6548ae7f..4bf2bb59 100644
--- a/plugins/huawei/mm-broadband-bearer-huawei.c
+++ b/plugins/huawei/mm-broadband-bearer-huawei.c
@@ -327,7 +327,7 @@ connect_3gpp_context_step (GTask *task)
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
"^NDISDUP=1,0",
- 3,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
FALSE,
FALSE,
NULL,
@@ -417,11 +417,11 @@ connect_3gpp_context_step (GTask *task)
}
case CONNECT_3GPP_CONTEXT_STEP_NDISSTATQRY:
- /* Wait for dial up timeout, retries for 60 times
- * (1s between the retries, so it means 1 minute).
+ /* Wait for dial up timeout, retries for 180 times
+ * (1s between the retries, so it means 3 minutes).
* If too many retries, failed
*/
- if (ctx->check_count > 60) {
+ if (ctx->check_count > MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT) {
/* Clear context */
self->priv->connect_pending = NULL;
g_task_return_new_error (task,
@@ -701,7 +701,7 @@ disconnect_3gpp_context_step (GTask *task)
case DISCONNECT_3GPP_CONTEXT_STEP_NDISSTATQRY:
/* If too many retries (1s of wait between the retries), failed */
- if (ctx->check_count > 60) {
+ if (ctx->check_count > MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT) {
/* Clear task */
self->priv->disconnect_pending = NULL;
g_task_return_new_error (task,
diff --git a/plugins/icera/mm-broadband-bearer-icera.c b/plugins/icera/mm-broadband-bearer-icera.c
index caa8567f..1d6859c0 100644
--- a/plugins/icera/mm-broadband-bearer-icera.c
+++ b/plugins/icera/mm-broadband-bearer-icera.c
@@ -364,7 +364,7 @@ disconnect_3gpp (MMBroadbandBearer *bearer,
MM_BASE_MODEM (modem),
primary,
command,
- 60,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
FALSE,
FALSE, /* raw */
NULL, /* cancellable */
@@ -437,7 +437,7 @@ connect_reset (GTask *task)
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
command,
- 3,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
FALSE,
FALSE, /* raw */
NULL, /* cancellable */
@@ -624,7 +624,7 @@ activate_ready (MMBaseModem *modem,
* Reports of modem being connected will arrive via unsolicited messages.
* This timeout should be long enough. Actually... ideally should never get
* reached. */
- self->priv->connect_pending_id = g_timeout_add_seconds (60,
+ self->priv->connect_pending_id = g_timeout_add_seconds (MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
(GSourceFunc)connect_timed_out_cb,
self);
@@ -698,7 +698,7 @@ authenticate_ready (MMBaseModem *modem,
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
command,
- 60,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
FALSE,
FALSE, /* raw */
NULL, /* cancellable */
@@ -812,7 +812,7 @@ connect_deactivate (GTask *task)
ctx->modem,
ctx->primary,
command,
- 60,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
FALSE,
FALSE, /* raw */
NULL, /* cancellable */
diff --git a/plugins/iridium/mm-bearer-iridium.c b/plugins/iridium/mm-bearer-iridium.c
index 2c4430cc..12b60419 100644
--- a/plugins/iridium/mm-bearer-iridium.c
+++ b/plugins/iridium/mm-bearer-iridium.c
@@ -165,7 +165,7 @@ service_type_ready (MMBaseModem *modem,
modem,
ctx->primary,
"ATDT008816000025",
- 60,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
FALSE,
FALSE, /* raw */
NULL, /* cancellable */
diff --git a/plugins/mbm/mm-broadband-bearer-mbm.c b/plugins/mbm/mm-broadband-bearer-mbm.c
index 761ad86a..b4bba2d9 100644
--- a/plugins/mbm/mm-broadband-bearer-mbm.c
+++ b/plugins/mbm/mm-broadband-bearer-mbm.c
@@ -232,7 +232,7 @@ connect_poll_cb (MMBroadbandBearerMbm *self)
}
/* Too many retries... */
- if (ctx->poll_count > 50) {
+ if (ctx->poll_count > MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT) {
g_assert (!ctx->saved_error);
ctx->saved_error = g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_NETWORK_TIMEOUT,
@@ -318,7 +318,7 @@ activate (GTask *task)
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
command,
- 3,
+ 10,
FALSE,
FALSE, /* raw */
g_task_get_cancellable (task),
@@ -682,7 +682,7 @@ disconnect_poll_cb (MMBroadbandBearerMbm *self)
ctx->poll_id = 0;
/* Too many retries... */
- if (ctx->poll_count > 20) {
+ if (ctx->poll_count > MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT) {
g_task_return_new_error (task,
MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_NETWORK_TIMEOUT,
diff --git a/plugins/novatel/mm-broadband-bearer-novatel-lte.c b/plugins/novatel/mm-broadband-bearer-novatel-lte.c
index 43eeed19..ec08f4d7 100644
--- a/plugins/novatel/mm-broadband-bearer-novatel-lte.c
+++ b/plugins/novatel/mm-broadband-bearer-novatel-lte.c
@@ -335,7 +335,7 @@ connect_3gpp (MMBroadbandBearer *self,
ctx = g_slice_new0 (DetailedConnectContext);
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
ctx->primary = g_object_ref (primary);
- ctx->retries = 60;
+ ctx->retries = MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT;
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_task_data (task, ctx, (GDestroyNotify)detailed_connect_context_free);
@@ -498,7 +498,7 @@ disconnect_3gpp (MMBroadbandBearer *self,
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
ctx->primary = g_object_ref (primary);
ctx->data = g_object_ref (data);
- ctx->retries = 60;
+ ctx->retries = MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT;
task = g_task_new (self, NULL, callback, user_data);
g_task_set_task_data (task, ctx, (GDestroyNotify)detailed_disconnect_context_free);
diff --git a/plugins/option/mm-broadband-bearer-hso.c b/plugins/option/mm-broadband-bearer-hso.c
index a5702c01..908d32c6 100644
--- a/plugins/option/mm-broadband-bearer-hso.c
+++ b/plugins/option/mm-broadband-bearer-hso.c
@@ -410,7 +410,7 @@ activate_ready (MMBaseModem *modem,
* Reports of modem being connected will arrive via unsolicited messages.
* This timeout should be long enough. Actually... ideally should never get
* reached. */
- self->priv->connect_pending_id = g_timeout_add_seconds (60,
+ self->priv->connect_pending_id = g_timeout_add_seconds (MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
(GSourceFunc)connect_timed_out_cb,
self);
@@ -686,7 +686,7 @@ disconnect_3gpp (MMBroadbandBearer *self,
mm_base_modem_at_command_full (MM_BASE_MODEM (modem),
primary,
command,
- 3,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
FALSE,
FALSE, /* raw */
NULL, /* cancellable */
diff --git a/plugins/sierra/mm-broadband-bearer-sierra.c b/plugins/sierra/mm-broadband-bearer-sierra.c
index db9fdead..2c2ef375 100644
--- a/plugins/sierra/mm-broadband-bearer-sierra.c
+++ b/plugins/sierra/mm-broadband-bearer-sierra.c
@@ -407,7 +407,7 @@ dial_3gpp_context_step (GTask *task)
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
command,
- 10,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
FALSE,
FALSE, /* raw */
NULL, /* cancellable */
@@ -538,7 +538,7 @@ disconnect_3gpp (MMBroadbandBearer *self,
mm_base_modem_at_command_full (MM_BASE_MODEM (modem),
primary,
command,
- 3,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
FALSE,
FALSE, /* raw */
NULL, /* cancellable */
diff --git a/plugins/ublox/mm-broadband-bearer-ublox.c b/plugins/ublox/mm-broadband-bearer-ublox.c
index 1b209841..d69bc8dc 100644
--- a/plugins/ublox/mm-broadband-bearer-ublox.c
+++ b/plugins/ublox/mm-broadband-bearer-ublox.c
@@ -379,7 +379,7 @@ activate_3gpp (GTask *task)
mm_obj_dbg (self, "establishing ECM data connection for PDP context #%u...", ctx->cid);
mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem),
cmd,
- 180,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
FALSE,
(GAsyncReadyCallback) cedata_activate_ready,
g_object_ref (self));
@@ -396,7 +396,7 @@ activate_3gpp (GTask *task)
mm_obj_dbg (self, "activating PDP context #%u...", ctx->cid);
mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem),
cmd,
- 120,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
FALSE,
(GAsyncReadyCallback) cgact_activate_ready,
task);
@@ -730,7 +730,7 @@ disconnect_3gpp (MMBroadbandBearer *self,
mm_obj_dbg (self, "deactivating PDP context #%u...", cid);
mm_base_modem_at_command (MM_BASE_MODEM (modem),
cmd,
- 120,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
FALSE,
(GAsyncReadyCallback) cgact_deactivate_ready,
task);
diff --git a/src/mm-base-bearer.h b/src/mm-base-bearer.h
index 729fa6a8..1c1f96ea 100644
--- a/src/mm-base-bearer.h
+++ b/src/mm-base-bearer.h
@@ -43,6 +43,17 @@ MMBearerIpConfig *mm_bearer_connect_result_peek_ipv6_config (MMBearerConnec
/*****************************************************************************/
+/* Default timeout values to be used in the steps of a connection or
+ * disconnection attempt that may take long to complete. Note that the actual
+ * connection attempt from the user may have a different timeout, but we don't
+ * really fully care about that, it's a problem to consider in the user side.
+ * In the daemon itself, what we want and require is to be in sync with the
+ * state of the modem. */
+#define MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT 180
+#define MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT 120
+
+/*****************************************************************************/
+
#define MM_TYPE_BASE_BEARER (mm_base_bearer_get_type ())
#define MM_BASE_BEARER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BASE_BEARER, MMBaseBearer))
#define MM_BASE_BEARER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BASE_BEARER, MMBaseBearerClass))
diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c
index 7df655da..e53529ee 100644
--- a/src/mm-bearer-mbim.c
+++ b/src/mm-bearer-mbim.c
@@ -948,7 +948,7 @@ connect_context_step (GTask *task)
mbim_device_command (ctx->device,
message,
- 60,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
NULL,
(GAsyncReadyCallback)ensure_disconnected_ready,
task);
@@ -1022,7 +1022,7 @@ connect_context_step (GTask *task)
mbim_device_command (ctx->device,
message,
- 60,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
NULL,
(GAsyncReadyCallback)connect_set_ready,
task);
@@ -1318,7 +1318,7 @@ disconnect_context_step (GTask *task)
mbim_device_command (ctx->device,
message,
- 60,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
NULL,
(GAsyncReadyCallback)disconnect_set_ready,
task);
diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c
index b3ea0d84..e29414f4 100644
--- a/src/mm-bearer-qmi.c
+++ b/src/mm-bearer-qmi.c
@@ -479,7 +479,7 @@ connect_context_free (ConnectContext *ctx)
input = qmi_message_wds_stop_network_input_new ();
qmi_message_wds_stop_network_input_set_packet_data_handle (input, ctx->packet_data_handle_ipv4, NULL);
- qmi_client_wds_stop_network (ctx->client_ipv4, input, 30, NULL, NULL, NULL);
+ qmi_client_wds_stop_network (ctx->client_ipv4, input, MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT, NULL, NULL, NULL);
}
g_clear_object (&ctx->client_ipv4);
}
@@ -501,7 +501,7 @@ connect_context_free (ConnectContext *ctx)
input = qmi_message_wds_stop_network_input_new ();
qmi_message_wds_stop_network_input_set_packet_data_handle (input, ctx->packet_data_handle_ipv6, NULL);
- qmi_client_wds_stop_network (ctx->client_ipv6, input, 30, NULL, NULL, NULL);
+ qmi_client_wds_stop_network (ctx->client_ipv6, input, MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT, NULL, NULL, NULL);
}
g_clear_object (&ctx->client_ipv6);
}
@@ -1420,7 +1420,7 @@ connect_context_step (GTask *task)
input = build_start_network_input (ctx);
qmi_client_wds_start_network (ctx->client_ipv4,
input,
- 45,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
g_task_get_cancellable (task),
(GAsyncReadyCallback)start_network_ready,
task);
@@ -1511,7 +1511,7 @@ connect_context_step (GTask *task)
input = build_start_network_input (ctx);
qmi_client_wds_start_network (ctx->client_ipv6,
input,
- 45,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
g_task_get_cancellable (task),
(GAsyncReadyCallback)start_network_ready,
task);
@@ -1980,7 +1980,7 @@ disconnect_context_step (GTask *task)
ctx->running_ipv6 = FALSE;
qmi_client_wds_stop_network (ctx->client_ipv4,
input,
- 30,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
NULL,
(GAsyncReadyCallback)stop_network_ready,
task);
@@ -2011,7 +2011,7 @@ disconnect_context_step (GTask *task)
ctx->running_ipv6 = TRUE;
qmi_client_wds_stop_network (ctx->client_ipv6,
input,
- 30,
+ MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
NULL,
(GAsyncReadyCallback)stop_network_ready,
task);
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index 004ef1f0..73869a0c 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -269,7 +269,7 @@ cdma_connect_context_dial (GTask *task)
mm_base_modem_at_command_full (ctx->modem,
MM_PORT_SERIAL_AT (ctx->data),
"DT#777",
- 90,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
FALSE,
FALSE,
NULL,
@@ -586,7 +586,7 @@ dial_3gpp (MMBroadbandBearer *self,
mm_base_modem_at_command_full (ctx->modem,
ctx->dial_port,
command,
- 60,
+ MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
FALSE,
FALSE, /* raw */
NULL, /* cancellable */