[openwrt/openwrt] base-files: wifi: add random MAC support for wifi-iface
LEDE Commits
lede-commits at lists.infradead.org
Thu Aug 11 03:56:34 PDT 2022
aparcar pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/1ea563ae13637f55ec3a1a1056ba4f3595752a37
commit 1ea563ae13637f55ec3a1a1056ba4f3595752a37
Author: Manas Sambhus <manas.sambhus+github at gmail.com>
AuthorDate: Tue Aug 9 13:14:40 2022 +0530
base-files: wifi: add random MAC support for wifi-iface
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 at gmail.com>
---
package/kernel/mac80211/Makefile | 2 +-
package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
index afc10bdb5c..d467d20c61 100644
--- a/package/kernel/mac80211/Makefile
+++ b/package/kernel/mac80211/Makefile
@@ -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
diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
index 5d6ca7c0e3..62afd9e6a0 100644
--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
@@ -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"
More information about the lede-commits
mailing list