75558faac79fe4f7a123aabbc5c18d39ca341034
[oweals/openwrt.git] / package / kernel / mac80211 / patches / subsys / 308-mac80211-Add-new-sta_info-getter-by-sta-vif-addrs.patch
1 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@redhat.com>
2 Date: Tue, 12 Nov 2019 14:08:35 +0100
3 Subject: [PATCH] mac80211: Add new sta_info getter by sta/vif addrs
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 In ieee80211_tx_status() we don't have an sdata struct when looking up the
9 destination sta. Instead, we just do a lookup by the vif addr that is the
10 source of the packet being completed. Factor this out into a new sta_info
11 getter helper, since we need to use it for accounting AQL as well.
12
13 Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
14 Link: https://lore.kernel.org/r/20191112130835.382062-1-toke@redhat.com
15 [remove internal rcu_read_lock(), document instead]
16 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
17 ---
18
19 --- a/net/mac80211/sta_info.c
20 +++ b/net/mac80211/sta_info.c
21 @@ -210,6 +210,20 @@ struct sta_info *sta_info_get_bss(struct
22         return NULL;
23  }
24  
25 +struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local,
26 +                                      const u8 *sta_addr, const u8 *vif_addr)
27 +{
28 +       struct rhlist_head *tmp;
29 +       struct sta_info *sta;
30 +
31 +       for_each_sta_info(local, sta_addr, sta, tmp) {
32 +               if (ether_addr_equal(vif_addr, sta->sdata->vif.addr))
33 +                       return sta;
34 +       }
35 +
36 +       return NULL;
37 +}
38 +
39  struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata,
40                                      int idx)
41  {
42 --- a/net/mac80211/sta_info.h
43 +++ b/net/mac80211/sta_info.h
44 @@ -725,6 +725,10 @@ struct sta_info *sta_info_get(struct iee
45  struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
46                                   const u8 *addr);
47  
48 +/* user must hold sta_mtx or be in RCU critical section */
49 +struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local,
50 +                                      const u8 *sta_addr, const u8 *vif_addr);
51 +
52  #define for_each_sta_info(local, _addr, _sta, _tmp)                    \
53         rhl_for_each_entry_rcu(_sta, _tmp,                              \
54                                sta_info_hash_lookup(local, _addr), hash_node)
55 --- a/net/mac80211/status.c
56 +++ b/net/mac80211/status.c
57 @@ -1086,19 +1086,13 @@ void ieee80211_tx_status(struct ieee8021
58                 .skb = skb,
59                 .info = IEEE80211_SKB_CB(skb),
60         };
61 -       struct rhlist_head *tmp;
62         struct sta_info *sta;
63  
64         rcu_read_lock();
65  
66 -       for_each_sta_info(local, hdr->addr1, sta, tmp) {
67 -               /* skip wrong virtual interface */
68 -               if (!ether_addr_equal(hdr->addr2, sta->sdata->vif.addr))
69 -                       continue;
70 -
71 +       sta = sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2);
72 +       if (sta)
73                 status.sta = &sta->sta;
74 -               break;
75 -       }
76  
77         __ieee80211_tx_status(hw, &status);
78         rcu_read_unlock();