Add ModemManager integration with networkd#38855
Conversation
6e7df9a to
1407daa
Compare
87df38b to
6eb41fd
Compare
4861500 to
16b9cb2
Compare
|
I have tested the PR over the weekend with 3 modems making random modem disconnects (with usbreset utility), ModemManager restarts and disconnects with |
83fedb5 to
8031c0c
Compare
I've just backported the current patchset to 257.8, and it indeed does now generate a new Bearer token. I do see the old bearer still listed via mmcli, does the current patchset disable/disconnect the stale bearer? Otherwise I'd argue it's better to delete it ;) |
|
@andr2000 Sorry for late re-review. I addressed the comments by @keszybz and pushed the revised version.
Let's address this after this merged. |
[Match] Name=wwan* [Network] LLDP=no LinkLocalAddressing=no IPv6AcceptRA=no [ModemManager] SimpleConnectPropertie]s=apn=internet ip-type=ipv4 allow-roaming=no pin=1111 operator-id=25503 RouteMetric=200 UseGateway=yes Co-authored-by: Yu Watanabe <[email protected]>
ModemManager (MM) integration consists of two big parts: things
we do on the networkd start and what we do during the run-time.
Initialization phase
2.1. Wait for networkd to connect to D-Bus
2.2. Setup D-Bus handlers for the essential signals:
to track modem plug/unplug
to track bearers
2.3. Check if MM service is yet available: for that call /org/freedesktop/DBus, org.freedesktop.DBus
ListNames method and see if MM is available. If it is not, then wait for the NameOwnerChanged
signal and see when it is; finish initialization phase.
2.4. If MM is available - enumerate modems, see p.4.
2.5. Finish initialization phase.
Run-time
3.1. During the run-time we track MM service avaialbility. When it is gone we remove all the modems
and bearers.
3.2. When MM is connected we do modem enumeration to get in sync with their current state.
3.3. If a modem was removed we also remove all its bearers.
3.4. If a modem was added we try to start a simple connect.
3.5. If connection was interrupted, e.g. modem changed its network connection from connected state
we start an automatic reconnect.
Modem enumeration proces
4.1. Modem enumeration is done by calling GetManagedObjects.
4.2. By receiving managed objects we try to instantiate all new modems found.
4.3. For that we inspect all bearers available for that modem and add all new bearers found.
4.4. We also read modem ports to detect WWAN interface name assigned to this modem, e.g. "wwan0" etc.
N.B. As we only get the interface name known that late and the corresponding .network file was
already used by the networkd to match interfaces etc. it is not possible
to do things like matching APN to .network and so on.
Simple (re)connect
5.1. Connection is done by calling org.freedesktop.ModemManager1.Modem.Simple Connect method for
the relevant modem.
5.2. It is possible that at the time of connect the operation may fail. For that reason and to ensure
we are always connected we employ a periodic timer which will re-try connection hoping it will
be successful this time or when modem has recovered after an error state and so on.
5.3. networkd will automatically start reconnection if any external entity disconnects modem from
the network.
Open questions
6.1. WWAN interfaces cannot be configured now with the existing .network file:
this under [Network] section for now. Is there a better name for that and location?
do not use any section of .network to define/alter relevant parts. This patch uses
[DHCP]:RouteMetric for that for now.
I use [DHCPv4]:UseGateway now which probably needs a better way of defining.
6.2. Use MM header files - add MM as a build dependency?