Netifd: how can a protocol handler report that an interface is disconnected?

The "modemmanager" netifd protocol handler installed by the package with the same name (in the packages repository) is able to setup and teardown connections managed via the ModemManager daemon, see https://github.com/openwrt/packages/blob/master/net/modemmanager/files/modemmanager.proto

For setting up an interface, the modem is first connected using a modem control protocol (e.g. AT, QMI, MBIM...) and once the device is in connected state, the associated data interface is configured (e.g. static IP addressing or DHCP in a net interface or PPP over a TTY).

The process to teardown an interface is equivalent to the setup; first the associated data interface is brought down and then the modem is disconnected using the modem control protocol.

Now, there are cases where it is the modem itself the one detecting a disconnection; e.g. a network-triggered disconnection. In this case, ModemManager gets notified that the modem is disconnected, and it reports the disconnection via DBus as well (the bearer object state would be disconnected), but in the netifd protocol handler side there is nothing monitoring the state of the bearer object, so that disconnection is never handled by netifd (i.e. it would still report the interface up even if there is no connection).

Is there any way a netifd protocol handler can "monitor" the connection so that it reports the correct state of the interface? Otherwise, how to handle this situation? Right now, if the network interface is brought up (either manually or automatically) and the connection is stopped by the network, there is no indication that this happened and so there is no autoreconnection done by netifd.

A quick solution would be to have some "monitor" method (e.g. a proto_modemmanager_monitor() method) that netifd could periodically call once the interface is up, and that would take care of checking the real state of the bearer connection reported by the ModemManager daemon). It wouldn't be an instant detection of the disconnection (due to the polling timeout) but at least it would be better than leaving the modem disconnected but assumed connected for hours.

The best solution would be having ModemManager itself report the bearer disconnection directly to netifd somehow, maybe integrating with ubus just for this purpose?

2 Likes

Has there been any progress on this?

1 Like

I am keen to know this too.