image.mk: fix emitting profiles for targets that have no subtargets
[openwrt/staging/mkresin.git] / package / kernel / mac80211 / patches / 329-mac80211-Unify-mesh-and-mpp-path-removal-function.patch
1 From: Henning Rogge <hrogge@gmail.com>
2 Date: Wed, 3 Feb 2016 13:58:38 +0100
3 Subject: [PATCH] mac80211: Unify mesh and mpp path removal function
4
5 mpp_path_del() and mesh_path_del() are mostly the same function.
6 Move common code into a new static function.
7
8 Acked-by: Bob Copeland <me@bobcopeland.com>
9 Signed-off-by: Henning Rogge <henning.rogge@fkie.fraunhofer.de>
10 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 ---
12
13 --- a/net/mac80211/mesh_pathtbl.c
14 +++ b/net/mac80211/mesh_pathtbl.c
15 @@ -55,16 +55,21 @@ int mpp_paths_generation;
16 static DEFINE_RWLOCK(pathtbl_resize_lock);
17
18
19 +static inline struct mesh_table *resize_dereference_paths(
20 + struct mesh_table __rcu *table)
21 +{
22 + return rcu_dereference_protected(table,
23 + lockdep_is_held(&pathtbl_resize_lock));
24 +}
25 +
26 static inline struct mesh_table *resize_dereference_mesh_paths(void)
27 {
28 - return rcu_dereference_protected(mesh_paths,
29 - lockdep_is_held(&pathtbl_resize_lock));
30 + return resize_dereference_paths(mesh_paths);
31 }
32
33 static inline struct mesh_table *resize_dereference_mpp_paths(void)
34 {
35 - return rcu_dereference_protected(mpp_paths,
36 - lockdep_is_held(&pathtbl_resize_lock));
37 + return resize_dereference_paths(mpp_paths);
38 }
39
40 /*
41 @@ -899,14 +904,17 @@ void mesh_path_flush_by_iface(struct iee
42 }
43
44 /**
45 - * mesh_path_del - delete a mesh path from the table
46 + * table_path_del - delete a path from the mesh or mpp table
47 *
48 - * @addr: dst address (ETH_ALEN length)
49 + * @tbl: mesh or mpp path table
50 * @sdata: local subif
51 + * @addr: dst address (ETH_ALEN length)
52 *
53 * Returns: 0 if successful
54 */
55 -int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr)
56 +static int table_path_del(struct mesh_table __rcu *rcu_tbl,
57 + struct ieee80211_sub_if_data *sdata,
58 + const u8 *addr)
59 {
60 struct mesh_table *tbl;
61 struct mesh_path *mpath;
62 @@ -915,11 +923,7 @@ int mesh_path_del(struct ieee80211_sub_i
63 int hash_idx;
64 int err = 0;
65
66 - /* flush relevant mpp entries first */
67 - mpp_flush_by_proxy(sdata, addr);
68 -
69 - read_lock_bh(&pathtbl_resize_lock);
70 - tbl = resize_dereference_mesh_paths();
71 + tbl = resize_dereference_paths(rcu_tbl);
72 hash_idx = mesh_table_hash(addr, sdata, tbl);
73 bucket = &tbl->hash_buckets[hash_idx];
74
75 @@ -935,9 +939,30 @@ int mesh_path_del(struct ieee80211_sub_i
76
77 err = -ENXIO;
78 enddel:
79 - mesh_paths_generation++;
80 spin_unlock(&tbl->hashwlock[hash_idx]);
81 + return err;
82 +}
83 +
84 +/**
85 + * mesh_path_del - delete a mesh path from the table
86 + *
87 + * @addr: dst address (ETH_ALEN length)
88 + * @sdata: local subif
89 + *
90 + * Returns: 0 if successful
91 + */
92 +int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr)
93 +{
94 + int err = 0;
95 +
96 + /* flush relevant mpp entries first */
97 + mpp_flush_by_proxy(sdata, addr);
98 +
99 + read_lock_bh(&pathtbl_resize_lock);
100 + err = table_path_del(mesh_paths, sdata, addr);
101 + mesh_paths_generation++;
102 read_unlock_bh(&pathtbl_resize_lock);
103 +
104 return err;
105 }
106
107 @@ -951,33 +976,13 @@ enddel:
108 */
109 static int mpp_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr)
110 {
111 - struct mesh_table *tbl;
112 - struct mesh_path *mpath;
113 - struct mpath_node *node;
114 - struct hlist_head *bucket;
115 - int hash_idx;
116 int err = 0;
117
118 read_lock_bh(&pathtbl_resize_lock);
119 - tbl = resize_dereference_mpp_paths();
120 - hash_idx = mesh_table_hash(addr, sdata, tbl);
121 - bucket = &tbl->hash_buckets[hash_idx];
122 -
123 - spin_lock(&tbl->hashwlock[hash_idx]);
124 - hlist_for_each_entry(node, bucket, list) {
125 - mpath = node->mpath;
126 - if (mpath->sdata == sdata &&
127 - ether_addr_equal(addr, mpath->dst)) {
128 - __mesh_path_del(tbl, node);
129 - goto enddel;
130 - }
131 - }
132 -
133 - err = -ENXIO;
134 -enddel:
135 - mesh_paths_generation++;
136 - spin_unlock(&tbl->hashwlock[hash_idx]);
137 + err = table_path_del(mpp_paths, sdata, addr);
138 + mpp_paths_generation++;
139 read_unlock_bh(&pathtbl_resize_lock);
140 +
141 return err;
142 }
143