From 4c413454890ac487985a3e15f812a7c828aa4617 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Thu, 25 Jun 2026 00:01:03 +0200 Subject: [PATCH] fix: push_radio_channel uses 'wifi' (full restart) instead of 'wifi reload' 'wifi reload' only reapplies the running config without physically changing the channel on many ath9k/ath10k/mt76 hardware+driver combinations. A full 'wifi' (down + up) cycle is required for channel changes to take effect. Also updated the test assertion accordingly. Co-Authored-By: Claude Sonnet 4.6 --- napalm_openwrt/wireless_mixin.py | 9 +++++++-- tests/unit/test_driver.py | 14 ++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/napalm_openwrt/wireless_mixin.py b/napalm_openwrt/wireless_mixin.py index 2c508b2..18faa62 100644 --- a/napalm_openwrt/wireless_mixin.py +++ b/napalm_openwrt/wireless_mixin.py @@ -528,7 +528,12 @@ class OpenWrtWirelessMixin: return entries def push_radio_channel(self, radio: str, channel: int) -> None: - """Set a new channel on *radio* via UCI and reload the wireless stack. + """Set a new channel on *radio* via UCI and restart the wireless stack. + + Uses ``wifi`` (full down/up cycle) rather than ``wifi reload``. + ``wifi reload`` only re-applies the running config without changing + the physical channel on many hardware/driver combinations; a full + restart is required for channel changes to take effect. :param radio: UCI radio name, e.g. ``"radio0"``. :param channel: Channel number to set; ``0`` sets UCI ``auto``. @@ -536,7 +541,7 @@ class OpenWrtWirelessMixin: ch_val = "auto" if channel == 0 else str(channel) self._send_command(f"uci set wireless.{radio}.channel={ch_val}") self._send_command("uci commit wireless") - self._send_command("wifi reload") + self._send_command("wifi") def get_radio_status(self) -> dict[str, Any]: """Return radio status from UCI and iwinfo. diff --git a/tests/unit/test_driver.py b/tests/unit/test_driver.py index fe3869c..899b390 100644 --- a/tests/unit/test_driver.py +++ b/tests/unit/test_driver.py @@ -1076,11 +1076,13 @@ class TestPushRadioChannel: driver.push_radio_channel("radio0", 11) assert any("uci commit wireless" in c for c in issued) - def test_issues_wifi_reload(self, driver): + def test_issues_wifi_restart(self, driver): + """Must call 'wifi' (full restart) — NOT just 'wifi reload'.""" issued: list[str] = [] driver._send_command = lambda cmd, **kw: issued.append(cmd) or "" driver.push_radio_channel("radio1", 36) - assert any("wifi reload" in c for c in issued) + # 'wifi' alone is a full restart; 'wifi reload' is insufficient for channel changes + assert any(c.strip() == "wifi" for c in issued) def test_auto_channel_zero(self, driver): """channel=0 should set 'auto' in UCI.""" @@ -1089,11 +1091,11 @@ class TestPushRadioChannel: driver.push_radio_channel("radio0", 0) assert any("channel=auto" in c or "channel='auto'" in c for c in issued) - def test_commit_before_reload(self, driver): - """UCI commit must happen before wifi reload.""" + def test_commit_before_restart(self, driver): + """UCI commit must happen before wifi restart.""" issued: list[str] = [] driver._send_command = lambda cmd, **kw: issued.append(cmd) or "" driver.push_radio_channel("radio0", 6) commit_idx = next(i for i, c in enumerate(issued) if "commit" in c) - reload_idx = next(i for i, c in enumerate(issued) if "wifi reload" in c) - assert commit_idx < reload_idx + wifi_idx = next(i for i, c in enumerate(issued) if c.strip() == "wifi") + assert commit_idx < wifi_idx