mac80211: fix MAC address allocations if the local bit is set on the base addr
authorFelix Fietkau <nbd@nbd.name>
Wed, 15 Jan 2020 12:54:28 +0000 (13:54 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 15 Jan 2020 14:36:26 +0000 (15:36 +0100)
If it's set, don't subtract 1 from the interface index encoded into the first
byte of the address

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh

index b0fc5fb37be3970801572bd1547e63ae2e8c0313..7ac0ce8aac2a1f4730bbae45681810c5dd2b6a98 100644 (file)
@@ -393,7 +393,7 @@ mac80211_generate_mac() {
        [ "$((0x$mask1))" -gt 0 ] && {
                b1="0x$1"
                [ "$id" -gt 0 ] && \
-                       b1=$(($b1 ^ ((($id - 1) << 2) | 0x2)))
+                       b1=$(($b1 ^ ((($id - !($b1 & 2)) << 2) | 0x2)))
                printf "%02x:%s:%s:%s:%s:%s" $b1 $2 $3 $4 $5 $6
                return
        }