Hotplug not working during Interface Up/Down

Hi Guys,

  1. I'm working on doing some actions via script during interface up/down. Im trying to use the hotplug feature by adding myscript under

root@OpenWrt:/etc/hotplug.d/iface# ls
00-netstate 10-qos 15-teql 20-firewall 25-dnsmasq
root@OpenWrt:/etc/hotplug.d/iface#

However, none of the scripts are being invoked. Confirmed by adding echo/debugs there.

Is there anything else to be done to trigger this hotplug feature ? Or Is it tied with Driver /platform dependent ? Please help.

  1. Also noted a strange issue where interface hold IP address even after pulling out the ethernet cable.

Thanks!

The /etc/hotplug.d/iface/ event class is synthesized by netifd and only applies to uci managed interfaces from /etc/config/network and that also only if netifd actuall brings down the interface which might not happen in all cases (see below). In case the interfaces you're trying to watch are not managed by netifd, see if using /etc/hotplug.d/net/ instead helps, this will receive lower level Kernel netdev events.

This happens on many devices, primarily on those having a builtin switch. Since the connection between the switch and the routers CPU port (eth0/eth1) is always up, the local ethernet interface will never see a link down event, which means that netifd will not shutdown and deconfigure the associated network.

Your only choice in such situations is active connectivity checking by other means, e.g. ping testing or similar.

3 Likes

I've the same problem. If i plug off the ethernet cable, i see from the system log, that netifd reload the wan interface but it doen't execute the scripts in /etc/hotplug.d/iface. On the start up the hotplug script are executed: there is the ....SignalRClient.... log print i've inserted in the script inside /etc/hotplug.d/iface :

Fri Jun 21 23:35:53 2019 daemon.notice netifd: Interface 'wan' is now up
Fri Jun 21 23:35:53 2019 daemon.notice hostapd: wlan0: interface state COUNTRY_UPDATE->ENABLED
Fri Jun 21 23:35:53 2019 daemon.notice hostapd: wlan0: AP-ENABLED
Fri Jun 21 23:35:54 2019 daemon.notice netifd: Network device 'wlan0' link is up
Fri Jun 21 23:35:54 2019 daemon.notice netifd: Interface 'lan' is enabled
Fri Jun 21 23:35:54 2019 daemon.notice netifd: Interface 'lan' is setting up now
Fri Jun 21 23:35:54 2019 daemon.notice netifd: Interface 'lan' is now up
Fri Jun 21 23:35:54 2019 daemon.notice netifd: Interface 'lan' has link connectivity
Fri Jun 21 23:35:55 2019 user.notice firewall: Reloading firewall due to ifup of wan (eth1)
Fri Jun 21 23:35:55 2019 **user.notice root: iface wan up detected: SignalRClient start e UPnP**

but when i pluged off the cable for simulating a wan down the netifd deamon intercept the wan interface down, but after the wan interface up the scripts in /etc/hootplug.d/iface don't be executed. Probably the ethernet pluged off is not the right way to simulate a wan interface down.

Sat Jun 22 11:34:13 2019 kern.info kernel: [ 3076.067996] eth1: link down
Sat Jun 22 11:34:13 2019 daemon.notice netifd: Network device 'eth1' link is down
Sat Jun 22 11:34:13 2019 daemon.notice netifd: Interface 'wan' has link connectivity loss
Sat Jun 22 11:34:24 2019 daemon.notice netifd: Network device 'eth1' link is up
Sat Jun 22 11:34:24 2019 daemon.notice netifd: Interface 'wan' has link connectivity
Sat Jun 22 11:34:24 2019 daemon.notice netifd: Interface 'wan' is setting up now
Sat Jun 22 11:34:25 2019 daemon.notice netifd: Interface 'wan' is now up

I discussed with Mediatek vendor and they indicated that they have to do changes in driver to trigger the event. This was done in ipq80x/40x platforms by default.

@guru ny update from MediaTek?

A similar problem with OpenWrt 18.06.8
The script from iface is not executed. Does not detect that the device is wlan0 up

[ "$ACTION" = ifup -a "$DEVICE" = wlan0 ] || exit 0
while true; do
sleep 300
iw wlan0 scan >/dev/null
logger  "WLAN driver ath9k wake up"
done

Thu Jul  9 03:00:14 2020 daemon.notice netifd: Network device 'wlan0' link is up

This script works fine, for example, OpenWrt Barrier Breaker. 14.07 Maybe the syntax of these scripts has changed?

Verification script from https://openwrt.org/docs/guide-user/base-system/hotplug
also does not work.

[ "${ACTION}" = "ifup" ] && {
    logger -t hotplug "Device: ${DEVICE} / Action: ${ACTION}"
}

Probably all other scripts that have a default iface folder do not work either

I have the same issues with some EdgeRouter X under OpenWrt 19.07.3 .

Please ensure that the option "Force link" in your interface definitions are not selected, because if they are, it is normal the scripts are never called. But once this option is disabled, the scripts are called only once, for the first down to up link state change, which is no better.

We would need a clean fix so that link up / link down states change would be really taken into consideration, and have the scripts in /etc/hotplug.d/iface really called at each link state change.

1 Like

Same here with an EdgeRouter X running 19.0.7.6:

The kernel is detecting and logging that the port is going up or down, but the hotplug event only occurs when mwan3s tracking script detects the interface as (dis)connected. Which delays the failover much more than needed.

`Fri Feb 12 18:14:40 2021 kern.info kernel: [179032.462872] mtk_soc_eth 1e100000.ethernet eth0: port 0 link down`
... (13 sec delay)

`Fri Feb 12 18:14:53 2021 user.notice hotplug: USER=root ACTION=ifdown SHLVL=1 HOTPLUG_TYPE=iface LOGNAME=root DEVICENAME= PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=wan PWD=/ DEVICE=eth0.2`

`Fri Feb 12 18:18:33 2021 kern.info kernel: [179265.781815] mtk_soc_eth 1e100000.ethernet eth0: port 0 link up`
... (59 sec delay)
`Fri Feb 12 18:19:32 2021 user.notice hotplug: USER=root ACTION=ifup SHLVL=1 HOTPLUG_TYPE=iface LOGNAME=root DEVICENAME= PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=wan PWD=/ DEVICE=eth0.2`

`Fri Feb 12 18:30:12 2021 kern.info kernel: [179964.846667] mtk_soc_eth 1e100000.ethernet eth0: port 1 link down`
... (13 sec delay)
`Fri Feb 12 18:30:25 2021 user.notice hotplug: USER=root ACTION=ifdown SHLVL=1 HOTPLUG_TYPE=iface LOGNAME=root DEVICENAME= PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=wanb PWD=/ DEVICE=eth0.3`

Is there a way to trigger a hotplug event based on the kernel event?

After some searching I found that the master branch is now using DSA for the switches. This might solve the issue.

At the moment I'm not able to test, because the router is in production. If anyone could confirm that would be great.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.