diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-07-13 16:45:16 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-07-13 16:48:50 +0200 |
commit | 06682e2806d2bceef8c8f63b49e84989465a2d33 (patch) | |
tree | 1ffd37a6b07cc9afe6285f14738c4dd969f296be | |
parent | daf72fe169f40bcb637a0a4db1a763bd54909d20 (diff) |
bearer-mbim: never update bearer properties sent by the user
We should never run any mm_bearer_properties_set_X() operations
ourselves for the properties received by the user, or otherwise the
logic comparing the bearers will fail and we may end up creating one
bearer per connection attempt.
-rw-r--r-- | src/mm-bearer-mbim.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c index 101c75cd..16bffd87 100644 --- a/src/mm-bearer-mbim.c +++ b/src/mm-bearer-mbim.c @@ -878,6 +878,7 @@ static gboolean load_settings_from_profile (MMBearerMbim *self, ConnectContext *ctx, MM3gppProfile *profile, + MMBearerApnType default_apn_type, GError **error) { MMBearerAllowedAuth bearer_auth; @@ -888,9 +889,12 @@ load_settings_from_profile (MMBearerMbim *self, ctx->apn = g_strdup (mm_3gpp_profile_get_apn (profile)); apn_type = mm_3gpp_profile_get_apn_type (profile); if (apn_type == MM_BEARER_APN_TYPE_NONE) { - g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, - "APN type in profile is not initialized"); - return FALSE; + if (default_apn_type == MM_BEARER_APN_TYPE_NONE) { + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "APN type in profile is not initialized"); + return FALSE; + } + apn_type = default_apn_type; } ctx->context_type = mm_bearer_apn_type_to_mbim_context_type (apn_type, self, &inner_error); if (inner_error) { @@ -951,7 +955,7 @@ get_profile_ready (MMIfaceModem3gppProfileManager *modem, return; } - if (!load_settings_from_profile (self, ctx, profile, &error)) { + if (!load_settings_from_profile (self, ctx, profile, MM_BEARER_APN_TYPE_NONE, &error)) { g_prefix_error (&error, "Couldn't load settings from profile: "); g_task_return_error (task, error); g_object_unref (task); @@ -1209,14 +1213,14 @@ load_settings_from_bearer (MMBearerMbim *self, return TRUE; } - /* If not loading from a stored profile, initialize the - * APN type to 'internet' by default, which is what we've done - * until now. */ - if (mm_bearer_properties_get_apn_type (properties) == MM_BEARER_APN_TYPE_NONE) - mm_bearer_properties_set_apn_type (properties, MM_BEARER_APN_TYPE_DEFAULT); - - /* Use the implicit profile settings in the bearer properties */ - if (!load_settings_from_profile (self, ctx, mm_bearer_properties_peek_3gpp_profile (properties), error)) + /* Use the implicit profile settings in the bearer properties. + * If not loading from a stored profile, initialize the APN type to 'internet' + * (TYPE_DEFAULT) by default, which is what we've done until now. */ + if (!load_settings_from_profile (self, + ctx, + mm_bearer_properties_peek_3gpp_profile (properties), + MM_BEARER_APN_TYPE_DEFAULT, + error)) return FALSE; /* Is this a 3GPP only modem and no APN or profile id was given? If so, error */ |