nl80211: properly handle netdev names starting with "radio"
authorJo-Philipp Wich <jo@mein.io>
Tue, 26 Nov 2019 07:39:23 +0000 (08:39 +0100)
committerDavid Bauer <mail@david-bauer.net>
Fri, 27 Dec 2019 12:32:03 +0000 (13:32 +0100)
This fixes VAPs not being queried correctly when the netdev name starts
with "radio".

Fixes: FS#2629

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: David Bauer <mail@david-bauer.net>
iwinfo_nl80211.c

index 4b6ef9124e66c6705b9ba356e8f2d8456b18f12a..5990c782184063483d7fc0512a45b6c84c071e74 100644 (file)
@@ -367,7 +367,8 @@ static struct nl80211_msg_conveyor * nl80211_msg(const char *ifname,
                phyidx = atoi(&ifname[3]);
        else if (!strncmp(ifname, "radio", 5))
                phyidx = nl80211_phy_idx_from_uci(ifname);
-       else if (!strncmp(ifname, "mon.", 4))
+
+       if (!strncmp(ifname, "mon.", 4))
                ifidx = if_nametoindex(&ifname[4]);
        else
                ifidx = if_nametoindex(ifname);
@@ -380,10 +381,9 @@ static struct nl80211_msg_conveyor * nl80211_msg(const char *ifname,
        if (!cv)
                return NULL;
 
-       if (ifidx > -1)
+       if (ifidx > 0)
                NLA_PUT_U32(cv->msg, NL80211_ATTR_IFINDEX, ifidx);
-
-       if (phyidx > -1)
+       else if (phyidx > -1)
                NLA_PUT_U32(cv->msg, NL80211_ATTR_WIPHY, phyidx);
 
        return cv;