From 11ca2ea4839c0d7213de00ac3de2f892baa46099 Mon Sep 17 00:00:00 2001 From: stsp Date: Tue, 30 May 2017 10:50:33 +0000 Subject: [PATCH] Always set the link state DOWN once we enter ieee80211_newstate(), regardless of whether the wifi interface happens to be leaving RUN state. The interface is never usable during state transitions so setting the link DOWN is the only reasonable option when any transition is triggered. Fixes a problem where, at boot time, the link state of wifi interfaces was reported to userland as UNKNOWN (which, curiously, has value 0). dhclient's link detection logic was recently changed from ifmedia to getifaddrs which exposed the UNKOWN link state. Since dhclient assumes an UNKNOWN link state means UP it would start trying to negotiate a lease too early during boot. Problem reported by tb@ ok krw@ --- sys/net80211/ieee80211_proto.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index 3271c86b335..fde740f9c62 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_proto.c,v 1.74 2017/03/02 09:41:27 stsp Exp $ */ +/* $OpenBSD: ieee80211_proto.c,v 1.75 2017/05/30 10:50:33 stsp Exp $ */ /* $NetBSD: ieee80211_proto.c,v 1.8 2004/04/30 23:58:20 dyoung Exp $ */ /*- @@ -828,8 +828,7 @@ ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, ieee80211_state_name[nstate])); ic->ic_state = nstate; /* state transition */ ni = ic->ic_bss; /* NB: no reference held */ - if (ostate == IEEE80211_S_RUN) - ieee80211_set_link_state(ic, LINK_STATE_DOWN); + ieee80211_set_link_state(ic, LINK_STATE_DOWN); switch (nstate) { case IEEE80211_S_INIT: /* -- 2.20.1