mac80211: Add new sta_info getter by sta/vif addrs
authorToke Høiland-Jørgensen <toke@redhat.com>
Tue, 12 Nov 2019 13:08:35 +0000 (14:08 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 22 Nov 2019 11:53:53 +0000 (12:53 +0100)
In ieee80211_tx_status() we don't have an sdata struct when looking up the
destination sta. Instead, we just do a lookup by the vif addr that is the
source of the packet being completed. Factor this out into a new sta_info
getter helper, since we need to use it for accounting AQL as well.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/r/20191112130835.382062-1-toke@redhat.com
[remove internal rcu_read_lock(), document instead]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/sta_info.c
net/mac80211/sta_info.h
net/mac80211/status.c

index 8d3a2389b055cfd970564ea995ed2a8877a7ba9e..41bf32080daca130ff6602daabb9c231434becce 100644 (file)
@@ -210,6 +210,20 @@ struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
        return NULL;
 }
 
+struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local,
+                                      const u8 *sta_addr, const u8 *vif_addr)
+{
+       struct rhlist_head *tmp;
+       struct sta_info *sta;
+
+       for_each_sta_info(local, sta_addr, sta, tmp) {
+               if (ether_addr_equal(vif_addr, sta->sdata->vif.addr))
+                       return sta;
+       }
+
+       return NULL;
+}
+
 struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata,
                                     int idx)
 {
index 369c2dddce528358351ec25bf9a5c8952e116fa8..0bd69a794758145f803bd876c6960cc79c9cbecf 100644 (file)
@@ -725,6 +725,10 @@ struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
 struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
                                  const u8 *addr);
 
+/* user must hold sta_mtx or be in RCU critical section */
+struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local,
+                                      const u8 *sta_addr, const u8 *vif_addr);
+
 #define for_each_sta_info(local, _addr, _sta, _tmp)                    \
        rhl_for_each_entry_rcu(_sta, _tmp,                              \
                               sta_info_hash_lookup(local, _addr), hash_node)
index ab8ba5835ca095220a73c97eeeae6705eb7b6780..0e51def35b8a7a7f234ad22525b0281887321042 100644 (file)
@@ -1073,19 +1073,13 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
                .skb = skb,
                .info = IEEE80211_SKB_CB(skb),
        };
-       struct rhlist_head *tmp;
        struct sta_info *sta;
 
        rcu_read_lock();
 
-       for_each_sta_info(local, hdr->addr1, sta, tmp) {
-               /* skip wrong virtual interface */
-               if (!ether_addr_equal(hdr->addr2, sta->sdata->vif.addr))
-                       continue;
-
+       sta = sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2);
+       if (sta)
                status.sta = &sta->sta;
-               break;
-       }
 
        __ieee80211_tx_status(hw, &status);
        rcu_read_unlock();