Help in establishing multiple simultaneous APNs: mmcli create/connect bearer

Riff Rafferty rafferty8933 at gmail.com
Thu Mar 17 02:38:41 UTC 2022


On Fri, Mar 4, 2022 at 9:43 AM Aleksander Morgado <aleksander at aleksander.es>
wrote:

> Hey,
>
> > I need some help in establishing simultaneous interfaces to multiple
> APNs.
> >
> > I have an Ubuntu 20.04 system with a single cellular modem attached via
> USB in an IoT application. My problem is that I need to drive traffic
> through two different APNs when registered to the same cellular network.
> Each APN serves a different purpose -- different services with different
> billing are to occur on each.
> >
> > I've tried multiple ways to do this. While I can get connected with two
> APNs, I can only get an interface name for one of the connections. I need a
> separate interface name for each so that I can place the respective flow of
> traffic through the appropriate interface and onto the correct APN. My
> application needs both to be available simultaneously. Going back and forth
> between building up and tearing down each of them is not an acceptable
> solution.
> >
> > I tried three different things and none have brought happiness:
> >
> > (1) Using mmcli in debug mode with a set of AT commands for each APN:
> using the sequence AT+GDCONT, AT+XGAUTH, and AT+CGACT with parameters
> relevant for the first APN and then again with the sequence AT+GDCONT,
> AT+XGAUTH, and AT+CGACT for the second APN. This is successful, and I
> obtain assigned IP addresses for each APN. However, neither of the APNs are
> assigned to an interface and I don't know how to funnel traffic to each.
> >
> > (2) I have used the bearer features of mmcli. I have run "mmcli -m
> <modem-number> --create-bearer=<key-value pairs>" two times, each with the
> proper key-value pairs for the respective APNs. When I later run "mmcli -m
> <modem_number>", I see both bearers. I then run "mmcli -m <modem-number>
> --bearer <bearer-number> --connect". This works the first time for the
> first APN/bearer, and I have an interface assigned. But I get the following
> error when next running " mmcli -m <modem-number> --bearer <bearer-number>
> --connect" for the second APN/bearer:
> > error: couldn't connect the bearer: 'GDBusError:
> org.freedesktop.ModemManager1.Error.Core.NotFound: No valid data port to
> launch connection'
> >
> > (3) I've put multiple connection keyfiles in the
> /etc/NetworkManager/system-connections directory. I run "nmcli con reload"
> and then "nmcli --wait 120 con up id <name_of_first_connection>". This
> works as I get connected to the first APN, get assigned an IP address, and
> get an interface association (wwan0). However, when I run "nmcli --wait 120
> con up id <name_of_second_connection>", this works, but it displaces the
> first connection, so I am only left with the second connection on interface
> wwan0. The first connection is no longer available.
> >
> > My Ubuntu 20.04 system has mmcli 1.16.6 and nmcli 1.22.10. I could also
> install mbimcli 1.24.8, although it is not currently part of the system
> image.
> >
> > Ideas on how to accomplish what I am after?
>
> Your modem needs to be QMI or MBIM based, and you need to install
> ModemManager 1.18, which is the first version supporting multiplexing.
> Once you have that, you can:
>  *  run Modem.SimpleConnect() with"multiplex=required"
> Or:
>  * start the ModemManager daemon with the additional
> --test-multiplex-requested option.
>
> My suggestion is to use the 2nd option, just start MM with
> --test-multiplex-requested so that any attempt to start a connection
> (e.g. via NetworkManager) will trigger the multiplex setup. When
> running with multiplex enabled, ModemManager will create a new virtual
> network interface for each APN connection, and then you can handle
> custom routing rules in the host for each of them.
>
> I talked a bit about this feature in the FOSDEM2022 talk earlier this
> year, if you're interested:
> https://fosdem.org/2022/schedule/event/mobile_modemmanager/
>
> --
> Aleksander
> https://aleksander.es


I attempted to use mmcli 1.18.6 and nmcli 1.36.0 with the create and
connect bearer features of mmcli to create multiple simultaneous
connections to two different APNs with a USB cellular modem on an Ubuntu
Jammy Jellyfish 22.04 system. The ModemManager.service file had the debug
and test-multiplex-requested options activated on the ExecStart line.

