fix: gate channel_band 6GHz to 181-233, reject open-6GHz, self-heal load-time 6GHz hints, harden hop/BSSID handling

This commit is contained in:
2026-08-18 08:30:45 -05:00
parent c0b9e58aa8
commit af5ff8039b
3 changed files with 63 additions and 10 deletions
@@ -1607,6 +1607,9 @@ DFS_CHANNELS = frozenset([52, 56, 60, 64, 100, 104, 108, 112, 116, 120,
124, 128, 132, 136, 140, 144])
_last_reconcile = 0.0
def channel_band(ch):
if ch is None:
return None
@@ -1618,7 +1621,7 @@ def channel_band(ch):
return BAND_2G
if 36 <= ch <= 177:
return BAND_5G
if 1 <= ch <= 233 and (ch - 1) % 4 == 0:
if 177 < ch <= 233 and (ch - 1) % 4 == 0:
return BAND_6G
return None
@@ -1646,6 +1649,8 @@ def _uci_section(section):
def h_pineap_wifi_get_ap(ctx):
global _last_reconcile
def _iface_state(open_name, wpa_name, radio_name):
open_cfg = _uci_wifi_iface(open_name)
wpa_cfg = _uci_wifi_iface(wpa_name)
@@ -1685,7 +1690,9 @@ def h_pineap_wifi_get_ap(ctx):
for name in ('wlan1open', 'wlan1wpa'):
cfg = _uci_wifi_iface(name)
if cfg and cfg.get('disabled') != '1' and not os.path.exists('/sys/class/net/%s' % name):
device_run(['wifi', 'reload'])
if time.time() - _last_reconcile > 30:
_last_reconcile = time.time()
device_run(['wifi', 'reload'])
break
return 200, {
'open': {
@@ -1746,6 +1753,8 @@ def _open_channel(value):
def _read_hop():
rc, out, err = device_run(['uci', 'get', 'pineapd.wlan1mon.hop'])
if rc != 0:
return None
return out.strip()
@@ -1782,6 +1791,8 @@ def _apply_radio1_ap(openap, wpa):
iface = 'wlan1wpa'
if band not in (BAND_5G, BAND_6G):
raise ValueError('radio1 AP requires a 5GHz or 6GHz channel')
if band == BAND_6G and wpa is None:
raise ValueError('6GHz open APs are not supported (6GHz requires WPA3/OWE)')
if band == BAND_6G and wpa is not None:
if (wpa.get('enctype') or 'psk2') not in ('sae', 'owe'):
raise ValueError('6GHz requires WPA3 (sae or owe)')
@@ -1810,7 +1821,9 @@ def _apply_radio1_ap(openap, wpa):
device_run(['uci', 'set', 'wireless.%s.encryption=none' % iface])
bssid = (openap or {}).get('bssid') or ''
if bssid:
device_run(['uci', 'set', 'wireless.%s.macaddr=%s' % (iface, bssid)])
if not re.match(r'^[0-9A-F]{2}(?::[0-9A-F]{2}){5}$', bssid.upper()):
raise ValueError('invalid BSSID format')
device_run(['uci', 'set', 'wireless.%s.macaddr=%s' % (iface, bssid.upper())])
device_run(['uci', 'commit', 'wireless'])
_pause_hop()
device_run(['wifi', 'reload'])