Some drivers use their own functions to change the link state for a
non-background scan, so ensure that they set the link state to down, and
free all nodes.  This is a follow up to stsp@'s ieee80211.c:r1.68.

(N.B. the atu driver already calls ieee80211_free_allnodes in this case
statement, but outside of the diff context)

Tested on iwm(4)

OK?


Index: ic/bwfm.c
===================================================================
RCS file: /cvs/openbsd/src/sys/dev/ic/bwfm.c,v
retrieving revision 1.42
diff -u -p -u -p -r1.42 bwfm.c
--- ic/bwfm.c   26 Apr 2018 12:50:07 -0000      1.42
+++ ic/bwfm.c   28 Apr 2018 15:01:55 -0000
@@ -2294,6 +2294,8 @@ bwfm_newstate(struct ieee80211com *ic, e
                        printf("%s: %s -> %s\n", DEVNAME(sc),
                            ieee80211_state_name[ic->ic_state],
                            ieee80211_state_name[nstate]);
+               ieee80211_set_link_state(ic, LINK_STATE_DOWN);
+               ieee80211_free_allnodes(ic, 1);
                ic->ic_state = nstate;
                splx(s);
                return 0;
Index: ic/pgt.c
===================================================================
RCS file: /cvs/openbsd/src/sys/dev/ic/pgt.c,v
retrieving revision 1.92
diff -u -p -u -p -r1.92 pgt.c
--- ic/pgt.c    28 Apr 2018 14:49:07 -0000      1.92
+++ ic/pgt.c    28 Apr 2018 15:17:35 -0000
@@ -2937,6 +2937,7 @@ pgt_newstate(struct ieee80211com *ic, en
                ic->ic_mgt_timer = 0;
                ic->ic_flags &= ~IEEE80211_F_SIBSS;
                ieee80211_free_allnodes(ic, 1);
+               ieee80211_set_link_state(ic, LINK_STATE_DOWN);
                break;
        case IEEE80211_S_SCAN:
                ic->ic_if.if_timer = 1;
@@ -2946,6 +2947,7 @@ pgt_newstate(struct ieee80211com *ic, en
                else
                        ieee80211_free_allnodes(ic, 1);
 
+               ieee80211_set_link_state(ic, LINK_STATE_DOWN);
 #ifndef IEEE80211_STA_ONLY
                /* Just use any old channel; we override it anyway. */
                if (ic->ic_opmode == IEEE80211_M_HOSTAP)
Index: pci/if_iwm.c
===================================================================
RCS file: /cvs/openbsd/src/sys/dev/pci/if_iwm.c,v
retrieving revision 1.227
diff -u -p -u -p -r1.227 if_iwm.c
--- pci/if_iwm.c        26 Apr 2018 12:50:07 -0000      1.227
+++ pci/if_iwm.c        28 Apr 2018 14:42:26 -0000
@@ -5501,6 +5501,10 @@ iwm_scan(struct iwm_softc *sc)
                printf("%s: %s -> %s\n", ifp->if_xname,
                    ieee80211_state_name[ic->ic_state],
                    ieee80211_state_name[IEEE80211_S_SCAN]);
+       if ((sc->sc_flags & IWM_FLAG_BGSCAN) == 0) {
+               ieee80211_set_link_state(ic, LINK_STATE_DOWN);
+               ieee80211_free_allnodes(ic, 1);
+       }
        ic->ic_state = IEEE80211_S_SCAN;
        iwm_led_blink_start(sc);
        wakeup(&ic->ic_state); /* wake iwm_init() */
Index: pci/if_iwn.c
===================================================================
RCS file: /cvs/openbsd/src/sys/dev/pci/if_iwn.c,v
retrieving revision 1.202
diff -u -p -u -p -r1.202 if_iwn.c
--- pci/if_iwn.c        26 Apr 2018 12:50:07 -0000      1.202
+++ pci/if_iwn.c        28 Apr 2018 14:59:42 -0000
@@ -1808,6 +1808,10 @@ iwn_newstate(struct ieee80211com *ic, en
                        printf("%s: %s -> %s\n", ifp->if_xname,
                            ieee80211_state_name[ic->ic_state],
                            ieee80211_state_name[nstate]);
+               if ((sc->sc_flags & IWN_FLAG_BGSCAN) == 0) {
+                       ieee80211_set_link_state(ic, LINK_STATE_DOWN);
+                       ieee80211_free_allnodes(ic, 1);
+               }
                ic->ic_state = nstate;
                return 0;
 
Index: pci/if_wpi.c
===================================================================
RCS file: /cvs/openbsd/src/sys/dev/pci/if_wpi.c,v
retrieving revision 1.143
diff -u -p -u -p -r1.143 if_wpi.c
--- pci/if_wpi.c        26 Apr 2018 12:50:07 -0000      1.143
+++ pci/if_wpi.c        28 Apr 2018 14:58:59 -0000
@@ -1057,6 +1057,8 @@ wpi_newstate(struct ieee80211com *ic, en
                        printf("%s: %s -> %s\n", ifp->if_xname,
                            ieee80211_state_name[ic->ic_state],
                            ieee80211_state_name[nstate]);
+               ieee80211_set_link_state(ic, LINK_STATE_DOWN);
+               ieee80211_free_allnodes(ic, 1);
                ic->ic_state = nstate;
                return 0;
 
Index: usb/if_atu.c
===================================================================
RCS file: /cvs/openbsd/src/sys/dev/usb/if_atu.c,v
retrieving revision 1.125
diff -u -p -u -p -r1.125 if_atu.c
--- usb/if_atu.c        28 Apr 2018 14:49:07 -0000      1.125
+++ usb/if_atu.c        28 Apr 2018 15:17:23 -0000
@@ -1221,6 +1221,7 @@ atu_newstate(struct ieee80211com *ic, en
                        printf("%s: %s -> %s\n", ifp->if_xname,
                            ieee80211_state_name[ic->ic_state],
                            ieee80211_state_name[nstate]);
+               ieee80211_set_link_state(ic, LINK_STATE_DOWN);
                ic->ic_state = nstate;
                return (0);
 


-- 
Speer's 1st Law of Proofreading:
        The visibility of an error is inversely proportional to the
        number of times you have looked at it.

Reply via email to