Set the link state of wifi interfaces to DOWN at attach time
instead of leaving it as UNKNOWN which userland cannot really
make use of (e.g. dhclient interprets UNKNOWN as UP).

Link state is also reset by the ieee80211_newstate() function.
However, that function is usually called by the driver-specific newstate
function stored in ic->ic_newstate. During the very first time ic_newstate()
runs, without the diff below the link state is UNKNOWN. And if a driver
decides not to call ieee80211_newstate() for some reason (such as iwm(4)
does during INIT->SCAN) the link state will still be UNKNOWN.

In my opinion the link state of wifi interfaces should at any time
be either DOWN or UP, and never UNKNOWN.

ok?

Index: sys/net80211/ieee80211.c
===================================================================
RCS file: /cvs/src/sys/net80211/ieee80211.c,v
retrieving revision 1.61
diff -u -p -r1.61 ieee80211.c
--- sys/net80211/ieee80211.c    31 May 2017 09:17:39 -0000      1.61
+++ sys/net80211/ieee80211.c    7 Jun 2017 15:08:55 -0000
@@ -156,6 +156,8 @@ ieee80211_ifattach(struct ifnet *ifp)
 
        if_addgroup(ifp, "wlan");
        ifp->if_priority = IF_WIRELESS_DEFAULT_PRIORITY;
+
+       ieee80211_set_link_state(ic, LINK_STATE_DOWN);
 }
 
 void

Reply via email to