modemmanager: move cleanup and enable to the top
authorFlorian Eckert <fe@dev.tdt.de>
Wed, 21 Feb 2024 15:03:07 +0000 (16:03 +0100)
committerFlorian Eckert <fe@dev.tdt.de>
Tue, 5 Mar 2024 14:20:38 +0000 (15:20 +0100)
Before a new connection attempt is made, the previous connection must be
cleaned up before further connection attempts are made. This is now done
by moving the cleanup and enable sequence to the beginning of the
conection setup.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
net/modemmanager/files/lib/netifd/proto/modemmanager.sh

index b059b4c59cadedc164ad2c917c4e80bde875a6b3..96597268377bebb377fd0228c919a0117aa53875 100644 (file)
@@ -458,6 +458,14 @@ proto_modemmanager_setup() {
        modemmanager_check_state "$device" "${modemstatus}" "$pincode"
        [ "$?" -ne "0" ] && return 1
 
+       # always cleanup before attempting a new connection, just in case
+       modemmanager_cleanup_connection "${modemstatus}"
+
+       mmcli --modem="${device}" --timeout 120 --enable || {
+               proto_notify_error "${interface}" MM_MODEM_DISABLED
+               return 1
+       }
+
        if [ -z "${allowedmode}" ]; then
                modemmanager_set_allowed_mode "$device" "$interface" "any"
        else
@@ -487,14 +495,6 @@ proto_modemmanager_setup() {
                [ "$?" -ne "0" ] && return 1
        fi
 
-       # always cleanup before attempting a new connection, just in case
-       modemmanager_cleanup_connection "${modemstatus}"
-
-       mmcli --modem="${device}" --timeout 120 --enable || {
-               proto_notify_error "${interface}" MM_MODEM_DISABLED
-               return 1
-       }
-
        # set initial eps bearer settings
        [ -z "${init_epsbearer}" ] || {
                case "$init_epsbearer" in