broadband-modem-mbim: limit the use of context types defined in MBIMEx

The Tethering context type UUID was defined by Microsoft in its
extensions as `5e4e0601-48dc-4e2b-acb8-08b4016bbaac` (along with
others like Admin, Xcap, App and EmergencyCalling), see
https://learn.microsoft.com/en-us/windows-hardware/drivers/network/mb-provisioned-context-operations.

These UUIDs are expected to be usable only if the modem supports
`MBIM_CID_MS_PROVISIONED_CONTEXT_V2` (CID=1) in the Basic Connect
Extensions service (3d01dcc5-fef5-4d05-0d3abef7058e9aaf).

If the modem doesn't support these, we should try to fallback to a
more generic APN type automatically, e.g. "Internet", which was
defined in MBIM 1.0 and should always be supported.

There should be no problem in a modem to have 2 separate PDN
connections with the same context type.
This commit is contained in:
Aleksander Morgado
2023-02-17 14:18:16 +00:00
parent 278678d8ed
commit 6d1f4aee30
5 changed files with 57 additions and 17 deletions

View File

@@ -907,9 +907,13 @@ load_settings_from_profile (MMBearerMbim *self,
MMBearerApnType default_apn_type,
GError **error)
{
MMBearerAllowedAuth bearer_auth;
MMBearerApnType apn_type;
GError *inner_error = NULL;
MMBearerAllowedAuth bearer_auth;
MMBearerApnType apn_type;
GError *inner_error = NULL;
g_autoptr(MMBaseModem) modem = NULL;
g_object_get (self, MM_BASE_BEARER_MODEM, &modem, NULL);
g_assert (modem);
/* APN settings */
ctx->apn = g_strdup (mm_3gpp_profile_get_apn (profile));
@@ -922,7 +926,11 @@ load_settings_from_profile (MMBearerMbim *self,
}
apn_type = default_apn_type;
}
ctx->context_type = mm_bearer_apn_type_to_mbim_context_type (apn_type, self, &inner_error);
ctx->context_type = mm_bearer_apn_type_to_mbim_context_type (
apn_type,
mm_broadband_modem_mbim_is_context_type_ext_supported (MM_BROADBAND_MODEM_MBIM (modem)),
self,
&inner_error);
if (inner_error) {
g_propagate_error (error, inner_error);
return FALSE;

View File

@@ -120,6 +120,7 @@ struct _MMBroadbandModemMbimPrivate {
/* Supported features */
gboolean is_profile_management_supported;
gboolean is_profile_management_ext_supported;
gboolean is_context_type_ext_supported;
gboolean is_pco_supported;
gboolean is_lte_attach_info_supported;
gboolean is_nr5g_registration_settings_supported;
@@ -389,6 +390,14 @@ mm_broadband_modem_mbim_peek_port_mbim_for_data (MMBroadbandModemMbim *self,
return MM_BROADBAND_MODEM_MBIM_GET_CLASS (self)->peek_port_mbim_for_data (self, data, error);
}
/*****************************************************************************/
gboolean
mm_broadband_modem_mbim_is_context_type_ext_supported (MMBroadbandModemMbim *self)
{
return self->priv->is_context_type_ext_supported;
}
/*****************************************************************************/
/* Current capabilities (Modem interface) */
@@ -3281,6 +3290,8 @@ query_device_services_ready (MbimDevice *device,
mm_obj_dbg (self, "Base stations info is supported");
self->priv->is_base_stations_info_supported = TRUE;
} else if (device_services[i]->cids[j] == MBIM_CID_MS_BASIC_CONNECT_EXTENSIONS_PROVISIONED_CONTEXTS) {
mm_obj_dbg (self, "Context types extension is supported");
self->priv->is_context_type_ext_supported = TRUE;
if (mm_context_get_test_mbimex_profile_management ()) {
mm_obj_dbg (self, "Profile management extension is supported");
self->priv->is_profile_management_ext_supported = TRUE;
@@ -7223,7 +7234,10 @@ modem_3gpp_profile_manager_store_profile (MMIfaceModem3gppProfileManager *_self,
ctx->apn_type = mm_3gpp_profile_get_apn_type (profile);
apn_type_str = mm_bearer_apn_type_build_string_from_mask (ctx->apn_type);
context_type = mm_bearer_apn_type_to_mbim_context_type (ctx->apn_type, self, &error);
context_type = mm_bearer_apn_type_to_mbim_context_type (ctx->apn_type,
self->priv->is_context_type_ext_supported,
self,
&error);
if (error) {
g_prefix_error (&error, "Failed to convert mbim context type from apn type: ");
g_task_return_error (task, error);
@@ -7398,11 +7412,11 @@ modem_3gpp_profile_manager_delete_profile (MMIfaceModem3gppProfileManager *_self
MbimContextType context_type;
g_assert (self->priv->is_profile_management_ext_supported);
g_assert (self->priv->is_context_type_ext_supported);
apn_type = mm_3gpp_profile_get_apn_type (profile);
g_assert (apn_type != MM_BEARER_APN_TYPE_NONE);
context_type = mm_bearer_apn_type_to_mbim_context_type (apn_type, self, &error);
context_type = mm_bearer_apn_type_to_mbim_context_type (apn_type, TRUE, self, &error);
if (error)
g_prefix_error (&error, "Failed to convert mbim context type from apn type: ");
else {

View File

@@ -71,4 +71,6 @@ void mm_broadband_modem_mbim_get_speeds (MMBroadbandModemMbim *self,
guint64 *uplink_speed,
guint64 *downlink_speed);
gboolean mm_broadband_modem_mbim_is_context_type_ext_supported (MMBroadbandModemMbim *self);
#endif /* MM_BROADBAND_MODEM_MBIM_H */

View File

@@ -562,6 +562,7 @@ mm_bearer_apn_type_from_mbim_context_type (MbimContextType context_type)
MbimContextType
mm_bearer_apn_type_to_mbim_context_type (MMBearerApnType apn_type,
gboolean mbim_extensions_supported,
gpointer log_object,
GError **error)
{
@@ -580,8 +581,6 @@ mm_bearer_apn_type_to_mbim_context_type (MMBearerApnType apn_type,
return MBIM_CONTEXT_TYPE_IMS;
if (apn_type & MM_BEARER_APN_TYPE_MMS)
return MBIM_CONTEXT_TYPE_MMS;
if (apn_type &MM_BEARER_APN_TYPE_MANAGEMENT)
return MBIM_CONTEXT_TYPE_ADMIN;
if (apn_type & MM_BEARER_APN_TYPE_VOICE)
return MBIM_CONTEXT_TYPE_VOICE;
if (apn_type & MM_BEARER_APN_TYPE_PRIVATE)
@@ -592,14 +591,30 @@ mm_bearer_apn_type_to_mbim_context_type (MMBearerApnType apn_type,
return MBIM_CONTEXT_TYPE_VIDEO_SHARE;
if (apn_type & MM_BEARER_APN_TYPE_LOCAL)
return MBIM_CONTEXT_TYPE_LOCAL;
if (apn_type & MM_BEARER_APN_TYPE_APP)
return MBIM_CONTEXT_TYPE_APP;
if (apn_type & MM_BEARER_APN_TYPE_XCAP)
return MBIM_CONTEXT_TYPE_XCAP;
if (apn_type & MM_BEARER_APN_TYPE_TETHERING)
return MBIM_CONTEXT_TYPE_TETHERING;
if (apn_type & MM_BEARER_APN_TYPE_EMERGENCY)
return MBIM_CONTEXT_TYPE_EMERGENCY_CALLING;
if (mbim_extensions_supported) {
if (apn_type & MM_BEARER_APN_TYPE_MANAGEMENT)
return MBIM_CONTEXT_TYPE_ADMIN;
if (apn_type & MM_BEARER_APN_TYPE_APP)
return MBIM_CONTEXT_TYPE_APP;
if (apn_type & MM_BEARER_APN_TYPE_XCAP)
return MBIM_CONTEXT_TYPE_XCAP;
if (apn_type & MM_BEARER_APN_TYPE_TETHERING)
return MBIM_CONTEXT_TYPE_TETHERING;
if (apn_type & MM_BEARER_APN_TYPE_EMERGENCY)
return MBIM_CONTEXT_TYPE_EMERGENCY_CALLING;
} else {
if ((apn_type & MM_BEARER_APN_TYPE_MANAGEMENT) ||
(apn_type & MM_BEARER_APN_TYPE_APP) ||
(apn_type & MM_BEARER_APN_TYPE_XCAP) ||
(apn_type & MM_BEARER_APN_TYPE_TETHERING) ||
(apn_type & MM_BEARER_APN_TYPE_EMERGENCY)) {
mm_obj_dbg (log_object,
"MS extensions unsupported: "
"fallback to using default (internet) APN type");
return MBIM_CONTEXT_TYPE_INTERNET;
}
}
str = mm_bearer_apn_type_build_string_from_mask (apn_type);
g_set_error (error,

View File

@@ -66,6 +66,7 @@ MbimContextIpType mm_bearer_ip_family_to_mbim_context_ip_type (MMBearerIpFa
GError **error);
MMBearerApnType mm_bearer_apn_type_from_mbim_context_type (MbimContextType context_type);
MbimContextType mm_bearer_apn_type_to_mbim_context_type (MMBearerApnType apn_type,
gboolean mbim_extensions_supported,
gpointer log_object,
GError **error);