Merge pull request #19648 from nemesisdesign/openwrt-21.02

[21.02] Backport fixes for modem-manager and its dependencies
This commit is contained in:
Josef Schlehofer 2022-11-16 21:48:31 +01:00 committed by GitHub
commit ecedd96fbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 137 additions and 43 deletions

View File

@ -8,14 +8,14 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=libmbim PKG_NAME:=libmbim
PKG_VERSION:=1.24.8 PKG_VERSION:=1.26.2
PKG_RELEASE:=1 PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://www.freedesktop.org/software/libmbim PKG_SOURCE_URL:=https://www.freedesktop.org/software/libmbim
PKG_HASH:=02590736163fff10e5732191fccc1b9920969616ddc59613a003052a116a3c25 PKG_HASH:=10c77bf5b5eb8c92ba80e9b519923ad9b898362bc8e1928e2bc9a17eeba649af
PKG_MAINTAINER:=Nicholas Smith <nicholas.smith@telcoantennas.com.au> PKG_MAINTAINER:=Nicholas Smith <nicholas@nbembedded.com>
PKG_INSTALL:=1 PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1 PKG_BUILD_PARALLEL:=1
@ -28,8 +28,7 @@ CONFIGURE_ARGS += \
--disable-gtk-doc \ --disable-gtk-doc \
--disable-gtk-doc-html \ --disable-gtk-doc-html \
--disable-gtk-doc-pdf \ --disable-gtk-doc-pdf \
--disable-silent-rules \ --disable-silent-rules
--enable-more-warnings=yes
define Package/libmbim define Package/libmbim
SECTION:=libs SECTION:=libs
@ -57,7 +56,6 @@ define Package/mbim-utils
endef endef
CONFIGURE_ARGS += \ CONFIGURE_ARGS += \
--without-udev \
--without-udev-base-dir --without-udev-base-dir
define Build/InstallDev define Build/InstallDev

View File

@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=libqmi PKG_NAME:=libqmi
PKG_VERSION:=1.28.8 PKG_VERSION:=1.30.8
PKG_RELEASE:=1 PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://www.freedesktop.org/software/libqmi PKG_SOURCE_URL:=https://www.freedesktop.org/software/libqmi
PKG_HASH:=6e3bbbd200bc1b64b23f6254fef9212f2699ec77cfb32075d2ba5079c73a9f78 PKG_HASH:=862482ce9e3ad0bd65d264334ee311cdb94b9df2863b5b7136309b41b8ac1990
PKG_MAINTAINER:=Nicholas Smith <nicholas@nbembedded.com> PKG_MAINTAINER:=Nicholas Smith <nicholas@nbembedded.com>
@ -66,7 +66,6 @@ CONFIGURE_ARGS += \
--disable-gtk-doc-pdf \ --disable-gtk-doc-pdf \
--disable-silent-rules \ --disable-silent-rules \
--enable-firmware-update \ --enable-firmware-update \
--enable-more-warnings=yes \
--without-udev \ --without-udev \
--without-udev-base-dir --without-udev-base-dir

View File

