[OpenWrt-Devel] netifd hotplug event race condition for monitor interfaces
Bruno Randolf
br1 at einfach.org
Fri Apr 29 08:22:53 EDT 2016
Hello,
I have a system where I want to reload a service when a monitor
interface appears. The monitor interface is configured in
/etc/config/wireless as:
config wifi-iface 'monitor'
option device 'radio0'
option ifname 'moni0'
option mode 'monitor'
Unfortunately netifd events for monitor interfaces are not reliable at
boot time. On some slower systems I never get them, on a Raspberry Pi 2
I get them about 50% of the time.
I have been able to debug it down to netifd/system-linux.c
handle_hotplug_msg() where system_if_force_external() is either true or
false, depending whether /sys/class/net/moni0/phy80211 already exists or
not. Interestingly it works well when it does not exist yet: then I get
the following log, the interface gets UP, and the hotplug script which
restarts my service is called:
netifd: Interface 'moni' is enabled
netifd: Network device 'moni0' link is up
netifd: Interface 'moni' has link connectivity
netifd: Interface 'moni' is setting up now
netifd: Interface 'moni' is now up
But when the /sys/ file does already exist, and
system_if_force_external() is true, I get the following log and the
interface stays down:
netifd: radio0 (1144): command failed: Device or resource busy (-16)
netifd: radio0 (1144): ifconfig: SIOCSIFHWADDR: Invalid argument
netifd: Network device 'moni0' link is up
netifd: Interface 'moni' has link connectivity
root at Rpi2:~# ubus call network.interface.moni status
{
"up": false,
"pending": false,
"available": false,
"autostart": true,
"dynamic": false,
"proto": "none",
"device": "moni0",
"data": {
}
}
I guess the problem is that monitor interfaces are created almost
instantly, in comparison to AP, STA and Ad-hoc interfaces which need
some time to set up...?
Any ideas how to fix this are appreciated, I want to do it, but I am
stuck now.
Thanks,
bruno
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list