[PATCH] bearer-mbim: handle already disconnected case

Prathmesh Prabhu Chromium pprabhu at chromium.org
Fri Jun 13 19:24:34 PDT 2014


Heads up!
benchan at chromium.org had some offline comments.
I'll submit an updated patch set (mostly on Monday).


On Fri, Jun 13, 2014 at 2:29 PM, Prathmesh Prabhu Chromium <
pprabhu at chromium.org> wrote:

> Trace from a successful disconnect:
>
> 2014-06-13T21:50:08.819297+01:00 localhost ModemManager[7467]: <debug>
> Disconnecting bearer '/org/freedesktop/ModemManager1/Bearer/0'
> 2014-06-13T21:50:08.819403+01:00 localhost ModemManager[7467]: <info>
>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connected ->
> disconnecting)
> 2014-06-13T21:50:08.820824+01:00 localhost ModemManager[7467]: <debug>
> Launching disconnection on data port (net/wwan0)
> 2014-06-13T21:50:08.821363+01:00 localhost ModemManager[7467]:
> [/dev/cdc-wdm0] Sent message...#012<<<<<< RAW:#012<<<<<<   length =
> 108#012<<<<<<   data   =
> 03:00:00:00:6C:00:00:00:16:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:01:00:00:00:3C:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:7E:5E:2A:7E:4E:6F:72:72:73:6B:65:6E:7E:5E:2A:7E
> 2014-06-13T21:50:08.821427+01:00 localhost ModemManager[7467]:
> [/dev/cdc-wdm0] Sent message (translated)...#012<<<<<< Header:#012<<<<<<
> length      = 108#012<<<<<<   type        = command (0x00000003)#012<<<<<<
>   transaction = 22#012<<<<<< Fragment header:#012<<<<<<   total   =
> 1#012<<<<<<   current = 0#012<<<<<< Contents:#012<<<<<<   service =
> 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012<<<<<<   cid
> = 'connect' (0x0000000c)#012<<<<<<   type    = 'set' (0x00000001)
> 2014-06-13T21:50:08.824002+01:00 localhost ModemManager[7467]:
> [/dev/cdc-wdm0] Received message...#012>>>>>> RAW:#012>>>>>>   length =
> 84#012>>>>>>   data   =
> 03:00:00:80:54:00:00:00:16:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:00:00:00:00:24:00:00:00:00:00:00:00:03:00:00:00:00:00:00:00:00:00:00:00:7E:5E:2A:7E:4E:6F:72:72:73:6B:65:6E:7E:5E:2A:7E:00:00:00:00
> 2014-06-13T21:50:08.824038+01:00 localhost ModemManager[7467]:
> [/dev/cdc-wdm0] Received message (translated)...#012>>>>>>
> Header:#012>>>>>>   length      = 84#012>>>>>>   type        = command-done
> (0x80000003)#012>>>>>>   transaction = 22#012>>>>>> Fragment
> header:#012>>>>>>   total   = 1#012>>>>>>   current = 0#012>>>>>>
> Contents:#012>>>>>>   status error = 'None' (0x00000000)#012>>>>>>
> service      = 'basic-connect'
> (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012>>>>>>   cid          = 'connect'
> (0x0000000c)
> 2014-06-13T21:50:08.824053+01:00 localhost ModemManager[7467]: <debug>
> Session ID '0': deactivated
> 2014-06-13T21:50:08.824061+01:00 localhost ModemManager[7467]: <debug>
> (wwan0): port now disconnected
> 2014-06-13T21:50:08.824070+01:00 localhost ModemManager[7467]: <debug>
> Disconnected bearer '/org/freedesktop/ModemManager1/Bearer/0'
> 2014-06-13T21:50:08.824078+01:00 localhost ModemManager[7467]: <info>
>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (disconnecting
> -> registered)
>
>
> Trace from a failed disconnect (simulated by reducing the timeout to 1
> seconds (that ought to be enough for everybody, right? ;) ).
> The second attempt to disconnect hits the CONTEXT_NOT_ACTIVATED error, and
> succeeds.
>
> 2014-06-13T21:41:32.436382+01:00 localhost ModemManager[25314]: <debug>
> Disconnecting bearer '/org/freedesktop/ModemManager1/Bearer/0'
> 2014-06-13T21:41:32.436436+01:00 localhost ModemManager[25314]: <info>
>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connected ->
> disconnecting)
> 2014-06-13T21:41:32.437900+01:00 localhost ModemManager[25314]: <debug>
> Launching disconnection on data port (net/wwan0)
> 2014-06-13T21:41:32.438038+01:00 localhost ModemManager[25314]:
> [/dev/cdc-wdm0] Sent message...#012<<<<<< RAW:#012<<<<<<   length =
> 108#012<<<<<<   data   =
> 03:00:00:00:6C:00:00:00:16:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:01:00:00:00:3C:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:7E:5E:2A:7E:4E:6F:72:72:73:6B:65:6E:7E:5E:2A:7E
> 2014-06-13T21:41:32.438054+01:00 localhost ModemManager[25314]:
> [/dev/cdc-wdm0] Sent message (translated)...#012<<<<<< Header:#012<<<<<<
> length      = 108#012<<<<<<   type        = command (0x00000003)#012<<<<<<
>   transaction = 22#012<<<<<< Fragment header:#012<<<<<<   total   =
> 1#012<<<<<<   current = 0#012<<<<<< Contents:#012<<<<<<   service =
> 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012<<<<<<   cid
> = 'connect' (0x0000000c)#012<<<<<<   type    = 'set' (0x00000001)
> 2014-06-13T21:41:33.438774+01:00 localhost ModemManager[25314]: <debug>
> Couldn't disconnect bearer '/org/freedesktop/ModemManager1/Bearer/0'
> 2014-06-13T21:41:33.438856+01:00 localhost ModemManager[25314]: <info>
>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (disconnecting
> -> connected)
> 2014-06-13T21:41:38.801220+01:00 localhost ModemManager[25314]:
> [/dev/cdc-wdm0] Received message...#012>>>>>> RAW:#012>>>>>>   length =
> 84#012>>>>>>   data   =
> 03:00:00:80:54:00:00:00:16:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:00:00:00:00:24:00:00:00:00:00:00:00:03:00:00:00:00:00:00:00:00:00:00:00:7E:5E:2A:7E:4E:6F:72:72:73:6B:65:6E:7E:5E:2A:7E:00:00:00:00
> 2014-06-13T21:41:38.801294+01:00 localhost ModemManager[25314]:
> [/dev/cdc-wdm0] No transaction matched in received message
> 2014-06-13T21:41:38.801314+01:00 localhost ModemManager[25314]:
> [/dev/cdc-wdm0] Received unexpected message (translated)...#012>>>>>>
> Header:#012>>>>>>   length      = 84#012>>>>>>   type        = command-done
> (0x80000003)#012>>>>>>   transaction = 22#012>>>>>> Fragment
> header:#012>>>>>>   total   = 1#012>>>>>>   current = 0#012>>>>>>
> Contents:#012>>>>>>   status error = 'None' (0x00000000)#012>>>>>>
> service      = 'basic-connect'
> (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012>>>>>>   cid          = 'connect'
> (0x0000000c)
> 2014-06-13T21:41:45.368826+01:00 localhost ModemManager[25314]: <debug>
> Disconnecting bearer '/org/freedesktop/ModemManager1/Bearer/0'
> 2014-06-13T21:41:45.369408+01:00 localhost ModemManager[25314]: <info>
>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connected ->
> disconnecting)
> 2014-06-13T21:41:45.370606+01:00 localhost ModemManager[25314]: <debug>
> Launching disconnection on data port (net/wwan0)
> 2014-06-13T21:41:45.370642+01:00 localhost ModemManager[25314]:
> [/dev/cdc-wdm0] Sent message...#012<<<<<< RAW:#012<<<<<<   length =
> 108#012<<<<<<   data   =
> 03:00:00:00:6C:00:00:00:17:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:01:00:00:00:3C:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:7E:5E:2A:7E:4E:6F:72:72:73:6B:65:6E:7E:5E:2A:7E
> 2014-06-13T21:41:45.370656+01:00 localhost ModemManager[25314]:
> [/dev/cdc-wdm0] Sent message (translated)...#012<<<<<< Header:#012<<<<<<
> length      = 108#012<<<<<<   type        = command (0x00000003)#012<<<<<<
>   transaction = 23#012<<<<<< Fragment header:#012<<<<<<   total   =
> 1#012<<<<<<   current = 0#012<<<<<< Contents:#012<<<<<<   service =
> 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012<<<<<<   cid
> = 'connect' (0x0000000c)#012<<<<<<   type    = 'set' (0x00000001)
> 2014-06-13T21:41:45.373771+01:00 localhost ModemManager[25314]:
> [/dev/cdc-wdm0] Received message...#012>>>>>> RAW:#012>>>>>>   length =
> 84#012>>>>>>   data   =
> 03:00:00:80:54:00:00:00:17:00:00:00:01:00:00:00:00:00:00:00:A2:89:CC:33:BC:BB:8B:4F:B6:B0:13:3E:C2:AA:E6:DF:0C:00:00:00:10:00:00:00:24:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
> 2014-06-13T21:41:45.373805+01:00 localhost ModemManager[25314]:
> [/dev/cdc-wdm0] Received message (translated)...#012>>>>>>
> Header:#012>>>>>>   length      = 84#012>>>>>>   type        = command-done
> (0x80000003)#012>>>>>>   transaction = 23#012>>>>>> Fragment
> header:#012>>>>>>   total   = 1#012>>>>>>   current = 0#012>>>>>>
> Contents:#012>>>>>>   status error = 'ContextNotActivated'
> (0x00000010)#012>>>>>>   service      = 'basic-connect'
> (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)#012>>>>>>   cid          = 'connect'
> (0x0000000c)
> 2014-06-13T21:41:45.373819+01:00 localhost ModemManager[25314]: <debug>
> Session ID '0' already disconnected.
> 2014-06-13T21:41:45.373828+01:00 localhost ModemManager[25314]: <debug>
> (wwan0): port now disconnected
> 2014-06-13T21:41:45.373837+01:00 localhost ModemManager[25314]: <debug>
> Disconnected bearer '/org/freedesktop/ModemManager1/Bearer/0'
>
>
>
>
> On Fri, Jun 13, 2014 at 2:22 PM, <pprabhu at chromium.org> wrote:
>
>> From: Prathmesh Prabhu <pprabhu at chromium.org>
>>
>> If the modem responds with MBIM_STATUS_ERROR_CONTEXT_NOT_ACTIVATED, take
>> it to
>> mean that the bearer has already been disconnected.
>> ---
>>  src/mm-bearer-mbim.c | 61
>> +++++++++++++++++++++++++++++++---------------------
>>  1 file changed, 37 insertions(+), 24 deletions(-)
>>
>> diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c
>> index b1e3176..cc658ee 100644
>> --- a/src/mm-bearer-mbim.c
>> +++ b/src/mm-bearer-mbim.c
>> @@ -950,35 +950,48 @@ disconnect_set_ready (MbimDevice *device,
>>      guint32 nw_error;
>>
>>      response = mbim_device_command_finish (device, res, &error);
>> -    if (response &&
>> -        (mbim_message_command_done_get_result (response, &error) ||
>> -         error->code == MBIM_STATUS_ERROR_FAILURE)) {
>> +    if (response) {
>>          GError *inner_error = NULL;
>> +        gboolean result = FALSE, parsed_result = FALSE;
>> +
>> +        result = mbim_message_command_done_get_result(response, &error);
>> +        /* Parse the response only for the cases we need to */
>> +        if (result ||
>> +            error->code == MBIM_STATUS_ERROR_FAILURE ||
>> +            error->code == MBIM_STATUS_ERROR_CONTEXT_NOT_ACTIVATED) {
>> +            parsed_result = mbim_message_connect_response_parse (
>> +                    response,
>> +                    &session_id,
>> +                    &activation_state,
>> +                    NULL, /* voice_call_state */
>> +                    NULL, /* ip_type */
>> +                    NULL, /* context_type */
>> +                    &nw_error,
>> +                    &inner_error);
>> +        }
>>
>> -        if (mbim_message_connect_response_parse (
>> -                response,
>> -                &session_id,
>> -                &activation_state,
>> -                NULL, /* voice_call_state */
>> -                NULL, /* ip_type */
>> -                NULL, /* context_type */
>> -                &nw_error,
>> -                &inner_error)) {
>> +        /* Now handle different response / error cases */
>> +        if (result && parsed_result) {
>> +            mm_dbg ("Session ID '%u': %s",
>> +                    session_id,
>> +                    mbim_activation_state_get_string (activation_state));
>> +        } else if (error->code ==
>> MBIM_STATUS_ERROR_CONTEXT_NOT_ACTIVATED) {
>> +            mm_dbg ("Session ID '%u' already disconnected.", session_id);
>> +            g_clear_error (&error);
>> +            g_clear_error (&inner_error);
>> +        } else if (error->code == MBIM_STATUS_ERROR_FAILURE) {
>> +            /* This is the only case when nw_error may be set */
>>              if (nw_error) {
>> -                if (error)
>> -                    g_error_free (error);
>> +                g_error_free (error);
>>                  error = mm_mobile_equipment_error_from_mbim_nw_error
>> (nw_error);
>> -            } else
>> -                mm_dbg ("Session ID '%u': %s",
>> -                        session_id,
>> -                        mbim_activation_state_get_string
>> (activation_state));
>> -        } else {
>> -            /* Prefer the error from the result to the parsing error */
>> -            if (!error)
>> -                error = inner_error;
>> -            else
>> -                g_error_free (inner_error);
>> +            }
>> +        }  /* else: Some other error->code we don't care about OR
>> (result && !parsed_result) */
>> +
>> +        /* Give precedence to original error over parsing error */
>> +        if (!error && inner_error) {
>> +            error = inner_error;
>>          }
>> +        g_clear_error(&inner_error);
>>      }
>>
>>      if (response)
>> --
>> 2.0.0.526.g5318336
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/modemmanager-devel/attachments/20140613/f6849a5d/attachment-0001.html>


More information about the ModemManager-devel mailing list