[PATCH iwinfo] nl80211: restore iterating over all devices in nl80211_phy2ifname()
Andre Heider
a.heider at gmail.com
Mon Jan 30 10:57:57 PST 2023
This reverts to the earlier behaviour, because:
* phys can be renamed, which breaks hardcoding "phy%d"
* /sys/class/ieee80211/*/device can return networks of other phys,
since "device" is a symlink which can have multiple phys
The earlier behaviour fixes both points.
Fixes: 6194aaf0 "nl80211: simplify iterating over phy's devices"
Fixes: #11902
Signed-off-by: Andre Heider <a.heider at gmail.com>
Tested-by: Olcay Korkmaz <nuke_mania at hotmail.com>
---
iwinfo_nl80211.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c
index 5bc2f51..50bb8f0 100644
--- a/iwinfo_nl80211.c
+++ b/iwinfo_nl80211.c
@@ -825,13 +825,15 @@ static char * nl80211_phy2ifname(const char *ifname)
memset(nif, 0, sizeof(nif));
- snprintf(buffer, sizeof(buffer),
- "/sys/class/ieee80211/phy%d/device/net", phyidx);
-
- if ((d = opendir(buffer)) != NULL)
+ if ((d = opendir("/sys/class/net")) != NULL)
{
while ((e = readdir(d)) != NULL)
{
+ snprintf(buffer, sizeof(buffer),
+ "/sys/class/net/%s/phy80211/index", e->d_name);
+ if (nl80211_readint(buffer) != phyidx)
+ continue;
+
snprintf(buffer, sizeof(buffer),
"/sys/class/net/%s/ifindex", e->d_name);
cifidx = nl80211_readint(buffer);
--
2.39.0
More information about the openwrt-devel
mailing list