@ -8,15 +8,15 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=modemmanager PKG_NAME:=modemmanager
PKG_VERSION:=1.16.6 PKG_VERSION:=1.18.12
PKG_RELEASE:=1 PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE:=ModemManager-$(PKG_VERSION).tar.xz PKG_SOURCE:=ModemManager-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://www.freedesktop.org/software/ModemManager PKG_SOURCE_URL:=https://www.freedesktop.org/software/ModemManager
PKG_HASH:=2a90b6260f66d3135609d62667ada73416694d717e7fd9b73223e3703a499617 PKG_HASH:=b464e4925d955a6ca86dd08616e763b26ae46d7fd37dbe281678e34065b1e430
PKG_BUILD_DIR:=$(BUILD_DIR)/ModemManager-$(PKG_VERSION) PKG_BUILD_DIR:=$(BUILD_DIR)/ModemManager-$(PKG_VERSION)
PKG_MAINTAINER:=Nicholas Smith <nicholas.smith@telcoantennas.com.au> PKG_MAINTAINER:=Nicholas Smith <nicholas@nbembedded.com>
PKG_LICENSE:=GPL-2.0-or-later PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=COPYING PKG_LICENSE_FILES:=COPYING
@ -98,6 +98,7 @@ define Package/modemmanager/install
$(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ModemManager $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ModemManager $(1)/usr/sbin
$(INSTALL_BIN) ./files/usr/sbin/ModemManager-wrapper $(1)/usr/sbin
$(INSTALL_DIR) $(1)/usr/bin $(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mmcli $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mmcli $(1)/usr/bin
@ -109,6 +110,9 @@ define Package/modemmanager/install
$(CP) $(PKG_INSTALL_DIR)/usr/lib/ModemManager/libmm-shared-*.so* $(1)/usr/lib/ModemManager $(CP) $(PKG_INSTALL_DIR)/usr/lib/ModemManager/libmm-shared-*.so* $(1)/usr/lib/ModemManager
$(CP) $(PKG_INSTALL_DIR)/usr/lib/ModemManager/libmm-plugin-*.so* $(1)/usr/lib/ModemManager $(CP) $(PKG_INSTALL_DIR)/usr/lib/ModemManager/libmm-plugin-*.so* $(1)/usr/lib/ModemManager
$(INSTALL_DIR) $(1)/usr/lib/ModemManager/connection.d
$(INSTALL_BIN) ./files/10-report-down $(1)/usr/lib/ModemManager/connection.d
$(INSTALL_DIR) $(1)/etc/dbus-1/system.d $(INSTALL_DIR) $(1)/etc/dbus-1/system.d
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/dbus-1/system.d/org.freedesktop.ModemManager1.conf $(1)/etc/dbus-1/system.d $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/dbus-1/system.d/org.freedesktop.ModemManager1.conf $(1)/etc/dbus-1/system.d
@ -119,6 +123,9 @@ define Package/modemmanager/install
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/ModemManager/*.conf $(1)/usr/share/ModemManager $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/ModemManager/*.conf $(1)/usr/share/ModemManager
$(INSTALL_DATA) ./files/modemmanager.common $(1)/usr/share/ModemManager $(INSTALL_DATA) ./files/modemmanager.common $(1)/usr/share/ModemManager
$(INSTALL_DIR) $(1)/usr/share/ModemManager/fcc-unlock.available.d
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/ModemManager/fcc-unlock.available.d/* $(1)/usr/share/ModemManager/fcc-unlock.available.d
$(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/modemmanager.init $(1)/etc/init.d/modemmanager $(INSTALL_BIN) ./files/modemmanager.init $(1)/etc/init.d/modemmanager
@ -131,6 +138,9 @@ define Package/modemmanager/install
$(INSTALL_DIR) $(1)/etc/hotplug.d/tty $(INSTALL_DIR) $(1)/etc/hotplug.d/tty
$(INSTALL_DATA) ./files/25-modemmanager-tty $(1)/etc/hotplug.d/tty $(INSTALL_DATA) ./files/25-modemmanager-tty $(1)/etc/hotplug.d/tty
$(INSTALL_DIR) $(1)/etc/hotplug.d/wwan
$(INSTALL_DATA) ./files/25-modemmanager-wwan $(1)/etc/hotplug.d/wwan
$(INSTALL_DIR) $(1)/lib/netifd/proto $(INSTALL_DIR) $(1)/lib/netifd/proto
$(INSTALL_BIN) ./files/modemmanager.proto $(1)/lib/netifd/proto/modemmanager.sh $(INSTALL_BIN) ./files/modemmanager.proto $(1)/lib/netifd/proto/modemmanager.sh
endef endef

View File

@ -0,0 +1,35 @@
#!/bin/sh
# SPDX-License-Identifier: CC0-1.0
# 2022 Aleksander Morgado <aleksander@aleksander.es>
#
# Automatically report to netifd that the underlying modem
# is really disconnected
#
# require program name and at least 4 arguments
[ $# -lt 4 ] && exit 1
MODEM_PATH="$1"
BEARER_PATH="$2"
INTERFACE="$3"
STATE="$4"
[ "${STATE}" = "disconnected" ] || exit 0
. /usr/share/ModemManager/modemmanager.common
. /lib/netifd/netifd-proto.sh
INCLUDE_ONLY=1 . /lib/netifd/proto/modemmanager.sh
MODEM_STATUS=$(mmcli --modem="${MODEM_PATH}" --output-keyvalue)
[ -n "${MODEM_STATUS}" ] || exit 1
MODEM_DEVICE=$(modemmanager_get_field "${MODEM_STATUS}" "modem.generic.device")
[ -n "${MODEM_DEVICE}" ] || exit 2
CFG=$(mm_get_modem_config "${MODEM_DEVICE}")
[ -n "${CFG}" ] || exit 3
logger -t "modemmanager" "interface ${CFG} (network device ${INTERFACE}) ${STATE}"
proto_init_update $INTERFACE 0
proto_send_update $CFG
exit 0

View File

@ -12,7 +12,7 @@
mkdir -m 0755 -p "${MODEMMANAGER_RUNDIR}" mkdir -m 0755 -p "${MODEMMANAGER_RUNDIR}"
# Report network interface # Report network interface
mm_log "${ACTION} network interface ${INTERFACE}: event processed" mm_log "info" "${ACTION} network interface ${INTERFACE}: event processed"
mm_report_event "${ACTION}" "${INTERFACE}" "net" "/sys${DEVPATH}" mm_report_event "${ACTION}" "${INTERFACE}" "net" "/sys${DEVPATH}"
# Look for an associated cdc-wdm interface # Look for an associated cdc-wdm interface
@ -26,6 +26,6 @@ esac
# Report cdc-wdm device, if any # Report cdc-wdm device, if any
[ -n "${cdcwdm}" ] && { [ -n "${cdcwdm}" ] && {
mm_log "${ACTION} cdc interface ${cdcwdm}: custom event processed" mm_log "info" "${ACTION} cdc interface ${cdcwdm}: custom event processed"
mm_report_event "${ACTION}" "${cdcwdm}" "usbmisc" "/sys${DEVPATH}" mm_report_event "${ACTION}" "${cdcwdm}" "usbmisc" "/sys${DEVPATH}"
} }

View File

@ -12,5 +12,5 @@
mkdir -m 0755 -p "${MODEMMANAGER_RUNDIR}" mkdir -m 0755 -p "${MODEMMANAGER_RUNDIR}"
# Report TTY # Report TTY
mm_log "${ACTION} serial interface ${DEVNAME}: event processed" mm_log "info" "${ACTION} serial interface ${DEVNAME}: event processed"
mm_report_event "${ACTION}" "${DEVNAME}" "tty" "/sys${DEVPATH}" mm_report_event "${ACTION}" "${DEVNAME}" "tty" "/sys${DEVPATH}"

View File

@ -0,0 +1,15 @@
#!/bin/sh
# Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
# Load hotplug common utilities
. /usr/share/ModemManager/modemmanager.common
# We require a device name
[ -n "$DEVNAME" ] || exit
# Always make sure the rundir exists
mkdir -m 0755 -p "${MODEMMANAGER_RUNDIR}"
# Report wwan
mm_log "info" "${ACTION} wwan control port ${DEVNAME}: event processed"
mm_report_event "${ACTION}" "${DEVNAME}" "wwan" "/sys${DEVPATH}"

View File

@ -20,7 +20,8 @@ MODEMMANAGER_EVENTS_CACHE="${MODEMMANAGER_RUNDIR}/events.cache"
# Common logging # Common logging
mm_log() { mm_log() {
logger -t "ModemManager" "hotplug: $*" local level="$1"; shift
logger -p "daemon.${level}" -t "ModemManager[$$]" "hotplug: $*"
} }
################################################################################ ################################################################################
@ -160,7 +161,7 @@ mm_wait_for_modem() {
while [ $n -ge 0 ]; do while [ $n -ge 0 ]; do
[ -d "${sysfspath}" ] || { [ -d "${sysfspath}" ] || {
mm_log "error: ignoring modem detection request: no device at ${sysfspath}" mm_log "error" "ignoring modem detection request: no device at ${sysfspath}"
proto_set_available "${cfg}" 0 proto_set_available "${cfg}" 0
return 1 return 1
} }
@ -168,10 +169,10 @@ mm_wait_for_modem() {
# Check if the modem exists at the given sysfs path # Check if the modem exists at the given sysfs path
if ! mmcli -m "${sysfspath}" > /dev/null 2>&1 if ! mmcli -m "${sysfspath}" > /dev/null 2>&1
then then
mm_log "error: modem not detected at sysfs path" mm_log "error" "modem not detected at sysfs path"
else else
mm_log "modem exported successfully at ${sysfspath}" mm_log "info" "modem exported successfully at ${sysfspath}"
mm_log "setting interface '${cfg}' as available" mm_log "info" "setting interface '${cfg}' as available"
proto_set_available "${cfg}" 1 proto_set_available "${cfg}" 1
return 0 return 0
fi fi
@ -180,7 +181,7 @@ mm_wait_for_modem() {
n=$((n-step)) n=$((n-step))
done done
mm_log "error: timed out waiting for the modem to get exported at ${sysfspath}" mm_log "error" "timed out waiting for the modem to get exported at ${sysfspath}"
proto_set_available "${cfg}" 0 proto_set_available "${cfg}" 0
return 2 return 2
} }
@ -192,7 +193,7 @@ mm_report_modem_wait() {
parent_sysfspath=$(mm_find_physdev_sysfs_path "$sysfspath") parent_sysfspath=$(mm_find_physdev_sysfs_path "$sysfspath")
[ -n "${parent_sysfspath}" ] || { [ -n "${parent_sysfspath}" ] || {
mm_log "error: parent device sysfspath not found" mm_log "error" "parent device sysfspath not found"
return return
} }
@ -203,23 +204,23 @@ mm_report_modem_wait() {
cfg=$(mm_get_modem_config "${parent_sysfspath}") cfg=$(mm_get_modem_config "${parent_sysfspath}")
if [ -n "${cfg}" ]; then if [ -n "${cfg}" ]; then
mm_log "interface '${cfg}' is set to configure device '${parent_sysfspath}'" mm_log "info" "interface '${cfg}' is set to configure device '${parent_sysfspath}'"
mm_log "now waiting for modem at sysfs path ${parent_sysfspath}" mm_log "info" "now waiting for modem at sysfs path ${parent_sysfspath}"
mm_set_modem_wait_status "${parent_sysfspath}" "processed" mm_set_modem_wait_status "${parent_sysfspath}" "processed"
# Launch subshell for the explicit wait # Launch subshell for the explicit wait
( mm_wait_for_modem "${cfg}" "${parent_sysfspath}" ) > /dev/null 2>&1 & ( mm_wait_for_modem "${cfg}" "${parent_sysfspath}" ) > /dev/null 2>&1 &
else else
mm_log "no need to wait for modem at sysfs path ${parent_sysfspath}" mm_log "info" "no need to wait for modem at sysfs path ${parent_sysfspath}"
mm_set_modem_wait_status "${parent_sysfspath}" "ignored" mm_set_modem_wait_status "${parent_sysfspath}" "ignored"
fi fi
;; ;;
"processed") "processed")
mm_log "already waiting for modem at sysfs path ${parent_sysfspath}" mm_log "info" "already waiting for modem at sysfs path ${parent_sysfspath}"
;; ;;
"ignored") "ignored")
;; ;;
*) *)
mm_log "error: unknown status read for device at sysfs path ${parent_sysfspath}" mm_log "error" "unknown status read for device at sysfs path ${parent_sysfspath}"
;; ;;
esac esac
} }
@ -249,7 +250,7 @@ mm_cleanup_interface_by_sysfspath() {
cfg=$(mm_get_modem_config "$dev") cfg=$(mm_get_modem_config "$dev")
[ -n "${cfg}" ] || return [ -n "${cfg}" ] || return
mm_log "setting interface '$cfg' as unavailable" mm_log "info" "setting interface '$cfg' as unavailable"
proto_set_available "${cfg}" 0 proto_set_available "${cfg}" 0
} }
@ -277,7 +278,7 @@ mm_report_event() {
esac esac
# Report the event # Report the event
mm_log "event reported: action=${action}, name=${name}, subsystem=${subsystem}" mm_log "debug" "event reported: action=${action}, name=${name}, subsystem=${subsystem}"
mmcli --report-kernel-event="action=${action},name=${name},subsystem=${subsystem}" 1>/dev/null 2>&1 & mmcli --report-kernel-event="action=${action},name=${name},subsystem=${subsystem}" 1>/dev/null 2>&1 &
# Wait for added modem if a sysfspath is given # Wait for added modem if a sysfspath is given
@ -293,7 +294,7 @@ mm_report_event_from_cache_line() {
subsystem=$(echo "${event_line}" | awk -F ',' '{ print $3 }') subsystem=$(echo "${event_line}" | awk -F ',' '{ print $3 }')
sysfspath=$(echo "${event_line}" | awk -F ',' '{ print $4 }') sysfspath=$(echo "${event_line}" | awk -F ',' '{ print $4 }')
mm_log "cached event found: action=${action}, name=${name}, subsystem=${subsystem}, sysfspath=${sysfspath}" mm_log "debug" "cached event found: action=${action}, name=${name}, subsystem=${subsystem}, sysfspath=${sysfspath}"
mm_report_event "${action}" "${name}" "${subsystem}" "${sysfspath}" mm_report_event "${action}" "${name}" "${subsystem}" "${sysfspath}"
} }
@ -308,11 +309,11 @@ mm_report_events_from_cache() {
# Wait for ModemManager to be available in the bus # Wait for ModemManager to be available in the bus
while [ $n -ge 0 ]; do while [ $n -ge 0 ]; do
sleep $step sleep $step
mm_log "checking if ModemManager is available..." mm_log "info" "checking if ModemManager is available..."
if ! mmcli -L >/dev/null 2>&1 if ! mmcli -L >/dev/null 2>&1
then then
mm_log "ModemManager not yet available" mm_log "info" "ModemManager not yet available"
else else
mmrunning=1 mmrunning=1
break break
@ -321,7 +322,7 @@ mm_report_events_from_cache() {
done done
[ ${mmrunning} -eq 1 ] || { [ ${mmrunning} -eq 1 ] || {
mm_log "error: couldn't report initial kernel events: ModemManager not running" mm_log "error" "couldn't report initial kernel events: ModemManager not running"
return return
} }

View File

@ -4,6 +4,8 @@
USE_PROCD=1 USE_PROCD=1
START=70 START=70
LOG_LEVEL="INFO"
stop_service() { stop_service() {
# Load common utils # Load common utils
. /usr/share/ModemManager/modemmanager.common . /usr/share/ModemManager/modemmanager.common
@ -22,14 +24,14 @@ start_service() {
# it starts. # it starts.
# #
# All these commands need to be executed on every MM start, even after # All these commands need to be executed on every MM start, even after
# procd-triggered respawns, which is why they're all included as instance command # procd-triggered respawns, which is why this is wrapped in a startup
# wrapper script called '/usr/sbin/ModemManager-wrapper'.
# #
. /usr/share/ModemManager/modemmanager.common
procd_open_instance procd_open_instance
procd_set_param command sh -c ". /usr/share/ModemManager/modemmanager.common; \ procd_set_param command /usr/sbin/ModemManager-wrapper
mkdir -m 0755 -p ${MODEMMANAGER_RUNDIR}; \ procd_append_param command --log-level="$LOG_LEVEL"
mm_cleanup_interfaces; \ [ "$LOG_LEVEL" = "DEBUG" ] && procd_append_param command --debug
( mm_report_events_from_cache ) >/dev/null 2>&1 & \
/usr/sbin/ModemManager"
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}" procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
procd_set_param pidfile "${MODEMMANAGER_PID_FILE}" procd_set_param pidfile "${MODEMMANAGER_PID_FILE}"
procd_close_instance procd_close_instance

View File

@ -515,7 +515,8 @@ proto_modemmanager_teardown() {
modemstatus=$(mmcli --modem="${device}" --output-keyvalue) modemstatus=$(mmcli --modem="${device}" --output-keyvalue)
bearerpath=$(modemmanager_get_field "${modemstatus}" "modem.generic.bearers.value\[1\]") bearerpath=$(modemmanager_get_field "${modemstatus}" "modem.generic.bearers.value\[1\]")
[ -n "${bearerpath}" ] || { [ -n "${bearerpath}" ] || {
echo "couldn't load bearer path" echo "couldn't load bearer path: disconnecting anyway"
mmcli --modem="${device}" --simple-disconnect >/dev/null 2>&1
return return
} }

View File

@ -0,0 +1,33 @@
#!/bin/sh
trap_with_arg() {
func="$1" ; shift
for sig ; do
# shellcheck disable=SC2064
trap "$func $sig" "$sig"
done
}
func_trap() {
logger "ModemManager-wrapper[$$]" "Sending signal ${1}..."
kill "-${1}" "$CHILD" 2>/dev/null
}
main() {
. /usr/share/ModemManager/modemmanager.common
trap_with_arg func_trap INT TERM KILL
mkdir -p "${MODEMMANAGER_RUNDIR}"
chmod 0755 "${MODEMMANAGER_RUNDIR}"
mm_cleanup_interfaces
/usr/sbin/ModemManager "$@" 1>/dev/null 2>/dev/null &
CHILD="$!"
mm_report_events_from_cache
wait "$CHILD"
}
main "$@"