From 70f63609f64f8e976e4f6e305fbdf7a2f5f5a1cf Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 16 Sep 2022 19:19:24 +0200 Subject: [PATCH] ap: add explicit ifname for ssids of duplicate nets --- config/ap.nix | 16 ++++++++-------- nix/lib/config/options.nix | 4 ++++ nix/pkgs/openwrt/uci-config.nix | 11 +++++++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/config/ap.nix b/config/ap.nix index 04204d2..6cdb6fd 100644 --- a/config/ap.nix +++ b/config/ap.nix @@ -1159,7 +1159,7 @@ htmode = "VHT80"; ssids = { "ZW public" = { net = "pub"; encryption = "none"; }; - "Datenspuren" = { net = "pub"; encryption = "owe"; }; + "Datenspuren" = { net = "pub"; encryption = "owe"; ifname = "wlan5-owe"; }; "ZW stage" = { net = "priv25"; }; }; }; @@ -1197,7 +1197,7 @@ htmode = "VHT80"; ssids = { "ZW public" = { net = "pub"; encryption = "none"; }; - "Datenspuren" = { net = "pub"; encryption = "owe"; }; + "Datenspuren" = { net = "pub"; encryption = "owe"; ifname = "wlan5-owe"; }; "ZW stage" = { net = "priv25"; }; }; }; @@ -1238,7 +1238,7 @@ ssids = { EWW = { net = "priv36"; }; "ZW public" = { net = "pub"; encryption = "none"; }; - "Datenspuren" = { net = "pub"; encryption = "owe"; }; + "Datenspuren" = { net = "pub"; encryption = "owe"; ifname = "wlan5-owe"; }; "ZW stage" = { net = "priv25"; }; }; }; @@ -1276,7 +1276,7 @@ htmode = "VHT80"; ssids = { "ZW public" = { net = "pub"; encryption = "none"; }; - "Datenspuren" = { net = "pub"; encryption = "owe"; }; + "Datenspuren" = { net = "pub"; encryption = "owe"; ifname = "wlan5-owe"; }; "ZW stage" = { net = "priv25"; }; }; }; @@ -1314,7 +1314,7 @@ htmode = "VHT80"; ssids = { "ZW public" = { net = "pub"; encryption = "none"; }; - "Datenspuren" = { net = "pub"; encryption = "owe"; }; + "Datenspuren" = { net = "pub"; encryption = "owe"; ifname = "wlan5-owe"; }; "ZW stage" = { net = "priv25"; }; }; }; @@ -1352,7 +1352,7 @@ htmode = "VHT80"; ssids = { "ZW public" = { net = "pub"; encryption = "none"; }; - "Datenspuren" = { net = "pub"; encryption = "owe"; }; + "Datenspuren" = { net = "pub"; encryption = "owe"; ifname = "wlan5-owe"; }; "ZW stage" = { net = "priv25"; }; }; }; @@ -1424,7 +1424,7 @@ htmode = "VHT80"; ssids = { "ZW public" = { net = "pub"; encryption = "none"; }; - "Datenspuren" = { net = "pub"; encryption = "owe"; }; + "Datenspuren" = { net = "pub"; encryption = "owe"; ifname = "wlan5-owe"; }; "ZW stage" = { net = "priv25"; }; }; }; @@ -1502,7 +1502,7 @@ htmode = "VHT80"; ssids = { "ZW public" = { net = "pub"; encryption = "none"; }; - "Datenspuren" = { net = "pub"; encryption = "owe"; }; + "Datenspuren" = { net = "pub"; encryption = "owe"; ifname = "wlan5-owe"; }; "ZW stage" = { net = "priv25"; }; }; }; diff --git a/nix/lib/config/options.nix b/nix/lib/config/options.nix index a0ad19e..76d42a1 100644 --- a/nix/lib/config/options.nix +++ b/nix/lib/config/options.nix @@ -462,6 +462,10 @@ let type = enum [ "ap" "sta" ]; default = "ap"; }; + ifname = mkOption { + type = nullOr str; + default = null; + }; }; })); }; diff --git a/nix/pkgs/openwrt/uci-config.nix b/nix/pkgs/openwrt/uci-config.nix index 5c3735a..12799df 100644 --- a/nix/pkgs/openwrt/uci-config.nix +++ b/nix/pkgs/openwrt/uci-config.nix @@ -265,16 +265,23 @@ in ${concatMapStrings (ssid: let ssidConfig = radioConfig.ssids.${ssid}; + # mapping our option to openwrt/hostapd setting encryption = { none = "none"; owe = "owe"; wpa2 = "psk2"; wpa3 = "sae-mixed"; - }.${radioConfig.ssids.${ssid}.encryption}; + }.${ssidConfig.encryption}; + + ifname = + if ssidConfig.ifname != null + then ssidConfig.ifname + else "${ifPrefix}-${ssidConfig.net}"; + in '' uci add wireless wifi-iface - uci set wireless.@wifi-iface[-1].ifname=${ifPrefix}-${ssidConfig.net} + uci set wireless.@wifi-iface[-1].ifname=${ifname} uci set wireless.@wifi-iface[-1].device=radio${toString index} uci set wireless.@wifi-iface[-1].ssid='${ssid}' uci set wireless.@wifi-iface[-1].mode=${ssidConfig.mode}