Skip to content

Commit

Permalink
nl80211: handle per_sta_vif case properly
Browse files Browse the repository at this point in the history
When per_sta_vif is enabled in hostapd BSS config, we need to iterate
through every interface in /sys/class/net which matches
`${interface_requested}.${number}`. Otherwise data we get will be
incomplete, similar cases are already handled for WDS so there is
precedence for this.

Closes openwrt/openwrt#14339

Signed-off-by: Rany Hany <[email protected]>
  • Loading branch information
rany2 committed Jan 5, 2024
1 parent a34977c commit 4248759
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions iwinfo_nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ static int nl80211_readstr(const char *path, char *buffer, int length)
return rv;
}

static bool nl80211_is_numeric(const char *str)
{
return strlen(str) > 0 && strspn(str, "0123456789") == strlen(str);
}

static int nl80211_get_band(int nla_type)
{
switch (nla_type)
Expand Down Expand Up @@ -1617,7 +1622,9 @@ static void nl80211_fill_signal(const char *ifname, struct nl80211_rssi_rate *r)
{
if (!strncmp(de->d_name, ifname, strlen(ifname)) &&
(!de->d_name[strlen(ifname)] ||
!strncmp(&de->d_name[strlen(ifname)], ".sta", 4)))
!strncmp(&de->d_name[strlen(ifname)], ".sta", 4) ||
(de->d_name[strlen(ifname)] == '.' &&
nl80211_is_numeric(&de->d_name[strlen(ifname) + 1]))))
{
nl80211_request(de->d_name, NL80211_CMD_GET_STATION,
NLM_F_DUMP, nl80211_fill_signal_cb, r);
Expand Down Expand Up @@ -2391,7 +2398,9 @@ static int nl80211_get_assoclist(const char *ifname, char *buf, int *len)
{
if (!strncmp(de->d_name, ifname, strlen(ifname)) &&
(!de->d_name[strlen(ifname)] ||
!strncmp(&de->d_name[strlen(ifname)], ".sta", 4)))
!strncmp(&de->d_name[strlen(ifname)], ".sta", 4) ||
(de->d_name[strlen(ifname)] == '.' &&
nl80211_is_numeric(&de->d_name[strlen(ifname) + 1]))))
{
nl80211_request(de->d_name, NL80211_CMD_GET_STATION,
NLM_F_DUMP, nl80211_get_assoclist_cb, &arr);
Expand Down

0 comments on commit 4248759

Please sign in to comment.