Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with ModemManager #20370

Open
zabbal opened this issue Aug 3, 2021 · 32 comments · May be fixed by #22315
Open

Integration with ModemManager #20370

zabbal opened this issue Aug 3, 2021 · 32 comments · May be fixed by #22315
Labels
network RFE 🎁 Request for Enhancement, i.e. a feature request

Comments

@zabbal
Copy link

zabbal commented Aug 3, 2021

Is your feature request related to a problem? Please describe.
Setting up WWAN connection with systemd-networkd is the major hurdle at the moment.

Describe the solution you'd like
Ability to specify a new .network or .netdev link type which would talk with ModemManager to establish and properly configure IP interface managed by systemd-networkd

Describe alternatives you've considered
Right now we have to resort to scripting and manual output parsing which is cumbersome and error-prone.

The typical WWAN connection bring-up looks as follows:

mmcli --list-modems
/org/freedesktop/ModemManager1/Modem/5 [QUALCOMM INCORPORATED] QUECTEL Mobile Broadband Module
# this gives the path and modem number e. g. 5:
mmcli --simple-connect="apn=test-internet.myapn" -m 5
successfully connected the modem
mmcli -m 5
...
Bearer                  paths: /org/freedesktop/ModemManager1/Bearer/3
# this (if succeed) gives the number of the established bearer e. g. 3:
mmcli -b 3

  General               path: /org/freedesktop/ModemManager1/Bearer/3
                             type: default  
  Status                 connected: yes
                             suspended: no
                             interface: wwan0
                             ip timeout: 20

  Properties           apn: test-internet.myapn
                            roaming: allowed

  IPv4 configuration       method: static
                                    address: 10.10.42.234
                                    prefix: 30
                                    gateway: 10.10.42.24
                                    dns: 8.8.8.8, 8.8.4.4
                                    mtu: 1500

  Statistics               duration: 60
                              attempts: 1
                              total-duration: 60

Now we have to parse the output of the mmcli (or use dbus - whatever) and get the IP address, Gateway and other parameters to generate wwan.network so it can be controlled with systemd-networkd.

Would be way more convenient if systemd-networkd could take care of low-level details and extract that information directly from ModemManager as well as gracefully handle network interruptions etc.

The systemd version you checked that didn't have the feature you are asking for
247

@yuwata yuwata added network RFE 🎁 Request for Enhancement, i.e. a feature request labels Aug 4, 2021
@benibr
Copy link

benibr commented Aug 9, 2021

I'd also like to have such an integration. Afaik NetworkManager is the only way to do the configuration automatically right now.

@yuwata
Copy link
Member

yuwata commented Aug 10, 2021

@zabbal Could you provide wwan.network you currently manually create? I'd like to know what kind of information should be obtained from ModemManager.

@zabbal
Copy link
Author

zabbal commented Aug 11, 2021

@yuwata the basic one as outlined in mmcli -b 3 output above - something like:

[Match]
Name=wwan0

[Network]
Description=APN is test-internet.myapn
Address=10.10.42.234/30
Gateway=10.10.42.24
DNS=8.8.8.8,8.8.4.4

[Link]
RequiredForOnline=no

See https://www.freedesktop.org/software/ModemManager/man/latest/mmcli.1.html for more details.

@yuwata
Copy link
Member

yuwata commented Aug 16, 2021

I am not familiar with WWAN devices and ModemManager. But IIUC, ModemManager only retrieves address, gateway, DNS, and etc., provided by an internet provider, but not assign them. And the information is exposed through DBus. Is it true?

I guess wwan0 or so is created dynamically when connection is established. If that is true, then I think it is better to introduce new condition APN= in [Match] section. WDYT?

@benibr
Copy link

benibr commented Aug 17, 2021

I am not familiar with WWAN devices and ModemManager. But IIUC, ModemManager only retrieves address, gateway, DNS, and etc., provided by an internet provider, but not assign them. And the information is exposed through DBus. Is it true?

