ims-pdn-up: do not connect a bearer while the modem is disabled

With the modem's radio off (airplane mode) the bring-up waited five
minutes for registration and then tried to connect the ims bearer
anyway. That attempt fails with no-service and leaves ModemManager's
modem state `enabled` while the modem stays in low power; switching the
radio back on then no longer brings the modem up, and the phone has no
mobile service until the modem is disabled and enabled again (dev phone
2026-10-06: not registered 150 s after the radio came on, against 5 s
without the attempt).

0.3.9's bring-up made the same attempts, but it only ran at boot or at
a manual restart. Since this series a registered imsd exits when its
address leaves the netdev and systemd runs the bring-up again, and an
upgrade restarts it: the bring-up now also runs during a radio-off
period.

A modem still disabled after the registration wait, or disabled when a
connect attempt is due, now makes the script exit non-zero without
touching the modem; systemd retries after RestartSec.

Tested on the dev phone (KPN) with this script: a registered imsd, the
radio switched off — imsd exited at its next refresh, the bring-up gave
up after the wait with the modem still disabled, and when the radio came
back the modem registered in 5 s and imsd registered by itself two
minutes later; the same with an upgrade's restart during the radio-off
period. The twelve mock scenarios of the bring-up are unchanged.
This commit is contained in:
Jorijn van der Graaf 2026-10-06 17:54:09 +02:00
commit 7d38846bb6
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
2 changed files with 20 additions and 0 deletions

View file

@ -436,6 +436,15 @@ configures the muxed netdev. Idempotent; a non-zero exit fails the unit.
- Waits up to 120 s for a modem, then gates the connect attempts on network
registration (`IMS_REG_TIMEOUT`, default 300 s): some carriers attach ~2 min
after boot.
- Never creates or connects a bearer while the modem is `disabled` — its
radio is off (airplane mode): a modem still disabled after the wait, or
disabled when an attempt is due, makes the script exit non-zero (`modem …
disabled … (radio off): not connecting`) and systemd retries. A bearer
connect on a disabled modem fails with `no-service` and leaves
ModemManager's state `enabled` with the modem in low power; switching the
radio back on then no longer brings it up (dev phone 2026-10-06: not
registered after 150 s, against 5 s without the attempt; a ModemManager
disable/enable recovered it).
- Connects by **3GPP profile index** (`IMS_PROFILE_ID`, default: looked up by
APN in `qmicli --wds-get-profile-list=3gpp`), not by APN string: a
profile-indexed request is exempt from the modem's attach-family forcing