oFono: Plugin Has the Incorrect Conditional for Evaluating When a Context Was Successfully Added

Grant Erickson <[email protected]>
Newsgroups dev.linux.lists.connman,dev.linux.lists.ofono
Message-ID <[email protected]>
Team Connection Manager and Ofono:

At the appropriate moment in the oFono plugin lifecycle, it gets and evaluates contexts from a given Cellular modem. Depending on the HNI/MCC+MNC and the network operator, there may be one or more such contexts, each with a different type.

Within ‘cm_get_contexts_reply', each received context is iterated on, evaluating each for the type ‘internet' by calling ‘add_cm_context'. If the context is not of type ‘internet’, ‘cm_get_contexts_reply' should continue to iterate until all contexts are exhausted or a matching context is found.

The return semantics of ‘add_cm_context’ are ‘-EINVAL' if a context *not* of the type ‘internet' is evaluated; otherwise zero ('0') if a context of type ‘internet' was found.

However, the current conditional logic of ‘cm_get_contexts_reply' is:

    while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_STRUCT) {
        const char *context_path;

        dbus_message_iter_recurse(&dict, &entry);
        dbus_message_iter_get_basic(&entry, &context_path);

        dbus_message_iter_next(&entry);
        dbus_message_iter_recurse(&entry, &value);

        if (add_cm_context(modem, context_path, &value))
            break;

        dbus_message_iter_next(&dict);
    }

So, assuming a set of contexts from, for example Verizon, such as '[ { vzwims, ims }, { vzwinternet, internet }, { vzwapp, wap } ]', then the above logic will encounter '{ vzwims, ims }', evaluate that it is not of type ‘internet', return ‘-EINVAL' from ‘add_cm_context', that will satisfy the conditional and trigger the ‘break' from the ‘while' loop and context iteration will terminate. This then misses the second '{ vzwinternet, internet }' context that was sought and the Cellular interface will never come up on connman.

See https://github.com/Nuovations/connman/issues/133.

Patch forthcoming which amounts to:

        if (add_cm_context(modem, context_path, &value) == 0)
            break;

Best,

Grant

-- 
Principal
Nuovations

[email protected]
https://www.nuovations.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.