Yes. That's correct.

I guess wwan0 or so is created dynamically when connection is established.

Yes.

If that is true, then I think it is better to introduce new condition APN= in [Match] section. WDYT?

Good idea. Would be a nice to have match criteria for setups with multiple wwan connections.
Nevertheless the biggest advantage would be if systemd-networkd would be able to receive the ip parameters via dbus and apply them on the interface.

@yuwata
Copy link
Member

yuwata commented Aug 17, 2021

@benibr Thanks.

@zabbal
Copy link
Author

zabbal commented Aug 17, 2021

ModemManager only retrieves address, gateway, DNS, and etc., provided by an internet provider, but not assign them.

Yes, exactly - the NetworkManager does that.

And the information is exposed through DBus. Is it true?

Precisely - that's what mmcli tool does.

Would be great to be able to replace NetworkManager with systemd-networkd.

The tricky thing which I don't understand yet is how to find the proper moment to assign the address etc - perhaps there's dbus signal from ModemManager which we could listen to?

@benibr
Copy link

benibr commented Aug 17, 2021

@zabbal I look around a bit with d-feet and dbus-monitor. I guess it would make sense to wait until ModemManager announces a Bearer then wait for a PropertyChanged with the bool Connected=True.
Sadly it looks like the the APN must be fetched seperatly, it's not in the connected message. But the IP config is

Example from dbus-monitor:

signal time=1629208586.362815 sender=:1.9 -> destination=(null destination) serial=406 path=/org/freedesktop/ModemManager1/Bearer/0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.freedesktop.ModemManager1.Bearer"
   array [
      dict entry(
         string "Stats"
         variant             array [
               dict entry(
                  string "duration"
                  variant                      uint32 0
               )
               dict entry(
                  string "rx-bytes"
                  variant                      uint64 0
               )
               dict entry(
                  string "tx-bytes"
                  variant                      uint64 0
               )
            ]
      )
      dict entry(
         string "Ip4Config"
         variant             array [
               dict entry(
                  string "method"
                  variant                      uint32 2
               )
               dict entry(
                  string "address"
                  variant                      string "10.117.110.168"
               )
               dict entry(
                  string "prefix"
                  variant                      uint32 16
               )
               dict entry(
                  string "dns1"
                  variant                      string "62.109.121.17"
               )
               dict entry(
                  string "dns2"
                  variant                      string "62.109.121.18"
               )
               dict entry(
                  string "dns3"
                  variant                      string "62.109.121.17"
               )
               dict entry(
                  string "gateway"
                  variant                      string "10.117.110.1"
               )
            ]
      )
      dict entry(
         string "Interface"
         variant             string "wwan0"
      )
      dict entry(
         string "Connected"
         variant             boolean true
      )
   ]

@zabbal
Copy link
Author

zabbal commented Aug 17, 2021

There's 1:1 correspondense between "Bearer" and "APN" in ModemManager. So we can always take bearer number N from that signal and make dbus call equivalent to mmcli -b N to fetch an APN.

Although it's more of a nice-to-have feature - most users won't use several modems with different APN in parallel.

@yuwata
Copy link
Member

yuwata commented Jan 28, 2022

@yuwata
Copy link
Member

yuwata commented Jan 28, 2022

So, let me confirm. How about the following way?

  1. When networkd detects wwanX, then call ListBearers() method, and get the Interface property for each bearer, and find corresponding bearer.
  2. Get "ip-type" field in the Properties property to determine IP addressing type.
  3. Get Ip4Config or/and Ip6Config properties and assign the provided static address or starts DHCP client.

Note, still e.g. mmcli --simple-connect="apn=test-internet.myapn" -m 5 needs to be called by user.

@yuwata
Copy link
Member

yuwata commented Jan 28, 2022

BTW, @zabbal and/or @benibr, could you provide the result of udevadm info /sys/class/net/wwanX? I'd like to know how to determine the interface is a WWAN interface, as the interface name may be changed arbitrary. I guess, DEVTYPE or DRIVER field can be used. But not sure.

