@@ -1468,17 +1468,7 @@ static void __ieee80211_assign_perm_addr(struct ieee80211_local *local,
return;
}
- /*
- * Pick address of existing interface in case user changed
- * MAC address manually, default to perm_addr.
- */
- m = local->hw.wiphy->perm_addr;
- list_for_each_entry(sdata, &local->interfaces, list) {
- if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
- continue;
- m = sdata->vif.addr;
- break;
- }
+ m = perm_addr;
start = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) |
((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
@@ -1529,6 +1519,15 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
mutex_lock(&local->iflist_mtx);
+ /* After manual mac change default addr may no longer fit into mask. */
+ if (!is_zero_ether_addr(local->hw.wiphy->addr_mask) &&
+ !list_empty(&local->interfaces)) {
+ sdata = list_first_entry(&local->interfaces,
+ struct ieee80211_sub_if_data,
+ list);
+ memcpy(perm_addr, sdata->vif.addr, ETH_ALEN);
+ }
+
switch (type) {
case NL80211_IFTYPE_MONITOR:
/* doesn't matter */