[openwrt/openwrt] wifi-scripts: add option to set per-device ifname prefix

LEDE Commits lede-commits at lists.infradead.org
Wed Jan 15 12:56:07 PST 2025


nbd pushed a commit to openwrt/openwrt.git, branch openwrt-24.10:
https://git.openwrt.org/06340650c5d056dd542b6c8cbcfa87cb4f9d9b27

commit 06340650c5d056dd542b6c8cbcfa87cb4f9d9b27
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Wed Dec 4 11:59:14 2024 +0100

    wifi-scripts: add option to set per-device ifname prefix
    
    Simplifies setting ifname to a different pattern for all affected
    interfaces.
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
    (cherry picked from commit a9ff3ba24b9466d9c06b9a9e1c2e9672bdd9f6f9)
---
 .../wifi-scripts/files/lib/netifd/wireless/mac80211.sh     | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
index 368885246a..4bf452d2f6 100755
--- a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
+++ b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
@@ -29,6 +29,7 @@ drv_mac80211_init_device_config() {
 	config_add_string path phy 'macaddr:macaddr'
 	config_add_string tx_burst
 	config_add_string distance
+	config_add_string ifname_prefix
 	config_add_int radio beacon_int chanbw frag rts
 	config_add_int rxantenna txantenna txpower min_tx_power
 	config_add_int num_global_macaddr multiple_bssid
@@ -660,9 +661,9 @@ mac80211_check_ap() {
 }
 
 mac80211_set_ifname() {
-	local phy="$1"
-	local prefix="$2"
-	eval "ifname=\"$phy-$prefix\${idx_$prefix:-0}\"; idx_$prefix=\$((\${idx_$prefix:-0 } + 1))"
+	local prefix="$1"
+	local type="$2"
+	eval "ifname=\"$prefix$type\${idx_$type:-0}\"; idx_$type=\$((\${idx_$type:-0 } + 1))"
 }
 
 mac80211_prepare_vif() {
@@ -679,7 +680,7 @@ mac80211_prepare_vif() {
 		monitor) prefix=mon;;
 		esac
 
-		mac80211_set_ifname "$phy$vif_phy_suffix" "$prefix"
+		mac80211_set_ifname "$ifname_prefix" "$prefix"
 	}
 
 	append active_ifnames "$ifname"
@@ -1116,7 +1117,8 @@ drv_mac80211_setup() {
 		txpower \
 		rxantenna txantenna \
 		frag rts beacon_int:100 htmode \
-		num_global_macaddr:1 multiple_bssid
+		num_global_macaddr:1 multiple_bssid \
+		ifname_prefix
 	json_get_values basic_rate_list basic_rate
 	json_get_values scan_list scan_list
 	json_select ..
@@ -1135,6 +1137,8 @@ drv_mac80211_setup() {
 		return 1
 	}
 
+	set_default ifname_prefix "$phy$vif_phy_suffix-"
+
 	local wdev
 	local cwdev
 	local found




More information about the lede-commits mailing list