modemmanager: improve cleanup of ifaces

Change workflow to cleanup interfaces using the sysfscache.
The sysfscache stores the processed sysfs-paths. Using this
instead of mmcli -L, the interfaces can be properly cleaned
up even if, for example, ModemManager crashes and mmcli is
no longer usable.

Signed-off-by: Oliver Sedlbauer <osedlbauer@tdt.de>
This commit is contained in:
Oliver Sedlbauer 2023-10-17 17:13:37 +02:00
parent 91c2be764a
commit d78505bcfa
2 changed files with 12 additions and 16 deletions

View file

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=modemmanager PKG_NAME:=modemmanager
PKG_SOURCE_VERSION:=1.22.0 PKG_SOURCE_VERSION:=1.22.0
PKG_RELEASE:=3 PKG_RELEASE:=4
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/ModemManager.git PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/ModemManager.git

View file

@ -235,24 +235,20 @@ mm_report_modem_wait() {
# Cleanup interfaces # Cleanup interfaces
mm_cleanup_interfaces() { mm_cleanup_interfaces() {
local modemlist modemlength idx modeminfo modemsysfspath local sysfs_path status
modemlist=$(mmcli --list-modems --output-keyvalue) # Do nothing if there is no sysfs cache
[ -n "${modemlist}" ] || return 0 [ -f "${MODEMMANAGER_SYSFS_CACHE}" ] || return
modemlength=$(modemmanager_get_field "${modemlist}" "modem-list.length") while IFS= read -r sysfs_cache_line; do
sysfs_path=$(echo "${sysfs_cache_line}" | awk '{print $1}')
status=$(echo "${sysfs_cache_line}" | awk '{print $2}')
# do nothing if no modem reported if [ "${status}" = "processed" ]; then
[ -n "${modemlength}" ] && [ "${modemlength}" -ge 1 ] && { mm_log "debug" "call cleanup for: ${sysfs_path}"
idx=1 mm_cleanup_interface_by_sysfspath "${sysfs_path}"
while [ $idx -le "$modemlength" ]; do fi
modempath=$(modemmanager_get_field "${modemlist}" "modem-list.value\[$idx\]") done < ${MODEMMANAGER_SYSFS_CACHE}
modeminfo=$(mmcli --modem "${modempath}" --output-keyvalue)
modemsysfspath=$(modemmanager_get_field "${modeminfo}" "modem.generic.device")
mm_cleanup_interface_by_sysfspath "${modemsysfspath}"
idx=$((idx + 1))
done
}
} }
mm_cleanup_interface_by_sysfspath() { mm_cleanup_interface_by_sysfspath() {