diff options
author | Dan Williams <dan@ioncontrol.co> | 2025-05-08 19:54:43 -0500 |
---|---|---|
committer | Dan Williams <dan@ioncontrol.co> | 2025-05-08 19:54:43 -0500 |
commit | bf416a7462d1cde66dee213d858dd2b8d06f042a (patch) | |
tree | 3bcad5021316a3d55758da80310f3ffa738ea4e2 /src | |
parent | 27384681a7300955bab234cdbea5ceb075245ef6 (diff) | |
parent | 4d2d01b2c6a0819d941a4ef2d257e5392af3e24f (diff) |
Merge request !1310 from 'disabled-profiles'
bearer: don't choose or activate disabled profiles
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1310
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-broadband-bearer.c | 8 | ||||
-rw-r--r-- | src/mm-broadband-modem-qmi.c | 37 | ||||
-rw-r--r-- | src/mm-modem-helpers.c | 6 |
3 files changed, 38 insertions, 13 deletions
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c index 69bf699b..dfd9d489 100644 --- a/src/mm-broadband-bearer.c +++ b/src/mm-broadband-bearer.c @@ -634,7 +634,13 @@ select_profile_3gpp_get_profile_ready (MMIfaceModem3gppProfileManager *modem, profile = mm_iface_modem_3gpp_profile_manager_get_profile_finish (modem, res, &error); if (!profile) g_task_return_error (task, error); - else + else if (!mm_3gpp_profile_get_enabled (profile)) { + g_task_return_new_error (task, + MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Profile '%d' is internally disabled", + ctx->profile_id); + } else g_task_return_int (task, ctx->profile_id); g_object_unref (task); } diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c index 996f91e2..16f2a088 100644 --- a/src/mm-broadband-modem-qmi.c +++ b/src/mm-broadband-modem-qmi.c @@ -6582,12 +6582,17 @@ wds_profile_settings_to_3gpp_profile (MMBroadbandModemQmi *se QmiWdsPdpType pdp_type; QmiWdsAuthentication auth; QmiWdsApnTypeMask apn_type; + gboolean profile_disabled; profile = mm_3gpp_profile_new (); /* On 3GPP modems, the modem seems to force profile-index = pdp-context-number, * and so, we're just going to rely on the profile-index ourselves.*/ mm_3gpp_profile_set_profile_id (profile, (gint) profile_index); + mm_3gpp_profile_set_enabled (profile, TRUE); + + if (qmi_message_wds_get_profile_settings_output_get_apn_disabled_flag (output, &profile_disabled, NULL)) + mm_3gpp_profile_set_enabled (profile, !profile_disabled); if (qmi_message_wds_get_profile_settings_output_get_apn_name (output, &str, NULL)) mm_3gpp_profile_set_apn (profile, str); @@ -6627,7 +6632,6 @@ get_profile_settings_ready (QmiClientWds *client, MMBroadbandModemQmi *self; GError *error = NULL; gint profile_id; - gboolean profile_disabled = FALSE; MM3gppProfile *profile; g_autoptr(QmiMessageWdsGetProfileSettingsOutput) output = NULL; @@ -6642,15 +6646,6 @@ get_profile_settings_ready (QmiClientWds *client, return; } - /* just ignore the profile if it's disabled */ - qmi_message_wds_get_profile_settings_output_get_apn_disabled_flag (output, &profile_disabled, NULL); - if (profile_disabled) { - g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, - "Profile '%d' is internally disabled", profile_id); - g_object_unref (task); - return; - } - profile = wds_profile_settings_to_3gpp_profile (self, profile_id, output, &error); if (!profile) g_task_return_error (task, error); @@ -6727,6 +6722,14 @@ modem_3gpp_profile_manager_list_profiles_finish (MMIfaceModem3gppProfileManager static void get_next_profile_settings (GTask *task); +static QmiMessageWdsGetProfileListOutputProfileListProfile * +get_current_qmi_profile_from_list (ListProfilesContext *ctx) +{ + return &g_array_index (ctx->qmi_profiles, + QmiMessageWdsGetProfileListOutputProfileListProfile, + ctx->i); +} + static void get_next_profile_settings_ready (MMIfaceModem3gppProfileManager *self, GAsyncResult *res, @@ -6740,7 +6743,12 @@ get_next_profile_settings_ready (MMIfaceModem3gppProfileManager *self, profile = modem_3gpp_profile_manager_get_profile_finish (self, res, &error); if (!profile) { - g_prefix_error (&error, "Couldn't load settings from profile index %u: ", ctx->i); + QmiMessageWdsGetProfileListOutputProfileListProfile *current; + + current = get_current_qmi_profile_from_list (ctx); + g_prefix_error (&error, + "Couldn't load settings from profile index %u: ", + current->profile_index); g_task_return_error (task, error); g_object_unref (task); return; @@ -6770,7 +6778,7 @@ get_next_profile_settings (GTask *task) return; } - current = &g_array_index (ctx->qmi_profiles, QmiMessageWdsGetProfileListOutputProfileListProfile, ctx->i); + current = get_current_qmi_profile_from_list (ctx); modem_3gpp_profile_manager_get_profile (MM_IFACE_MODEM_3GPP_PROFILE_MANAGER (self), current->profile_index, (GAsyncReadyCallback)get_next_profile_settings_ready, @@ -6850,6 +6858,7 @@ typedef struct { QmiWdsApnTypeMask qmi_apn_type; QmiWdsAuthentication qmi_auth; QmiWdsPdpType qmi_pdp_type; + gboolean apn_disabled_flag; } StoreProfileContext; static void @@ -6990,6 +6999,7 @@ store_profile_run (GTask *task) qmi_message_wds_create_profile_input_set_authentication (input, ctx->qmi_auth, NULL); qmi_message_wds_create_profile_input_set_username (input, ctx->user, NULL); qmi_message_wds_create_profile_input_set_password (input, ctx->password, NULL); + qmi_message_wds_create_profile_input_set_apn_disabled_flag (input, ctx->apn_disabled_flag, NULL); if (!self->priv->apn_type_not_supported) qmi_message_wds_create_profile_input_set_apn_type_mask (input, ctx->qmi_apn_type, NULL); @@ -7010,6 +7020,7 @@ store_profile_run (GTask *task) qmi_message_wds_modify_profile_input_set_authentication (input, ctx->qmi_auth, NULL); qmi_message_wds_modify_profile_input_set_username (input, ctx->user, NULL); qmi_message_wds_modify_profile_input_set_password (input, ctx->password, NULL); + qmi_message_wds_modify_profile_input_set_apn_disabled_flag (input, ctx->apn_disabled_flag, NULL); if (!self->priv->apn_type_not_supported) qmi_message_wds_modify_profile_input_set_apn_type_mask (input, ctx->qmi_apn_type, NULL); @@ -7083,6 +7094,8 @@ modem_3gpp_profile_manager_store_profile (MMIfaceModem3gppProfileManager *self, return; } + ctx->apn_disabled_flag = !mm_3gpp_profile_get_enabled (profile); + store_profile_run (task); } diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index 574ec7fc..fcb44ad2 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -1677,6 +1677,12 @@ mm_3gpp_profile_list_find_best (GList *profile_list, continue; } + /* Never select disabled profiles */ + if (!mm_3gpp_profile_get_enabled (iter_profile)) { + mm_obj_dbg (log_object, "skipping context at profile %d: disabled", iter_profile_id); + continue; + } + /* Always prefer an exact match; compare all supported fields except for profile id */ if (mm_3gpp_profile_cmp (iter_profile, requested, cmp_apn, cmp_flags)) { mm_obj_dbg (log_object, "found exact context at profile %d", iter_profile_id); |