Files
ModemManager/data/ModemManager.service.in
Semyon Maryasin 225e66fea9 service: don't SIGTERM the QMI/MBIM proxies together with the daemon
The qmi-proxy/mbim-proxy processes spawned by the daemon live in the
service's cgroup, so with the default KillMode=control-group systemd
sends SIGTERM to them at the same time as to the daemon on every unit
stop. The proxy exits immediately, tearing the control channel from
under the daemon while it is still disabling the modems:

    <msg> caught signal, shutting down...
    <msg> [modem0] state changed (connected -> disabling)
    <msg> [modem0] port 'cdc-wdm0' no longer controllable, reprobing
    <wrn> [/dev/cdc-wdm0] MBIM error: Device must be open to send commands
    <wrn> shutdown failed: timeout waiting for sleep preparation to complete

The consequences of losing the proxy mid-shutdown:
 - the modem disable/disconnect never reaches the device, so an MBIM
   session with an active bearer is left open in the firmware (observed
   to occasionally wedge the MBIM function of a Sierra EM7565 until a
   firmware reset);
 - the port teardown stalls waiting on the dead proxy until the
   shutdown timeout, so stopping the unit always takes the full
   MAX_SHUTDOWN_TIME_SECS instead of a second or two;
 - the port invalidation triggers the device reprobe path in the middle
   of the shutdown.

With KillMode=mixed only the daemon receives SIGTERM; the proxies
survive long enough for a clean disconnect and MBIM/QMI close, and
whatever remains in the cgroup afterwards (an idle, stateless proxy) is
killed when the unit finally stops.

Signed-off-by: Semyon Maryasin <simeon@maryasin.name>
2026-09-22 12:31:25 -05:00

25 lines
540 B
Plaintext

[Unit]
Description=Modem Manager
After=@MM_POLKIT_SERVICE@
Requires=@MM_POLKIT_SERVICE@
ConditionVirtualization=!container
[Service]
Type=dbus
BusName=org.freedesktop.ModemManager1
ExecStart=@sbindir@/ModemManager
StandardError=null
Restart=on-abort
KillMode=mixed
CapabilityBoundingSet=CAP_SYS_ADMIN CAP_NET_ADMIN
ProtectSystem=true
ProtectHome=true
PrivateTmp=true
RestrictAddressFamilies=AF_NETLINK AF_UNIX AF_QIPCRTR
NoNewPrivileges=true
User=root
[Install]
WantedBy=multi-user.target
Alias=dbus-org.freedesktop.ModemManager1.service