From 2aff57efdc10f3dd42efb892f19915b36aaeacb4 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 4 May 2022 14:01:57 +0200 Subject: [PATCH] modemmanager: report network initiated disconnections to netifd The new connection dispatcher scripts support integrated in ModemManager 1.18.8 allows us to provide a openwrt-specific dispatcher script used to report netifd that the underlying network connection is down. See also https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/775 Fixes https://github.com/openwrt/openwrt/issues/8368 Fixes https://github.com/openwrt/packages/issues/14096 Signed-off-by: Aleksander Morgado (cherry picked from commit bc754f31cfdb004eefa43038f8f0827922107fc6) --- net/modemmanager/Makefile | 3 +++ net/modemmanager/files/10-report-down | 35 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 net/modemmanager/files/10-report-down diff --git a/net/modemmanager/Makefile b/net/modemmanager/Makefile index 8b928677d3..601ff7997c 100644 --- a/net/modemmanager/Makefile +++ b/net/modemmanager/Makefile @@ -100,6 +100,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-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_CONF) $(PKG_INSTALL_DIR)/etc/dbus-1/system.d/org.freedesktop.ModemManager1.conf $(1)/etc/dbus-1/system.d diff --git a/net/modemmanager/files/10-report-down b/net/modemmanager/files/10-report-down new file mode 100755 index 0000000000..a3e5fb4ba7 --- /dev/null +++ b/net/modemmanager/files/10-report-down @@ -0,0 +1,35 @@ +#!/bin/sh + +# SPDX-License-Identifier: CC0-1.0 +# 2022 Aleksander Morgado +# +# 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 -- 2.30.2