Merge request !1310 from 'disabled-profiles'

bearer: don't choose or activate disabled profiles

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1310
This commit is contained in:
Dan Williams
2025-05-08 19:54:43 -05:00
3 changed files with 38 additions and 13 deletions
+7 -1
View File
@@ -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);
}
+25 -12
View File
@@ -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);
}
+6
View File
@@ -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);