@dwrz
Copy link

dwrz commented Jan 28, 2022

Hello @yuwata - I really appreciate your time on this. Here's the output from one machine:

udevadm info /sys/class/net/wwp0s20f0u3i12
P: /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.12/net/wwp0s20f0u3i12
L: 0
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.12/net/wwp0s20f0u3i12
E: DEVTYPE=wwan
E: INTERFACE=wwp0s20f0u3i12
E: IFINDEX=8
E: SUBSYSTEM=net
E: USEC_INITIALIZED=250009396017
E: ID_NET_NAMING_SCHEME=v250
E: ID_NET_NAME_PATH=wwp0s20f0u3i12
E: ID_VENDOR=Sierra_Wireless__Incorporated
E: ID_VENDOR_ENC=Sierra\x20Wireless\x2c\x20Incorporated
E: ID_VENDOR_ID=1199
E: ID_MODEL=Sierra_Wireless_EM7455_Qualcomm_Snapdragon_X7_LTE-A
E: ID_MODEL_ENC=Sierra\x20Wireless\x20EM7455\x20Qualcomm\x20Snapdragon\x20X7\x20LTE-A
E: ID_MODEL_ID=9079
E: ID_REVISION=0006
E: ID_SERIAL=Sierra_Wireless__Incorporated_Sierra_Wireless_EM7455_Qualcomm_Snapdragon_X7_LTE-A_LF81510625021022
E: ID_SERIAL_SHORT=LF81510625021022
E: ID_TYPE=generic
E: ID_BUS=usb
E: ID_USB_INTERFACES=:020e00:0a0002:
E: ID_USB_INTERFACE_NUM=0c
E: ID_USB_DRIVER=cdc_mbim
E: ID_VENDOR_FROM_DATABASE=Sierra Wireless, Inc.
E: ID_MODEL_FROM_DATABASE=EM7455
E: ID_MM_CANDIDATE=1
E: ID_PATH=pci-0000:00:14.0-usb-0:3:1.12
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_3_1_12
E: ID_NET_DRIVER=cdc_mbim
E: ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link
E: ID_NET_NAME=wwp0s20f0u3i12
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/wwp0s20f0u3i12
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:

@dwrz-dbhg
Copy link

And from my work laptop:

udevadm info /sys/class/net/wwan0
P: /devices/pci0000:00/0000:00:1c.0/0000:08:00.0/mhi0/wwan/wwan0/net/wwan0
L: 0
E: DEVPATH=/devices/pci0000:00/0000:00:1c.0/0000:08:00.0/mhi0/wwan/wwan0/net/wwan0
E: DEVTYPE=wwan
E: INTERFACE=wwan0
E: IFINDEX=4
E: SUBSYSTEM=net
E: USEC_INITIALIZED=13764867
E: ID_BUS=pci
E: ID_VENDOR_ID=0x105b
E: ID_MODEL_ID=0xe0ab
E: ID_PCI_CLASS_FROM_DATABASE=Wireless controller
E: ID_VENDOR_FROM_DATABASE=Foxconn International, Inc.
E: ID_MM_CANDIDATE=1
E: ID_PATH=pci-0000:08:00.0
E: ID_PATH_TAG=pci-0000_08_00_0
E: ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link
E: ID_NET_NAME=wwan0
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/wwan0
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:

@yuwata
Copy link
Member

yuwata commented Jan 29, 2022

@dwrz and @dwrz-dbhg Thank you!

@yuwata
Copy link
Member

yuwata commented Jan 29, 2022

@zabbal, @benibr, @dwrz and @dwrz-dbhg, could you also show the result of busctl tree org.freedesktop.ModemManager1?

@dwrz-dbhg
Copy link

└─/org
  └─/org/freedesktop
    └─/org/freedesktop/ModemManager1
      ├─/org/freedesktop/ModemManager1/Modem
      │ └─/org/freedesktop/ModemManager1/Modem/9
      └─/org/freedesktop/ModemManager1/SIM
        ├─/org/freedesktop/ModemManager1/SIM/18
        └─/org/freedesktop/ModemManager1/SIM/19

