base-files: wifi: add random MAC support for wifi-iface
authorManas Sambhus <manas.sambhus+github@gmail.com>
Tue, 9 Aug 2022 07:44:40 +0000 (13:14 +0530)
committerPaul Spooren <mail@aparcar.org>
Thu, 11 Aug 2022 10:56:15 +0000 (12:56 +0200)
Add support for randomly generating a MAC address for a wifi-iface
instance by setting `macaddr` to `random`
When set to `random`, a new locally administered unicast MAC address
is generated and assigned to the iface everytime it is (re-)configured

Signed-off-by: Manas Sambhus <manas.sambhus+github@gmail.com>
package/kernel/mac80211/Makefile
package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh

index afc10bdb5c99bdb1ad8cc89613ff8bd1e1253fce..d467d20c61147f81d249273d494ddd69872d1fbc 100644 (file)
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
 PKG_NAME:=mac80211
 
 PKG_VERSION:=5.15.58-1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v5.15.58/
 PKG_HASH:=a3c2a2b7bbaf8943c65fd72f4e7d7ad5e205aeae28b26c835f9d8afa0f9810bf
 
index 5d6ca7c0e311860f59532aaa6998ad3243aa15ba..62afd9e6a0fb6c4b047432ac8b1e8b97e42fc72b 100644 (file)
@@ -1,6 +1,7 @@
 #!/bin/sh
 . /lib/netifd/netifd-wireless.sh
 . /lib/netifd/hostapd.sh
+. /lib/functions/system.sh
 
 init_wireless_driver "$@"
 
@@ -667,10 +668,12 @@ mac80211_prepare_vif() {
 
        json_select ..
 
-       [ -n "$macaddr" ] || {
+       if [ -z "$macaddr" ]; then
                macaddr="$(mac80211_generate_mac $phy)"
                macidx="$(($macidx + 1))"
-       }
+       elif [ "$macaddr" = 'random' ]; then
+               macaddr="$(macaddr_random)"
+       fi
 
        json_add_object data
        json_add_string ifname "$ifname"