Short summary of results:

A sequence of mmcli commands to create a bearer, connect the bearer, create
a second bearer, then connect the second bearer did result in multiple
simultaneous packet data network connections. Some subsequent configuration
with ip and route commands were necessary to make it work, but the second
connection failed after a few minutes with error
org.freedesktop.ModemManager1.Error.MobileEquipment.Unknown.

More details starting from the beginning:

After booting and logging in, I plugged in the modem into the system, it
reported this configuration:

user at ubuntu22a:~/Documents$ ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet6 fe80::ad94:11a5:b4a6:eada  prefixlen 64  scopeid 0x20<link>

        ether 00:0c:29:df:a4:a1  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 321  bytes 51137 (51.1 KB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

        device interrupt 19  base 0x2000



lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 8850  bytes 637347 (637.3 KB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 8850  bytes 637347 (637.3 KB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



user at ubuntu22a:~/Documents$ ip link list

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
mode DEFAULT group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel
state UNKNOWN mode DEFAULT group default qlen 1000

    link/ether 00:0c:29:df:a4:a1 brd ff:ff:ff:ff:ff:ff

    altname enp2s1

3: wwan0: <BROADCAST,MULTICAST,NOARP> mtu 1428 qdisc noop state DOWN
mode DEFAULT group default qlen 1000

    link/ether 6a:d4:98:05:df:3a brd ff:ff:ff:ff:ff:ff



    link/ether 6a:d4:98:05:df:3a brd ff:ff:ff:ff:ff:ff



user at ubuntu22a:~/Documents$ route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

*<empty>*



Running the command “sudo mmcli -L” indicated that my modem was number 0. I
ran the following command:

sudo mmcli -m 0
–create-bearer=’apn=apnname1,ip-type=ipv4,allowed-auth=pap,user=apnuser1,password=apnpass1’

This was successful and created bearer number 0.

I then ran

sudo mmcli -m 0 -b 0 --connect

This was also successful.

After doing this, the system’s networking configuration looked as follows:

user at ubuntu22a:~/Documents$ ifconfig

*<ens33 and lo omitted for brevity’s sake; they are identical to first listing>*

mbimmux0.1: flags=4291<UP,BROADCAST,RUNNING,NOARP,MULTICAST>  mtu 1428

        inet6 fe80::98b0:d0ff:fe6e:dc9f  prefixlen 64  scopeid 0x20<link>

        inet6 2001:db53:18ae:0:98b0:d0ff:fe6e:dc9f  prefixlen 64
scopeid 0x0<global>

        inet6 2001:db53:18ae:0:3911:3b6a:6a96:92a4  prefixlen 64
scopeid 0x0<global>

        ether 9a:b0:d0:6e:dc:9f  txqueuelen 1000  (Ethernet)

        RX packets 1  bytes 88 (88.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 24  bytes 4191 (4.1 KB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



wwan0: flags=67<UP,BROADCAST,RUNNING>  mtu 1428

        inet6 fe80::98b0:d0ff:fe6e:dc9f  prefixlen 64  scopeid 0x20<link>

        ether 9a:b0:d0:6e:dc:9f  txqueuelen 1000  (Ethernet)

        RX packets 1  bytes 88 (88.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 30  bytes 4271 (4.2 KB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



user at ubuntu22a:~/Documents$ ip link list

*<1: lo and 2: ens33 omitted for brevity’s sake; they are identical to
first listing>*

3: wwan0: <BROADCAST,UP,LOWER_UP> mtu 1428 qdisc fq_codel state
UNKNOWN mode DEFAULT group default qlen 1000

    link/ether 9a:b0:d0:6e:dc:9f brd ff:ff:ff:ff:ff:ff

4: mbimmux0.1 at wwan0: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> mtu 1428
qdisc noqueue state UP mode DEFAULT group default qlen 1000

    link/ether 9a:b0:d0:6e:dc:9f brd ff:ff:ff:ff:ff:ff



user at ubuntu22a:~/Documents$ route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

*<empty>*



I then ran

sudo mmcli -m 0
–create-bearer=’apn=apnname2,ip-type=ipv4,allowed-auth=pap,user=apnuser2,password=apnpass2’

This was successful and created bearer number 1.

I then ran

sudo mmcli -m 0 -b 1 --connect

This was also successful.

After doing this, the system’s networking configuration looked as follows:

user at ubuntu22a:~/Documents$ ifconfig

*<ens33 and lo omitted for brevity’s sake; they are identical to first listing>*

mbimmux0.1: flags=4291<UP,BROADCAST,RUNNING,NOARP,MULTICAST>  mtu 1428

        inet6 fe80::98b0:d0ff:fe6e:dc9f  prefixlen 64  scopeid 0x20<link>

        inet6 2001:db53:18ae:0:98b0:d0ff:fe6e:dc9f  prefixlen 64
scopeid 0x0<global>

        inet6 2001:db53:18ae:0:3911:3b6a:6a96:92a4  prefixlen 64
scopeid 0x0<global>

        ether 9a:b0:d0:6e:dc:9f  txqueuelen 1000  (Ethernet)

        RX packets 1  bytes 88 (88.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 27  bytes 4512 (4.5 KB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



wwan0: flags=67<UP,BROADCAST,RUNNING>  mtu 1428

        inet6 fe80::98b0:d0ff:fe6e:dc9f  prefixlen 64  scopeid 0x20<link>

        ether 9a:b0:d0:6e:dc:9f  txqueuelen 1000  (Ethernet)

        RX packets 1  bytes 88 (88.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 36  bytes 4718 (4.7 KB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



user at ubuntu22a:~/Documents$ ip link list

*<1: lo and 2: ens33 omitted for brevity’s sake; they are identical to
first listing>*

3: wwan0: <BROADCAST,UP,LOWER_UP> mtu 1428 qdisc fq_codel state
UNKNOWN mode DEFAULT group default qlen 1000

    link/ether 9a:b0:d0:6e:dc:9f brd ff:ff:ff:ff:ff:ff

4: mbimmux0.1 at wwan0: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> mtu 1428
qdisc noqueue state UP mode DEFAULT group default qlen 1000

    link/ether 9a:b0:d0:6e:dc:9f brd ff:ff:ff:ff:ff:ff

5: mbimmux0.2 at wwan0: <BROADCAST> mtu 1428 qdisc noop state DOWN mode
DEFAULT group default qlen 1000

    link/ether 9a:b0:d0:6e:dc:9f brd ff:ff:ff:ff:ff:ff



user at ubuntu22a:~/Documents$ route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

*<empty>*



I noticed that mbimmux0.2 did not appear in the “ifconfig” output and that
“ip link list” did not report it as up. So I ran “sudo ip link set
mbimmux0.2 up” and then the interface configuration looked like this:

user at ubuntu22a:~/Documents$ ifconfig

*<ens33 and lo omitted for brevity’s sake; they are identical to first listing>*

mbimmux0.1: flags=4291<UP,BROADCAST,RUNNING,NOARP,MULTICAST>  mtu 1428

        inet6 fe80::98b0:d0ff:fe6e:dc9f  prefixlen 64  scopeid 0x20<link>

        inet6 2001:db53:18ae:0:98b0:d0ff:fe6e:dc9f  prefixlen 64
scopeid 0x0<global>

        inet6 2001:db53:18ae:0:3911:3b6a:6a96:92a4  prefixlen 64
scopeid 0x0<global>

        ether 9a:b0:d0:6e:dc:9f  txqueuelen 1000  (Ethernet)

        RX packets 1  bytes 88 (88.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 29  bytes 4726 (4.7 KB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



mbimmux0.2: flags=67<UP,BROADCAST,RUNNING>  mtu 1428

        inet6 2001:db53:18ae:0:19fd:361e:7fdb:ea15  prefixlen 64
scopeid 0x0<global>

        inet6 fe80::98b0:d0ff:fe6e:dc9f  prefixlen 64  scopeid 0x20<link>

        inet6 2001:db53:18ae:0:98b0:d0ff:fe6e:dc9f  prefixlen 64
scopeid 0x0<global>

        ether 9a:b0:d0:6e:dc:9f  txqueuelen 1000  (Ethernet)

        RX packets 1  bytes 88 (88.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 10  bytes 868 (868.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



wwan0: flags=67<UP,BROADCAST,RUNNING>  mtu 1428

        inet6 fe80::98b0:d0ff:fe6e:dc9f  prefixlen 64  scopeid 0x20<link>

        ether 9a:b0:d0:6e:dc:9f  txqueuelen 1000  (Ethernet)

        RX packets 2  bytes 176 (176.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 49  bytes 5688 (5.6 KB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



user at ubuntu22a:~/Documents$ ip link list

*<1: lo and 2: ens33 omitted for brevity’s sake; they are identical to
first listing>*

3: wwan0: <BROADCAST,UP,LOWER_UP> mtu 1428 qdisc fq_codel state
UNKNOWN mode DEFAULT group default qlen 1000

    link/ether 9a:b0:d0:6e:dc:9f brd ff:ff:ff:ff:ff:ff

4: mbimmux0.1 at wwan0: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> mtu 1428
qdisc noqueue state UP mode DEFAULT group default qlen 1000

    link/ether 9a:b0:d0:6e:dc:9f brd ff:ff:ff:ff:ff:ff

5: mbimmux0.2 at wwan0: <BROADCAST,UP,LOWER_UP> mtu 1428 qdisc noqueue
state UP mode DEFAULT group default qlen 1000

    link/ether 9a:b0:d0:6e:dc:9f brd ff:ff:ff:ff:ff:ff



user at ubuntu22a:~/Documents$ route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

*<empty>*



The status of the modem and the two bearers was then as follows:

user at ubuntu22a:~/Documents$ mmcli -m 0

  --------------------------------

  General  |                 path: /org/freedesktop/ModemManager1/Modem/0

           |            device id: a883afd9cd8161007d0e42fe1e7a52bd9073f70d

  --------------------------------

  Hardware |         manufacturer: Undisclosed, Inc.

           |                model: A101

           |    firmware revision: A101_01.2000.00

           |         h/w revision: A101_V4.5_MBIM_V4.5

           |            supported: gsm-umts, lte

           |              current: gsm-umts, lte

           |         equipment id: 101000000000008

  --------------------------------

  System   |               device:
/sys/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1

           |              drivers: cdc_acm, cdc_mbim

           |               plugin: generic

           |         primary port: cdc-wdm0

           |                ports: cdc-wdm0 (mbim), ttyACM0 (at),
ttyACM2 (at), wwan0 (net)

  --------------------------------

  Status   |       unlock retries: sim-pin2 (3)

           |                state: connected

           |          power state: on

           |          access tech: gprs

           |       signal quality: 80% (cached)

  --------------------------------

  Modes    |            supported: allowed: 2g, 3g, 4g; preferred: none

           |              current: allowed: 2g, 3g, 4g; preferred: none

  --------------------------------

  IP       |            supported: ipv4, ipv6, ipv4v6

  --------------------------------

  3GPP     |                 imei: 101000000000008

           |        enabled locks: fixed-dialing

           |          operator id: MCCMNC

           |        operator name: MCCMNC

           |         registration: roaming

  --------------------------------

  3GPP EPS | ue mode of operation: csps-2

  --------------------------------

  SIM      |     primary sim path: /org/freedesktop/ModemManager1/SIM/0

  --------------------------------

  Bearer   |                paths: /org/freedesktop/ModemManager1/Bearer/1

           |                       /org/freedesktop/ModemManager1/Bearer/0

user at ubuntu22a:~/Documents$ mmcli -m 0 -b 0

  ------------------------------------

  General            |           path: /org/freedesktop/ModemManager1/Bearer/0

                     |           type: default

  ------------------------------------

  Status             |      connected: yes

                     |      suspended: no

                     |    multiplexed: yes

                     |      interface: mbimmux0.1

                     |     ip timeout: 20

  ------------------------------------

  Properties         |            apn: apnname1

                     |        roaming: allowed

                     |        ip type: ipv4

                     |   allowed-auth: pap

                     |           user: apnuser1

                     |       password: apnpass1

  ------------------------------------

  IPv4 configuration |         method: static

                     |        address: 10.3.1.2

                     |         prefix: 24

                     |        gateway: 10.3.1.1

                     |            dns: 208.67.222.222, 208.67.220.220

  ------------------------------------

  Statistics         |       duration: 390

                     |       attempts: 1

                     | total-duration: 390

user at ubuntu22a:~/Documents$ mmcli -m 0 -b 1

  ------------------------------------

  General            |           path: /org/freedesktop/ModemManager1/Bearer/1

                     |           type: default

  ------------------------------------

  Status             |      connected: yes

                     |      suspended: no

                     |    multiplexed: yes

                     |      interface: mbimmux0.2

                     |     ip timeout: 20

  ------------------------------------

  Properties         |            apn: apnname2

                     |        roaming: allowed

                     |        ip type: ipv4

                     |   allowed-auth: pap

                     |           user: apnuser2

                     |       password: apnpass2

  ------------------------------------

  IPv4 configuration |         method: static

                     |        address: 10.3.1.3

                     |         prefix: 24

                     |        gateway: 10.3.1.1

                     |            dns: 208.67.222.222, 208.67.220.220

  ------------------------------------

  Statistics         |       attempts: 2

                     | total-duration: 284



I noticed that I would need to add some route information in order to be
able to direct traffic through the mmbimux0.1 and mbimmux0.2 interfaces.
This is fine.

However, after approximately five minutes of using and examining these
interfaces, I noticed the second bearer connection had failed with an
unknown error and mbimmux0.2 had been removed from the list of interfaces:

user at ubuntu22a:~/Documents$ mmcli -m 0 -b 1

  --------------------------------------

  General    |                     path: /org/freedesktop/ModemManager1/Bearer/1

             |                     type: default

  --------------------------------------

  Status     |                connected: no

             |    connection error name:
org.freedesktop.ModemManager1.Error.MobileEquipment.Unknown

             | connection error message: Unknown error

             |                suspended: no

             |              multiplexed: no

             |               ip timeout: 20

  --------------------------------------

  Properties |                      apn: apnname2

             |                  roaming: allowed

             |                  ip type: ipv4

             |             allowed-auth: pap

             |                     user: apnuser2

             |                 password: apnpass2

  --------------------------------------

  Statistics |                 duration: 294

             |                 attempts: 2

             |           total-duration: 578

user at ubuntu22a:~/Documents$ ifconfig

*<ens33 and lo omitted for brevity’s sake; they are identical to first listing>*

mbimmux0.1: flags=4291<UP,BROADCAST,RUNNING,NOARP,MULTICAST>  mtu 1428

        inet6 fe80::98b0:d0ff:fe6e:dc9f  prefixlen 64  scopeid 0x20<link>

        inet6 2001:db53:18ae:0:98b0:d0ff:fe6e:dc9f  prefixlen 64
scopeid 0x0<global>

        inet6 2001:db53:18ae:0:3911:3b6a:6a96:92a4  prefixlen 64
scopeid 0x0<global>

        ether 9a:b0:d0:6e:dc:9f  txqueuelen 1000  (Ethernet)

        RX packets 1  bytes 88 (88.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 30  bytes 4833 (4.8 KB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



wwan0: flags=67<UP,BROADCAST,RUNNING>  mtu 1428

        inet6 fe80::98b0:d0ff:fe6e:dc9f  prefixlen 64  scopeid 0x20<link>

        ether 9a:b0:d0:6e:dc:9f  txqueuelen 1000  (Ethernet)

        RX packets 3  bytes 264 (264.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 62  bytes 6621 (6.6 KB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



After it fails, running “sudo mmcli -m 0 -b 1 --connect” then “sudo ip link
set mbimmux0.2 up” puts things back in business. I did not expect to have
to keep checking and then stand it back up when it fails.

Questions:

1. How can I keep the second bearer connection from falling over?

2. Is it expected that “sudo ip link set mbimmux0.2 up” would be necessary
after the second bearer connection is established? Is this the right thing
to do?

3. Is there a way to have the ifconfig and route entries managed by any of
this software to avoid the need to “manually” manage them?

4. Any other advice to help me achieve happiness?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/modemmanager-devel/attachments/20220316/8c681e49/attachment-0001.htm>


More information about the ModemManager-devel mailing list