]> git.99rst.org Git - openwrt-packages.git/commitdiff
modemmanager: skip live report when the service isn't up yet
authorMichael Pfeifroth <redacted>
Fri, 31 Jul 2026 12:05:38 +0000 (14:05 +0200)
committerFlorian Eckert <redacted>
Mon, 3 Aug 2026 11:03:31 +0000 (13:03 +0200)
At boot procd replays every previously-seen uevent before
/etc/init.d/modemmanager starts.  Each replay walks the hotplug.d/
tree, which calls mm_report_event() in modemmanager.common.  That
helper does two independent things:

  1) appends the event to ${MODEMMANAGER_EVENTS_CACHE}, and
  2) runs 'mmcli --report-kernel-event=...' to notify a live MM.

Step 1 is what matters for boot; step 2 exists so events fired
after MM is running get reported without waiting for the next
cache replay.  The cache path is intentional: ModemManager-wrapper
starts MM, then mm_report_events_from_cache() polls 'mmcli -L'
until the bus is available and replays every cached event.

At boot the modemmanager service instance hasn't been spawned by
procd yet, so step 2 always fails with:

  daemon.err ModemManager[NNN]: hotplug: Couldn't report kernel
    event: error: couldn't get bus: Could not connect: No such
    file or directory

That's one daemon.err line per hotplug script per port, per boot.
On a dual-modem board that's a dozen spurious errors before the
service even starts.  Nothing is lost -- the wrapper's cache
replay picks them all up seconds later -- but the log noise makes
real ModemManager errors harder to spot.

Guard the live call with a cheap pidfile-based liveness check.
The pidfile is procd's, so it proves the service instance has
been spawned, not that MM is already reachable on the bus; the
brief wrapper-startup window (procd spawns the wrapper -> wrapper
execs MM -> MM reaches the bus) is not covered.  In practice no
fresh uevents fire in that window on the boards this was tested
on, and events that do arrive there are still cached.  If the
service hasn't been spawned yet, the event is silently cached and
the wrapper handles it.  If it has, behavior is unchanged.

Signed-off-by: Michael Pfeifroth <redacted>
net/modemmanager/Makefile
net/modemmanager/files/usr/share/ModemManager/modemmanager.common

index 52f3b749ac8b38e6c3d57a1463fde8bb9a5e617e..f5f9bc0409aa02bd8d808f4f5038ceda8c7d2f41 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=modemmanager
 PKG_VERSION:=1.24.0
-PKG_RELEASE:=11
+PKG_RELEASE:=12
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/ModemManager.git
index bc35eaca97374d58ce25a4591bb007d74f300a71..2e07082dfefa7101a17eaaed13303669e7c1a170 100644 (file)
@@ -158,6 +158,12 @@ mm_report_event() {
                        ;;
        esac
 
+       # Skip live report if MM isn't up; wrapper will replay from cache.
+       if [ ! -s "${MODEMMANAGER_PID_FILE}" ] || \
+               ! kill -0 "$(cat "${MODEMMANAGER_PID_FILE}" 2>/dev/null)" 2>/dev/null; then
+               return
+       fi
+
        # Report the event
        mm_log "debug" "Report event: action=${action}, name=${name}, subsystem=${subsystem}"
        result=$(mmcli --report-kernel-event="action=${action},name=${name},subsystem=${subsystem}" 2>&1)
git clone https://git.99rst.org/PROJECT