diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-11-19 20:17:08 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-11-19 20:17:08 +0000 |
commit | ec132f29de6ef20d86b88dc968ffedd91ede8fba (patch) | |
tree | 98e24870a888e5c397f1d29e51227b97ea2b6e9d | |
parent | 027cc6721a6b3e60eaf7ba9829e2143bf956b70d (diff) | |
download | master-187ad058-ec132f29de6ef20d86b88dc968ffedd91ede8fba.tar.gz master-187ad058-ec132f29de6ef20d86b88dc968ffedd91ede8fba.tar.bz2 master-187ad058-ec132f29de6ef20d86b88dc968ffedd91ede8fba.zip |
mac80211: try to get interface addresses from wiphy sysfs 'addresses' if no mask is set
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@43326 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r-- | package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh index 918955a98a..d8fa07e225 100644 --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh @@ -326,6 +326,13 @@ ${max_listen_int:+max_listen_interval=$max_listen_int} EOF } +mac80211_get_addr() { + local phy="$1" + local idx="$(($2 + 1))" + + head -n $(($macidx + 1)) /sys/class/ieee80211/${phy}/addresses | tail -n1 +} + mac80211_generate_mac() { local phy="$1" local id="${macidx:-0}" @@ -333,7 +340,18 @@ mac80211_generate_mac() { local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)" local mask="$(cat /sys/class/ieee80211/${phy}/address_mask)" - [ "$mask" = "00:00:00:00:00:00" ] && mask="ff:ff:ff:ff:ff:ff"; + [ "$mask" = "00:00:00:00:00:00" ] && { + mask="ff:ff:ff:ff:ff:ff"; + + [ "$(wc -l < /sys/class/ieee80211/${phy}/addresses)" -gt 1 ] && { + addr="$(mac80211_get_addr "$phy" "$id")" + [ -n "$addr" ] && { + echo "$addr" + return + } + } + } + local oIFS="$IFS"; IFS=":"; set -- $mask; IFS="$oIFS" local mask1=$1 |