@bmork I wonder about your thoughts on the following.
The latest ModemManager includes a '10-report-down' script to report to netifd a modem disconnection. I hacked this to check whether the interface was originally up before reporting the interface as down, and after having reported the interface as down, then bring the interface back up again with 'ifup', as follows:
root@OpenWrt:/lib/netifd/proto# cat /usr/lib/ModemManager/connection.d/10-report-down-and-reconnect
#!/bin/sh
# Report modem disconnect to netifd and reconnect if the interface was up
# 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
IFUP=$(ifstatus ${CFG} | jsonfilter -e '@.up')
logger -t "modemmanager" "interface ${CFG} (network device ${INTERFACE}) ${STATE}"
proto_init_update $INTERFACE 0
proto_send_update $CFG
[ "${IFUP}" = "true" ] && ifup ${CFG}
exit 0
So I just added the ifup check and ifup call to sandwhich the report to netifd that the interface has gone down, as follows:
IFUP=$(ifstatus ${CFG} | jsonfilter -e '@.up')
logger -t "modemmanager" "interface ${CFG} (network device ${INTERFACE}) ${STATE}"
proto_init_update $INTERFACE 0
proto_send_update $CFG
[ "${IFUP}" = "true" ] && ifup ${CFG}
Please let me know if any obvious improvement is readily apparent to you.
This results in automatic reconnection, but it is somewhat slow in that on checking my logs I see that a disconnect event occurred at 11:18:08 and then wan got back up 11:18:13 (so around 5 to 6 seconds to fully reconnect). Here is the log:
Mon Nov 7 11:18:08 2022 daemon.info [2727]: <info> [modem0/bearer27] verbose call end reason (6,36): [3gpp] regular-deactivation
Mon Nov 7 11:18:08 2022 daemon.info [2727]: <info> [modem0] state changed (connected -> registered)
Mon Nov 7 11:18:08 2022 daemon.info [2727]: <info> [modem0/bearer27] connection #1 finished: duration 172799s, tx: 3431975022 bytes, rx: 27023076800 bytes
Mon Nov 7 11:18:09 2022 user.notice modemmanager: interface wan (network device wwan0) disconnected
Mon Nov 7 11:18:09 2022 daemon.notice netifd: Interface 'wan' has lost the connection
Mon Nov 7 11:18:09 2022 daemon.notice netifd: Network device 'wwan0' link is down
Mon Nov 7 11:18:09 2022 daemon.warn dnsmasq[1]: no servers found in /tmp/resolv.conf.d/resolv.conf.auto, will retry
Mon Nov 7 11:18:09 2022 daemon.notice netifd: wan (13635): stopping network
Mon Nov 7 11:18:09 2022 daemon.notice netifd: wan (13635): running disconnection (common)
Mon Nov 7 11:18:09 2022 daemon.notice netifd: wan (13635): Command failed: ubus call network.interface notify_proto { "action": 0, "link-up": false, "keep": false, "interface": "wan" } (Permission denied)
Mon Nov 7 11:18:09 2022 daemon.notice netifd: wan (13635): successfully disconnected all bearers in the modem
Mon Nov 7 11:18:09 2022 daemon.info [2727]: <info> [modem0] state changed (registered -> disabling)
Mon Nov 7 11:18:10 2022 daemon.info [2727]: <info> [modem0] 3GPP registration state changed (home -> unknown)
Mon Nov 7 11:18:10 2022 daemon.info [2727]: <info> [modem0] state changed (disabling -> disabled)
Mon Nov 7 11:18:10 2022 daemon.notice netifd: wan (13635): successfully disabled the modem
Mon Nov 7 11:18:10 2022 daemon.notice netifd: Interface 'wan' is now down
Mon Nov 7 11:18:10 2022 daemon.notice netifd: Interface 'wan' is setting up now
Mon Nov 7 11:18:10 2022 daemon.notice netifd: wan (13683): modem available at /org/freedesktop/ModemManager1/Modem/0
Mon Nov 7 11:18:10 2022 daemon.notice netifd: wan (13683): starting connection with apn 'wap.vodafone.co.uk'...
Mon Nov 7 11:18:10 2022 daemon.info [2727]: <info> [modem0] simple connect started...
Mon Nov 7 11:18:10 2022 daemon.info [2727]: <info> [modem0] simple connect state (3/8): enable
Mon Nov 7 11:18:10 2022 daemon.info [2727]: <info> [modem0] state changed (disabled -> enabling)
Mon Nov 7 11:18:10 2022 daemon.info [2727]: <info> [modem0] power state updated: on
Mon Nov 7 11:18:11 2022 daemon.info [2727]: <info> [modem0] simple connect state (4/8): wait to get fully enabled
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0] state changed (enabling -> enabled)
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0] simple connect state (5/8): register
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0] 3GPP registration state changed (unknown -> registering)
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0] 3GPP registration state changed (registering -> home)
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0] state changed (enabled -> registered)
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0] simple connect state (6/8): bearer
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0] simple connect state (7/8): connect
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0] state changed (registered -> connecting)
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0/bearer29] QMI IPv4 Settings:
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0/bearer29] address: 10.13.xx.yy/30
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0/bearer29] gateway: 10.13.xx.zz
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0/bearer29] DNS #1: 192.168.aa.1
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0/bearer29] DNS #2: failed (Field 'Secondary IPv4 DNS Address' was not found in the message)
Mon Nov 7 11:18:12 2022 daemon.info [2727]: <info> [modem0/bearer29] MTU: 1500
Mon Nov 7 11:18:13 2022 daemon.info [2727]: <info> [modem0/bearer29] couldn't start network: QMI protocol error (14): 'CallFailed'
Mon Nov 7 11:18:13 2022 daemon.info [2727]: <info> [modem0/bearer29] verbose call end reason (2,210): [internal] pdn-ipv6-call-disallowed
Mon Nov 7 11:18:13 2022 daemon.info [2727]: <info> [modem0] state changed (connecting -> connected)
Mon Nov 7 11:18:13 2022 daemon.info [2727]: <info> [modem0] simple connect state (8/8): all done
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): successfully connected the modem
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): signal refresh rate is not set
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): network operator name: voda UK
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): network operator MCCMNC: 23415
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): registration type: home
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): access technology: lte
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): signal quality: 63%
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): IPv4 connection setup required in interface wan: static
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): adding IPv4 address 10.13.xx.yy, netmask 255.255.255.252
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): adding default IPv4 route via 10.13.xx.zz
Mon Nov 7 11:18:13 2022 daemon.notice netifd: wan (13683): adding primary DNS at 192.168.aa.1
Mon Nov 7 11:18:13 2022 daemon.notice netifd: Interface 'wan' is now up
Mon Nov 7 11:18:13 2022 daemon.info dnsmasq[1]: reading /tmp/resolv.conf.d/resolv.conf.auto
Mon Nov 7 11:18:13 2022 daemon.notice netifd: Network device 'wwan0' link is up
Mon Nov 7 11:18:13 2022 daemon.info dnsmasq[1]: using nameserver 192.168.aa.1#53
Mon Nov 7 11:18:13 2022 daemon.info dnsmasq[1]: using only locally-known addresses for test
Mon Nov 7 11:18:13 2022 daemon.info dnsmasq[1]: using only locally-known addresses for onion
Mon Nov 7 11:18:13 2022 daemon.info dnsmasq[1]: using only locally-known addresses for localhost
Mon Nov 7 11:18:13 2022 daemon.info dnsmasq[1]: using only locally-known addresses for local
Mon Nov 7 11:18:13 2022 daemon.info dnsmasq[1]: using only locally-known addresses for invalid
Mon Nov 7 11:18:13 2022 daemon.info dnsmasq[1]: using only locally-known addresses for bind
Mon Nov 7 11:18:13 2022 daemon.info dnsmasq[1]: using only locally-known addresses for lan
Mon Nov 7 11:18:14 2022 user.notice firewall: Reloading firewall due to ifup of wan (wwan0)
Do you think that this could be sped up at all?
Could it perhaps be sped up by trying to get the modem's built in '--set-autoconnect enabled' functionality to work?
Is there a way to have the modem just handle all the IP stuff so that we don't have to worry about IP settings and just let the modem itself reconnect and get treated as an ethernet device?
Do you know how the Zyxel firmware handles this reconnection issue?