wifi-scripts: txpower 0 treated as auto in ucode mac80211.sh — router transmits at maximum power
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 28.5k
- Forks
- 13k
- PR merge metrics
- PR metrics pending
Description
Describe the bug
When setting option txpower '0' in /etc/config/wireless, the router ignores the value and transmits at maximum power. The bug is in the ucode version of mac80211.sh — txpower 0 is falsy in ucode/JavaScript, causing the script to set txpower to auto instead of fixed 000. The old shell version correctly handles 0 using [ -n "$txpower" ]. The bug was introduced during migration to ucode.
OpenWrt version
r32802-f505120278
OpenWrt release
25.12.2
OpenWrt target/subtarget
Multiple targets affected: mediatek/filogic, ath79/generic, ath79/generic (ipq40xx)
Device
Multiple devices affected — see additional info
Image kind
Official downloaded image
Steps to reproduce
uci set wireless.radio1.txpower='0'
uci commit wireless
wifi reload
iwinfo phy1-ap0 info | grep Tx-Power
Actual behaviour
Tx-Power: 23 dBm — maximum power despite txpower=0
Expected behaviour
Tx-Power: 0 dBm — or minimum supported by hardware
Additional info
Root cause:
In package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh:
Bug — 0 is falsy in ucode, jumps to auto:
if (config.txpower)
config.txpower = 'fixed ' + config.txpower + '00';
else
config.txpower = 'auto';
Fix — explicit null check:
if (config.txpower != null)
config.txpower = 'fixed ' + config.txpower + '00';
else
config.txpower = 'auto';
Note: The old shell version uses [ -n "$txpower" ] which correctly handles 0.
The bug was introduced during migration to ucode.
Confirmed active version is ucode:
cat /lib/netifd/wireless/mac80211.sh | head -5
#!/usr/bin/ucode
'use strict';
import { set_default, log } from 'wifi.common';
Proof — direct iw command works correctly:
iw phy phy1 set txpower fixed 0
iwinfo phy1-ap0 info | grep Tx-Power
Tx-Power: 0 dBm
The kernel driver accepts 0 dBm correctly — the bug is in the ucode script, not the kernel driver.
Proof — after wifi reload, txpower is absent from configuration line:
netifd: radio1 (12995): wifi-scripts: Configuring 'phy1' txantenna: 4294967295, rxantenna: 4294967295 distance: 0
txpower is absent — confirming it was set to auto instead of fixed 000.
Also note:
netifd: radio1 (4936): command failed: Not supported (-95)
This error appears because the ucode script attempts to set txpower auto on a phy that does not support it.
Tested on five devices with three different chipsets, all running OpenWrt 25.12.2:
Device | Chipset | txpower=1 | txpower=0
Cudy WR3000S v1 | MediaTek Filogic | 1 dBm | 23 dBm
Buffalo WZR-600DHP | Atheros AR7161 | 3 dBm | 15 dBm
OpenWrt One | MediaTek Filogic | 1 dBm | 23 dBm
TP-Link Archer C7 v2 | Qualcomm Atheros QCA9558 | 5 dBm | 25 dBm
GL.iNet GL-MT6000 | MediaTek Filogic | 1 dBm | 23 dBm
All devices show identical behavior — this is not chipset specific.
Physical verification:
At txpower=0: -51 dBm measured by nearby router
At txpower=1: -72 dBm measured by nearby router
The 21 dBm difference confirms the router is transmitting at maximum power when txpower=0 is set.
UCI stores the value correctly:
uci show wireless.radio1
wireless.radio1.txpower='0'
UCI correctly stores and returns the value — the bug is exclusively in the ucode script.
Related issue in openwrt/luci: https://github.com/openwrt/luci/issues/8177
Diffconfig
Not applicable — official image
Terms
- I am reporting an issue for OpenWrt, not an unsupported fork.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh and inspect the txpower handling described in the issue. Reproduce with the provided UCI, wifi reload, and iwinfo commands on an affected device. Done means txpower='0' is passed as fixed 000 rather than auto and the reported power is 0 dBm or the hardware minimum.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 67/100