ae5be18170a5b47baec5ad9d2fad809e9ca7882c
[oweals/openwrt.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sat, 16 Mar 2019 17:43:58 +0100
3 Subject: [PATCH] mac80211: mesh: drop redundant rcu_read_lock/unlock calls
4
5 The callers of these functions are all within RCU locked sections
6
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 ---
9
10 --- a/net/mac80211/mesh_hwmp.c
11 +++ b/net/mac80211/mesh_hwmp.c
12 @@ -1112,16 +1112,13 @@ int mesh_nexthop_resolve(struct ieee8021
13         struct mesh_path *mpath;
14         struct sk_buff *skb_to_free = NULL;
15         u8 *target_addr = hdr->addr3;
16 -       int err = 0;
17  
18         /* Nulls are only sent to peers for PS and should be pre-addressed */
19         if (ieee80211_is_qos_nullfunc(hdr->frame_control))
20                 return 0;
21  
22 -       rcu_read_lock();
23 -       err = mesh_nexthop_lookup(sdata, skb);
24 -       if (!err)
25 -               goto endlookup;
26 +       if (!mesh_nexthop_lookup(sdata, skb))
27 +               return 0;
28  
29         /* no nexthop found, start resolving */
30         mpath = mesh_path_lookup(sdata, target_addr);
31 @@ -1129,8 +1126,7 @@ int mesh_nexthop_resolve(struct ieee8021
32                 mpath = mesh_path_add(sdata, target_addr);
33                 if (IS_ERR(mpath)) {
34                         mesh_path_discard_frame(sdata, skb);
35 -                       err = PTR_ERR(mpath);
36 -                       goto endlookup;
37 +                       return PTR_ERR(mpath);
38                 }
39         }
40  
41 @@ -1143,13 +1139,10 @@ int mesh_nexthop_resolve(struct ieee8021
42         info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
43         ieee80211_set_qos_hdr(sdata, skb);
44         skb_queue_tail(&mpath->frame_queue, skb);
45 -       err = -ENOENT;
46         if (skb_to_free)
47                 mesh_path_discard_frame(sdata, skb_to_free);
48  
49 -endlookup:
50 -       rcu_read_unlock();
51 -       return err;
52 +       return -ENOENT;
53  }
54  
55  /**
56 @@ -1169,13 +1162,10 @@ int mesh_nexthop_lookup(struct ieee80211
57         struct sta_info *next_hop;
58         struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
59         u8 *target_addr = hdr->addr3;
60 -       int err = -ENOENT;
61  
62 -       rcu_read_lock();
63         mpath = mesh_path_lookup(sdata, target_addr);
64 -
65         if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE))
66 -               goto endlookup;
67 +               return -ENOENT;
68  
69         if (time_after(jiffies,
70                        mpath->exp_time -
71 @@ -1190,12 +1180,10 @@ int mesh_nexthop_lookup(struct ieee80211
72                 memcpy(hdr->addr1, next_hop->sta.addr, ETH_ALEN);
73                 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN);
74                 ieee80211_mps_set_frame_flags(sdata, next_hop, hdr);
75 -               err = 0;
76 +               return 0;
77         }
78  
79 -endlookup:
80 -       rcu_read_unlock();
81 -       return err;
82 +       return -ENOENT;
83  }
84  
85  void mesh_path_timer(struct timer_list *t)
86 --- a/net/mac80211/mesh_pathtbl.c
87 +++ b/net/mac80211/mesh_pathtbl.c
88 @@ -217,7 +217,7 @@ static struct mesh_path *mpath_lookup(st
89  {
90         struct mesh_path *mpath;
91  
92 -       mpath = rhashtable_lookup_fast(&tbl->rhead, dst, mesh_rht_params);
93 +       mpath = rhashtable_lookup(&tbl->rhead, dst, mesh_rht_params);
94  
95         if (mpath && mpath_expired(mpath)) {
96                 spin_lock_bh(&mpath->state_lock);