From 7464940971ded3d550217872b42fef9f3120b1bf Mon Sep 17 00:00:00 2001 From: Carlo Lobrano Date: Thu, 14 Jul 2022 12:14:13 +0200 Subject: [PATCH] mm-iface-modem-3gpp-profile-manager: do not override Bearer 3gpp profile properties during connection When connecting via AT commands requiring a 3gpp profile with undefined profile-id, the corresponding bearer 3gpp profile is later modified adding the selected PDP context. For this reason when a next connection is requested with the same properties (that is no profile-id) the already existing bearers is not selected because of the different profile-id value and a new one is created. This change lets the connection logic use a copy of the user-requested bearer's 3gpp profile which can be modified for the logic needs, but it is not stored and then does not compromise a bearer comparison in a next connection request. --- src/mm-iface-modem-3gpp-profile-manager.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/mm-iface-modem-3gpp-profile-manager.c b/src/mm-iface-modem-3gpp-profile-manager.c index 67601ada..1ab01487 100644 --- a/src/mm-iface-modem-3gpp-profile-manager.c +++ b/src/mm-iface-modem-3gpp-profile-manager.c @@ -674,15 +674,29 @@ mm_iface_modem_3gpp_profile_manager_set_profile (MMIfaceModem3gppProfileManager GAsyncReadyCallback callback, gpointer user_data) { - GTask *task; - SetProfileContext *ctx; - MMBearerIpFamily ip_family; + GError *error; + GTask *task; + SetProfileContext *ctx; + MMBearerIpFamily ip_family; + g_autoptr(GVariant) dict = NULL; + g_autoptr(MM3gppProfile) requested_copy = NULL; task = g_task_new (self, NULL, callback, user_data); + /* The MM3gppProfile passed to the SetProfileContext is going to + * be modified, so we make a copy to preserve the original one. */ + dict = mm_3gpp_profile_get_dictionary (requested); + requested_copy = mm_3gpp_profile_new_from_dictionary (dict, &error); + if (!requested_copy) { + g_prefix_error (&error, "Couldn't copy 3GPP profile:"); + g_task_return_error (task, error); + g_object_unref (task); + return; + } + ctx = g_slice_new0 (SetProfileContext); ctx->step = SET_PROFILE_STEP_FIRST; - ctx->requested = g_object_ref (requested); + ctx->requested = g_object_ref (requested_copy); ctx->index_field = g_strdup (index_field); ctx->strict = strict; ctx->profile_id = mm_3gpp_profile_get_profile_id (requested);