network.subr: Workaround race between wpa_supplicant and dhcpcd
authorAaron LI <aly@aaronly.me>
Wed, 12 Dec 2018 04:06:17 +0000 (12:06 +0800)
committerAaron LI <aly@aaronly.me>
Fri, 14 Dec 2018 14:18:07 +0000 (22:18 +0800)
Insert a 1-second delay after starting wpa_supplicant(8) to workaround
the race between it and dhcpcd(8), which can modify the interface's
state and break wpa_supplicant's ongoing SSID scan.

dhclient(8) doesn't have such an issue with wpa_supplicant.

Tested-by: me, Daniel Bilik <ddb@neosystem.org>
etc/network.subr

index 0d2727d..fe4e566 100644 (file)
@@ -52,6 +52,14 @@ ifconfig_up()
        if wpaif $1; then
                ifconfig $1 up
                /etc/rc.d/wpa_supplicant start $1
+               # NOTE: wpa_supplicant(8) needs to control the interface's
+               #       state in order to perform the SSID scan.  But
+               #       dhcpcd(8), which may be started by the "dhcp_client"
+               #       below, can race against wpa_supplicant(8) and modify
+               #       the interface's state, breaking the SSID scan and
+               #       preventing the SSID association.
+               #       Insert a small delay here to workaround the issue.
+               sleep 1
                _cfg=0          # XXX: not sure this should count
        fi