🙏🏽

@dwrz
Copy link

dwrz commented Jan 29, 2022

└─/org
  └─/org/freedesktop
    └─/org/freedesktop/ModemManager1
      ├─/org/freedesktop/ModemManager1/Modem
      │ └─/org/freedesktop/ModemManager1/Modem/3
      └─/org/freedesktop/ModemManager1/SIM
        └─/org/freedesktop/ModemManager1/SIM/3

🙏🏽🙏🏽🙏🏽

@yuwata
Copy link
Member

yuwata commented Jan 29, 2022

Thank you!

yuwata added a commit to yuwata/systemd that referenced this issue Jan 31, 2022
@yuwata yuwata linked a pull request Jan 31, 2022 that will close this issue
@yuwata
Copy link
Member

yuwata commented Jan 31, 2022

Hi all! Could you test PR #22315?

yuwata added a commit to yuwata/systemd that referenced this issue Jan 31, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Jan 31, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Jan 31, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Jan 31, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Jan 31, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Jan 31, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Feb 1, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Feb 1, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Feb 24, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Mar 4, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Mar 12, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Mar 12, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Mar 22, 2022
yuwata added a commit to yuwata/systemd that referenced this issue Mar 22, 2022
@WhyNotHugo
Copy link
Contributor

Minor correction on what was discussed here: wwan0 shows up as soon as I plug in the modem onto the host.

Trying to find a bearer when the interface shows up won't work because the bearer is created when modemmanager is instructed to connect. So the bearer can also exist a short while before the connection is established too.

@aleksander0m
Copy link

Minor correction on what was discussed here: wwan0 shows up as soon as I plug in the modem onto the host.

Trying to find a bearer when the interface shows up won't work because the bearer is created when modemmanager is instructed to connect. So the bearer can also exist a short while before the connection is established too.

Another note here. The data interface listed in the bearer object MAY be instantiated at runtime while the modem is connected and the bearer object created, so it may not even exist in the system if the modem is disconnected. We do this in ModemManager when multiplexing is enabled, as we can create N net interfaces multiplexed over a single wwan0 in order to connect to N different APNs.

@aleksander0m
Copy link

@yuwata do you want me to send you some WWAN devices to test with?

@yuwata
Copy link
Member

yuwata commented Apr 20, 2022

@aleksander0m Oh, thanks. Yes, please if possible. Currently, I have no modem to test this feature. That's why this is stopped to be updated.

@fabiobulgarella
Copy link

Hi all, thanks for the great work you are doing. Is there any news about this integration?

@yuwata
Copy link
Member

yuwata commented Nov 16, 2022

Sorry, not yet. But, I really want to implement that for next release (v253).

@killermoehre
Copy link
Contributor

@yuwata so, v253 just dropped, and I don't see this feature in the release notes. Is it postponed to v254?

@yuwata
Copy link
Member

yuwata commented Feb 18, 2023

@killermoehre Ah, yeah, unfortunately...

@abielan
Copy link

abielan commented May 22, 2023

I'm surprised by the lack of interest. It is very important issue.

@mdlayher
Copy link
Contributor

@yuwata, I would be happy to sponsor your work on this project.

Would you mind contacting me on Twitter (same username) or (username)@gmail.com? I am sure we can arrange a way to purchase some hardware for you!

@tswaehn
Copy link

tswaehn commented Jan 26, 2024

Just wondering, if there is additional information needed to bring up wwan (like PIN, APN, ... ) what is the expected place to store these in conjunction with this integration?

@aleksander0m
Copy link

I'm happy to help with this however needed. I also sent already a modem to play with to @yuwata some time ago, if anyone else needs one, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
network RFE 🎁 Request for Enhancement, i.e. a feature request
Development

Successfully merging a pull request may close this issue.