From: Felix Fietkau Date: Wed, 4 Dec 2024 10:59:14 +0000 (+0100) Subject: wifi-scripts: add option to set per-device ifname prefix X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=a9ff3ba24b9466d9c06b9a9e1c2e9672bdd9f6f9;p=openwrt%2Fstaging%2Fblocktrron.git 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 --- diff --git a/package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh b/package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh index fe364b8f48..8b55d01e7a 100755 --- a/package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh +++ b/package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh @@ -210,6 +210,9 @@ function setup() { } data.phy_suffix = phy_suffix(data.config.radio, ":"); data.vif_phy_suffix = phy_suffix(data.config.radio, "."); + data.ifname_prefix = data.config.ifname_prefix; + if (!data.ifname_prefix) + data.ifname_prefix = data.phy + data.vif_phy_suffix + "-"; let active_ifnames = []; log('Starting'); @@ -229,12 +232,12 @@ function setup() { let mode_idx = idx[mode]++; if (!v.config.ifname) - v.config.ifname = data.phy + data.vif_phy_suffix + "-" + mode + mode_idx; + v.config.ifname = data.ifname_prefix + mode + mode_idx; push(active_ifnames, v.config.ifname); if (v.config.encryption == 'owe' && v.config.owe_transition) { mode_idx = idx[mode]++; - v.config.owe_transition_ifname = data.phy + data.vif_phy_suffix + "-" + mode + mode_idx; + v.config.owe_transition_ifname = data.ifname_prefix + mode + mode_idx; push(active_ifnames, v.config.ifname); } diff --git a/package/network/config/wifi-scripts/files-ucode/usr/share/schema/wireless.wifi-device.json b/package/network/config/wifi-scripts/files-ucode/usr/share/schema/wireless.wifi-device.json index 9a7e777b63..0588401c99 100644 --- a/package/network/config/wifi-scripts/files-ucode/usr/share/schema/wireless.wifi-device.json +++ b/package/network/config/wifi-scripts/files-ucode/usr/share/schema/wireless.wifi-device.json @@ -396,6 +396,10 @@ "type": "alias", "default": "assoc_sa_query_retry_timeout" }, + "ifname_prefix": { + "description": "Default ifname prefix for this radio", + "type": "string" + }, "iface_max_num_sta": { "description": "Limits the maximum allowed number of associated clients", "type": "number" 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 3d953eff74..f65128783f 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" @@ -1105,7 +1106,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 .. @@ -1124,6 +1126,8 @@ drv_mac80211_setup() { return 1 } + set_default ifname_prefix "$phy$vif_phy_suffix-" + local wdev local cwdev local found