As rt2800 hw can only be configured to mask the last three bits of the
programmed MAC addresses, we can't change first byte of the MAC - otherwise it
doesn't work. More information about this issue [1].

Should fix #12133.

1. http://marc.info/?l=linux-wireless&m=135387062429809&w=2

Thanks to Paul Fertser and Helmut Schaa.

Signed-off-by: Petr Štetiar <yn...@true.cz>
---
 package/mac80211/files/lib/wifi/mac80211.sh |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/package/mac80211/files/lib/wifi/mac80211.sh 
b/package/mac80211/files/lib/wifi/mac80211.sh
index 1b0bea7..752325e 100644
--- a/package/mac80211/files/lib/wifi/mac80211.sh
+++ b/package/mac80211/files/lib/wifi/mac80211.sh
@@ -272,13 +272,28 @@ get_freq() {
        iw "$phy" info | grep -E -m1 "(\* ${chan:-....} 
MHz${chan:+|\\[$chan\\]})" | grep MHz | awk '{print $2}'
 }
 
+is_not_rt2800() {
+       local phy="$1"
+       local drvname="$(readlink /sys/class/ieee80211/$phy/device/driver)"
+       drvname="${drvname##*/}"
+
+       case "$drvname" in
+       *"rt2800_wmac")
+               return 1
+               ;;
+       esac
+
+       return 0
+}
+
 mac80211_generate_mac() {
        local off="$1"
        local mac="$2"
+       local phy="$3"
        local oIFS="$IFS"; IFS=":"; set -- $mac; IFS="$oIFS"
 
        local b2mask=0x00
-       [ $off -gt 0 ] && b2mask=0x02
+       [ $off -gt 0 ] && is_not_rt2800 "$phy" && b2mask=0x02
 
        printf "%02x:%s:%s:%s:%02x:%02x" \
                $(( 0x$1 | $b2mask )) $2 $3 $4 \
@@ -378,7 +393,7 @@ enable_mac80211() {
                config_get macaddr "$device" macaddr
                config_get vif_mac "$vif" macaddr
                [ -n "$vif_mac" ] || {
-                       vif_mac="$(mac80211_generate_mac $macidx $macaddr)"
+                       vif_mac="$(mac80211_generate_mac $macidx $macaddr $phy)"
                        macidx="$(($macidx + 1))"
                }
                [ "$mode" = "ap" ] || ifconfig "$ifname" hw ether "$vif_mac"
-- 
1.7.9.5

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to