From 1f86f4e471f81038a9b69a4f121a55637634c7cf Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 19 Apr 2026 22:26:59 +0200 Subject: [PATCH] wifi-scripts: ucode: simplify wpa_pairwise default selection parse_encryption() stashed a preliminary wpa_pairwise value in a local wpa3_pairwise variable, cleared it per auth_type, then let a switch default either copy it back or special-case wpa3-192. The result was three separate places where wpa_pairwise was clobbered and behavior that was awkward to trace when the explicit cipher suffix (encryption[1]) and the auth_type disagreed. Replace the scaffolding with a single block at the end of parse_encryption() that only assigns wpa_pairwise via ??= when no earlier branch (explicit cipher suffix, wpa3-192, or sae-compat) has already set one: no WPA -> null 60 GHz (hw_mode=ad) -> GCMP HE or EHT htmode -> GCMP-256 CCMP everything else -> CCMP wpa3-192 now sets wpa_pairwise='GCMP-256' directly in its switch case, so the final default block can stay short. No functional change for existing encryption values. Co-Authored-By: Claude Opus 4.7 Link: https://github.com/openwrt/openwrt/pull/23009 Signed-off-by: Hauke Mehrtens --- .../files-ucode/usr/share/ucode/wifi/iface.uc | 36 +++++-------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/iface.uc b/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/iface.uc index a65577f1a2..4f718327f0 100644 --- a/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/iface.uc +++ b/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/wifi/iface.uc @@ -17,16 +17,8 @@ export function parse_encryption(config, dev_config) { break; } - config.wpa_pairwise = null; - if (config.wpa) - config.wpa_pairwise = (config.hw_mode == 'ad') ? 'GCMP' : 'CCMP'; - config.auth_type = encryption[0] ?? 'none'; - let wpa3_pairwise = config.wpa_pairwise; - if (wildcard(dev_config?.htmode, 'EHT*') || wildcard(dev_config?.htmode, 'HE*')) - wpa3_pairwise = 'GCMP-256 ' + wpa3_pairwise; - switch(config.auth_type) { case 'owe': config.auth_type = 'owe'; @@ -38,6 +30,7 @@ export function parse_encryption(config, dev_config) { case 'wpa3-192': config.auth_type = 'eap192'; + config.wpa_pairwise = 'GCMP-256'; break; case 'wpa3-mixed': @@ -52,7 +45,6 @@ export function parse_encryption(config, dev_config) { case 'psk2': case 'psk-mixed': config.auth_type = 'psk'; - wpa3_pairwise = null; break; case 'sae': @@ -69,12 +61,6 @@ export function parse_encryption(config, dev_config) { case 'wpa2': case 'wpa-mixed': config.auth_type = 'eap'; - wpa3_pairwise = null; - break; - - default: - config.wpa_pairwise = null; - wpa3_pairwise = null; break; } @@ -106,20 +92,16 @@ export function parse_encryption(config, dev_config) { case 'gcmp': config.wpa_pairwise = 'GCMP'; break; - - default: - if (config.encryption == 'wpa3-192') { - config.wpa_pairwise = 'GCMP-256'; - break; - } - - if (!wpa3_pairwise) - break; - - config.wpa_pairwise = wpa3_pairwise; - break; } + if (!config.wpa) + config.wpa_pairwise ??= null; + else if (config.hw_mode == 'ad') + config.wpa_pairwise ??= 'GCMP'; + else if (wildcard(dev_config?.htmode, 'EHT*') || wildcard(dev_config?.htmode, 'HE*')) + config.wpa_pairwise ??= 'GCMP-256 CCMP'; + else + config.wpa_pairwise ??= 'CCMP'; }; export function wpa_key_mgmt(config) {