Index: sys/dev/ath/if_ath.c =================================================================== --- sys/dev/ath/if_ath.c (revision 307150) +++ sys/dev/ath/if_ath.c (working copy) @@ -1466,14 +1466,31 @@ struct ath_vap *avp; struct ieee80211vap *vap; uint8_t mac[IEEE80211_ADDR_LEN]; - int needbeacon, error; + int needbeacon, setmacaddr, error; enum ieee80211_opmode ic_opmode; avp = malloc(sizeof(struct ath_vap), M_80211_VAP, M_WAITOK | M_ZERO); needbeacon = 0; - IEEE80211_ADDR_COPY(mac, mac0); + setmacaddr = 0; ATH_LOCK(sc); + ath_hal_getmac(sc->sc_ah, mac); + if ((flags & IEEE80211_CLONE_MACADDR) != 0 && + !IEEE80211_ADDR_EQ(mac, mac0)) { + if (sc->sc_nvaps != 0) { + device_printf(sc->sc_dev, + "MAC address change request will be ignored\n"); + /* XXX goto bad? */ + } else { + /* + * NB: delay MAC address change in case + * if vap setup fails + */ + IEEE80211_ADDR_COPY(mac, mac0); + setmacaddr = 1; + } + } + ic_opmode = opmode; /* default to opmode of new vap */ switch (opmode) { case IEEE80211_M_STA: @@ -1700,6 +1717,8 @@ */ sc->sc_swbmiss = 1; } + if (setmacaddr) + ath_hal_setmac(sc->sc_ah, mac0); ATH_UNLOCK(sc); /* complete setup */