relying on UCI wireless config being ready in ieee80211 hotplug handlers

Leon Busch-George leon at georgemail.eu
Mon Aug 21 04:24:31 PDT 2023


Hi :-)

Recently, a race condition was discovered which relates to `wifi config` being called before `board_detect`.
It was fixed by creating a marker file `/tmp/.config_pending` (b993a00b82b, in /etc/init.d/boot).
While the marker is present, `wifi config` exits without doing anything (exit code 0).

There is a hotplug handler `ieee80211/10-wifi-detect` which calls `wifi config` and that is now a noop while the marker is present.
This is not a problem because
  1. the marker is created before `kmodloader` loads mac80211 (among others), so the marker is already there when the hotplug handler is called (and `wifi config` wouldn't encounter any phys if it is called otherwise), and 
  2. `/etc/init.d/boot` calls `wifi config` after the deletion of the marker which then adds all the sections to UCI which would otherwise have been added from the hotplug handler.
(There's still a race with hotplug and init.d/boot calling `wifi config` at the same time, though. Afterwards, there should be no problem.)

My concern is the following:
Previously, any hotplug handlers lexically ordered behind `10-wifi-detect` were able to rely on the fact that the UCI sections for the phy in question have already been created.
This is no longer the case. Now, it is difficult to do so even when calling `wifi config` manually.
Waiting for the marker file to be deleted and then calling `wifi config` is a horrible idea (again, racing `wifi config`).
Waiting for any amount of sections to appear in /etc/config/wireless won't guarantee that the radio for which the hotplug handler is being called exists already.
Testing for and identifying the corresponding section is already a bit clumsy (for mac80211, it could be identified by path, macaddr, or phy). If there's no matching section there might have been an error - or I'm checking to early.

My initial thought was creating a service to queue and synchronize calls to `wifi config` but that seems a bit overblown and has other problems.
Is anyone experiencing related problems? Is there a proper way to wait for the UCI sections to be created?

kind regards



More information about the openwrt-devel mailing list