Skip to content

lime-system: detect radios on any bus in wireless.scandevices() - #18

Open
Pablomonte wants to merge 2 commits into
javierbrk:final-releasefrom
Pablomonte:fix/wireless-radio-detection-any-bus
Open

lime-system: detect radios on any bus in wireless.scandevices()#18
Pablomonte wants to merge 2 commits into
javierbrk:final-releasefrom
Pablomonte:fix/wireless-radio-detection-any-bus

Conversation

@Pablomonte

Copy link
Copy Markdown

scandevices() filters out radios whose hardware is missing by globbing
/sys/devices/<uci path>/ieee80211/phy*, but the path netifd stores in uci is relative to a
bus prefix that varies per target. On ramips/mt7621 (LibreRouter R2) the PCIe controller is a
platform device: uci holds 1e140000.pcie/pci0000:00/... while sysfs exposes
/sys/devices/platform/1e140000.pcie/.... The glob never matched, so the three ath9k radios of
a LibreRouter v1 card were all reported as hardware not found, lime-config generated no
wifi-iface and the radios stayed disabled.

Instead of guessing the prefix, resolve each phy under /sys/class/ieee80211 with realpath(3)
and match the uci path against it:

  • anchoring the match on <path>/ieee80211/ keeps a parent PCIe bridge from matching its child radio;
  • comparing literally instead of as a Lua pattern keeps the dots and colons of PCI paths from acting as wildcards;
  • the +N suffix netifd appends when several phys share one device (mt7915 DBDC) is handled too — the old glob missed it as well.

The check stays a strict superset of the previous one: /sys/devices is the canonical sysfs
tree with no internal symlinks, so realpath is the identity on an already real path and no
radio the old glob accepted can be lost. Stale radios are still rejected — that is what keeps
firstbootwizard from asking for a phy that does not exist and dying in get_phy_mac().

Tested on a LibreRouter R2 (LibreRouterOS 2025.10, kernel 6.6.121) with three ath9k radios: the
old glob matched none of the three uci paths, the new check resolves all of them to
phy0/phy1/phy2, and a stale radio path is still reported as missing.

Tests

The second commit fixes tests/test_lime_config_device.lua (#librerouter), which is already
red on final-release
for the same root cause: the fixture's sysfs paths do not exist in the
test container, so all three radios get filtered out and no mesh interface is generated.

final-release      325 successes / 1 failure
this branch        332 successes / 0 failures

Replaces #17, which was opened from the wrong head branch (Pablomonte:master, carrying two
unrelated lime-app commits) and against master instead of final-release.

Pablomonte and others added 2 commits August 4, 2026 17:11
scandevices() skips wifi-devices whose hardware is missing by globbing
/sys/devices/<uci path>/ieee80211/phy*, but the path netifd stores in uci is
relative to a bus prefix that varies per target. On ramips/mt7621 -- the SoC
of the LibreRouter R2 -- the PCIe controller is a platform device and uci
holds '1e140000.pcie/pci0000:00/...' while sysfs exposes
/sys/devices/platform/1e140000.pcie/..., so the glob never matched and every
ath9k radio of a LibreRouter v1 card was reported as 'hardware not found'.
lime-config then generated no wifi-iface at all and the three radios stayed
disabled.

Resolve the device path of each phy under /sys/class/ieee80211 with
realpath(3) and match the uci path against it instead of guessing the
prefix. Anchoring the match on '<path>/ieee80211/' keeps a parent PCIe
bridge from matching its child radio, and comparing literally rather than as
a Lua pattern keeps the dots and colons of PCI paths from acting as
wildcards. This also handles the '+N' suffix netifd appends when several
phys share one device (e.g. mt7915 DBDC), which the old glob missed too.

The check stays a strict superset of the previous one: sysfs /sys/devices is
the canonical tree with no internal symlinks, so realpath is the identity on
an already real path and no radio the old glob accepted can be lost. Stale
radios are still rejected, which is what keeps firstbootwizard from asking
for a phy that does not exist and dying in get_phy_mac().

Tested on a LibreRouter R2 (LibreRouterOs 2025.10, kernel 6.6.121) with
three ath9k radios: the old glob matched none of the three uci paths, the
new check resolves all of them to phy0/phy1/phy2, and a stale radio path is
still reported as missing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The #librerouter test feeds lime-config the wireless config OpenWrt
generates on a LibreRouter v1, whose three wifi-devices carry real sysfs
paths (platform/qca955x_wmac and two PCI ones). Those paths do not exist
inside the test container, so scandevices() correctly reports the radios as
missing hardware, no mesh interface is generated and the assertion on
lm_net_wlan1_mesh_babeld_dev fails.

This failure predates the previous commit: it appears on a clean checkout as
soon as scandevices() started filtering absent hardware. Fake the three phy
entries the fixture expects so the test exercises the device config it is
meant to cover.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant