diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-03-11 10:43:05 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-03-17 09:39:10 +0100 |
commit | e5305498b7ddbc5e419cf51fc0c30aa6593a40d2 (patch) | |
tree | 0b356745ee60f0effb5c91447d4d8876cecd7414 /src | |
parent | 0830f9510cd67c25de57a4ffc5086882b59b3d12 (diff) |
bearer-mbim: session id 0 by default in all non-multiplexed connections
The original logic in the MBIM modem would assume that if we had more
than one network interface in the same modem, we could connect
multiple data interfaces, each one with a different session. That
logic is actually wrong, when using the master (non-multiplexed)
network interface we should always use session id 0, which is the one
holding all non-VLAN-tagged traffic.
So, remove the logic that automatically creates new bearers with a
different session id, as that is really wrong.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-bearer-mbim.c | 64 | ||||
-rw-r--r-- | src/mm-bearer-mbim.h | 3 | ||||
-rw-r--r-- | src/mm-broadband-modem-mbim.c | 90 |
3 files changed, 16 insertions, 141 deletions
diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c index 16dcad45..323483ce 100644 --- a/src/mm-bearer-mbim.c +++ b/src/mm-bearer-mbim.c @@ -34,18 +34,9 @@ G_DEFINE_TYPE (MMBearerMbim, mm_bearer_mbim, MM_TYPE_BASE_BEARER) -enum { - PROP_0, - PROP_SESSION_ID, - PROP_LAST -}; - -static GParamSpec *properties[PROP_LAST]; - struct _MMBearerMbimPrivate { /* The session ID for this bearer */ guint32 session_id; - MMPort *data; }; @@ -1320,8 +1311,7 @@ report_connection_status (MMBaseBearer *self, MMBaseBearer * mm_bearer_mbim_new (MMBroadbandModemMbim *modem, - MMBearerProperties *config, - guint32 session_id) + MMBearerProperties *config) { MMBaseBearer *bearer; @@ -1329,9 +1319,8 @@ mm_bearer_mbim_new (MMBroadbandModemMbim *modem, * and that means that the object is not async-initable, so we just use * g_object_new() here */ bearer = g_object_new (MM_TYPE_BEARER_MBIM, - MM_BASE_BEARER_MODEM, modem, + MM_BASE_BEARER_MODEM, modem, MM_BASE_BEARER_CONFIG, config, - MM_BEARER_MBIM_SESSION_ID, (guint)session_id, NULL); /* Only export valid bearers */ @@ -1341,43 +1330,6 @@ mm_bearer_mbim_new (MMBroadbandModemMbim *modem, } static void -set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - MMBearerMbim *self = MM_BEARER_MBIM (object); - - switch (prop_id) { - case PROP_SESSION_ID: - self->priv->session_id = g_value_get_uint (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - MMBearerMbim *self = MM_BEARER_MBIM (object); - - switch (prop_id) { - case PROP_SESSION_ID: - g_value_set_uint (value, self->priv->session_id); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - -static void mm_bearer_mbim_init (MMBearerMbim *self) { /* Initialize private data */ @@ -1404,8 +1356,6 @@ mm_bearer_mbim_class_init (MMBearerMbimClass *klass) /* Virtual methods */ object_class->dispose = dispose; - object_class->get_property = get_property; - object_class->set_property = set_property; base_bearer_class->connect = _connect; base_bearer_class->connect_finish = connect_finish; @@ -1416,14 +1366,4 @@ mm_bearer_mbim_class_init (MMBearerMbimClass *klass) base_bearer_class->reload_stats_finish = reload_stats_finish; base_bearer_class->load_connection_status = NULL; base_bearer_class->load_connection_status_finish = NULL; - - properties[PROP_SESSION_ID] = - g_param_spec_uint (MM_BEARER_MBIM_SESSION_ID, - "Session ID", - "Session ID to use with this bearer", - 0, - 255, - 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_SESSION_ID, properties[PROP_SESSION_ID]); } diff --git a/src/mm-bearer-mbim.h b/src/mm-bearer-mbim.h index 0d97d8d9..3da599a6 100644 --- a/src/mm-bearer-mbim.h +++ b/src/mm-bearer-mbim.h @@ -53,8 +53,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMBearerMbim, g_object_unref) /* MBIM bearer creation implementation. * NOTE it is *not* a broadband bearer, so not async-initable */ MMBaseBearer *mm_bearer_mbim_new (MMBroadbandModemMbim *modem, - MMBearerProperties *config, - guint32 session_id); + MMBearerProperties *config); guint32 mm_bearer_mbim_get_session_id (MMBearerMbim *self); diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index a578aba1..baae397b 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -1962,93 +1962,29 @@ modem_reset (MMIfaceModem *_self, /* Create Bearer (Modem interface) */ static MMBaseBearer * -modem_create_bearer_finish (MMIfaceModem *self, - GAsyncResult *res, - GError **error) +modem_create_bearer_finish (MMIfaceModem *self, + GAsyncResult *res, + GError **error) { return g_task_propagate_pointer (G_TASK (res), error); } -typedef struct { - guint32 session_id; - gboolean found; -} FindSessionId; - static void -bearer_list_session_id_foreach (MMBaseBearer *bearer, - gpointer user_data) +modem_create_bearer (MMIfaceModem *self, + MMBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data) { - FindSessionId *ctx = user_data; - - if (!ctx->found && - MM_IS_BEARER_MBIM (bearer) && - mm_bearer_mbim_get_session_id (MM_BEARER_MBIM (bearer)) == ctx->session_id) - ctx->found = TRUE; -} - -static gint -find_next_bearer_session_id (MMBroadbandModemMbim *self) -{ - MMBearerList *bearer_list; - guint i; - - g_object_get (self, - MM_IFACE_MODEM_BEARER_LIST, &bearer_list, - NULL); - - if (!bearer_list) - return 0; - - for (i = 0; i <= 255; i++) { - FindSessionId ctx; - - ctx.session_id = i; - ctx.found = FALSE; - - mm_bearer_list_foreach (bearer_list, - bearer_list_session_id_foreach, - &ctx); - - if (!ctx.found) { - g_object_unref (bearer_list); - return (gint)i; - } - } - - /* no valid session id found */ - g_object_unref (bearer_list); - return -1; -} - -static void -modem_create_bearer (MMIfaceModem *_self, - MMBearerProperties *properties, - GAsyncReadyCallback callback, - gpointer user_data) -{ - MMBroadbandModemMbim *self = MM_BROADBAND_MODEM_MBIM (_self); MMBaseBearer *bearer; - GTask *task; - gint session_id; - - task = g_task_new (self, NULL, callback, user_data); + GTask *task; - /* Find a new session ID */ - session_id = find_next_bearer_session_id (self); - if (session_id < 0) { - g_task_return_new_error (task, - MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Not enough session IDs"); - g_object_unref (task); - return; - } + /* Note: the session id to be used by the bearer will always be 0 + * for non-multiplexed sessions, bound to the non-VLAN-tagged traffic + * managed by the master network interface */ - /* We just create a MMBearerMbim */ + task = g_task_new (self, NULL, callback, user_data); mm_obj_dbg (self, "creating MBIM bearer in MBIM modem"); - bearer = mm_bearer_mbim_new (self, - properties, - (guint)session_id); + bearer = mm_bearer_mbim_new (MM_BROADBAND_MODEM_MBIM (self), properties); g_task_return_pointer (task, bearer, g_object_unref); g_object_unref (task); } |