From ba92c4552bf96632ce5dc3236f4a30cf9a9e58f0 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 13 Jun 2022 12:24:43 +0200 Subject: [PATCH] modemmanager: explicitly disconnect even if no bearers found A network restart where netifd is cleanly restarted involves bringing the network interfaces down. The 'modemmanager' protocol handler will run a mmcli --simple-disconnect in this case, but only if there are bearer objects found. If the network restart happened *during* the connection attempt procedure, while the modem is e.g. being registered in the network, no bearer objects exist yet, and so, we would skip doing anything during the interface teardown operation. This would lead to the original connection attempt succeeding, so leaving the modem in ModemManager in connected state, while the associated interface in netifd is reported down. Signed-off-by: Aleksander Morgado (cherry picked from commit c15e94f6c5fbbaedd41fd74b930a2a205f80afc0) --- net/modemmanager/files/modemmanager.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/modemmanager/files/modemmanager.proto b/net/modemmanager/files/modemmanager.proto index d24910b984..855060f06e 100755 --- a/net/modemmanager/files/modemmanager.proto +++ b/net/modemmanager/files/modemmanager.proto @@ -515,7 +515,8 @@ proto_modemmanager_teardown() { modemstatus=$(mmcli --modem="${device}" --output-keyvalue) bearerpath=$(modemmanager_get_field "${modemstatus}" "modem.generic.bearers.value\[1\]") [ -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 }