From 434c353e62a6bcd697e991f76658feae10a67ade Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 4 Feb 2025 12:36:51 +0100 Subject: [PATCH] modemmanager: do not disable modem on reconnect If the modem loses the connection, an attempt is made to re-establish the connection via the report-down script. Until now, the modem was disabled when the modem processed the teardown of the modemmanager protohandler. The immediate up events of netifd renables the modem right away. This takes time, which is not necessary. This commit changes the behavior so that the modem is not disabled when the modemmanager is disconnected via the report-down script. Signed-off-by: Florian Eckert --- net/modemmanager/Makefile | 2 +- .../files/lib/netifd/proto/modemmanager.sh | 13 +++++++++++-- .../lib/ModemManager/connection.d/10-report-down | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/net/modemmanager/Makefile b/net/modemmanager/Makefile index fb4bcef9cb..fc50a7478a 100644 --- a/net/modemmanager/Makefile +++ b/net/modemmanager/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=modemmanager PKG_VERSION:=1.22.0 -PKG_RELEASE:=20 +PKG_RELEASE:=21 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/ModemManager.git diff --git a/net/modemmanager/files/lib/netifd/proto/modemmanager.sh b/net/modemmanager/files/lib/netifd/proto/modemmanager.sh index 715178f71e..1d0211cf85 100644 --- a/net/modemmanager/files/lib/netifd/proto/modemmanager.sh +++ b/net/modemmanager/files/lib/netifd/proto/modemmanager.sh @@ -869,8 +869,17 @@ proto_modemmanager_teardown() { mmcli --modem="${device}" --simple-disconnect || proto_notify_error "${interface}" DISCONNECT_FAILED - # disable - mmcli --modem="${device}" --disable + # reading variable from var state which was set in + # '/usr/lib/ModemManager/connection.d/10-report-down' + # because of a reconnect event. + # The modem therefore does not need to be disabled. + local disable="$(uci_get_state network "$interface" disable_modem "1")" + if [ "${disable}" -eq 0 ]; then + echo "Skipping modem disable" + uci_revert_state network "${interface}" disable_modem + else + mmcli --modem="${device}" --disable + fi # low power, only if requested [ "${lowpower:-0}" -lt 1 ] || diff --git a/net/modemmanager/files/usr/lib/ModemManager/connection.d/10-report-down b/net/modemmanager/files/usr/lib/ModemManager/connection.d/10-report-down index b8feb26779..9c0484d6ed 100644 --- a/net/modemmanager/files/usr/lib/ModemManager/connection.d/10-report-down +++ b/net/modemmanager/files/usr/lib/ModemManager/connection.d/10-report-down @@ -32,6 +32,7 @@ IFUP=$(ifstatus "${CFG}" | jsonfilter -e "@.up") [ "${IFUP}" = "true" ] && { mm_log "info" "Reconnecting '${CFG}' on '${STATE}' event" + uci_toggle_state network "${CFG}" disable_modem "0" ubus call network.interface down "{ 'interface': '${CFG}'}" ubus call network.interface up "{ 'interface': '${CFG}'}" } -- 2.30.2