radio/rfkill state (WwanEnabled) out of sync with ModemManager daemon state if modem disconnect fails
We're using NetworkManager (v1.24.2) which is controlling ModemManager via D-Bus. When we disable the modem via 'nmcli radio wwan off' it can happen the Modem fails to disconnect because it is already disconnecting (e.g. due to temporary network/modem problems).
In such a case the whole operation partly fails and the out of sync condition occurs.
The kernel rfkill state is disabled and NetworkManager.state reflects WWANEnabled=false (see manager_radio_user_toggled). But since ModemManager fails to disconnect, no subsequent action is done (so no modem power-off, see modem_disable_ready) and soon NM will take over the MM modem state (which isn't disabled)
Any subsequent 'nmcli radio wwan ...' command fails because of the out of sync condition.
The latest NetworkManager code seems to have this problem as well.
Here are some relevant system log entries:
Aug 24 06:55:27 system-0123456789 daemon.warn NetworkManager[1459]: <warn> [1629788127.2734] modem-broadband[ttyACM1]: failed to disable modem: GDBus.Error:org.freedesktop.ModemManager1.Error.Core.InProgress: Bearer already being disconnected
Aug 24 06:55:27 system-0123456789 daemon.info NetworkManager[1459]: <info> [1629788127.3298] modem["ttyACM1"]: modem state changed, 'disabling' --> 'connected' (reason: unknown)
I guess either the rfkill and WWANEnabled state should be reverted or written as soon as modem disabling succeeded. I think the other option (continue anyway and power off the modem) may fail if modem isn't in disabled state.