aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDaniele Furlan <daniele.furlan@gmail.com>2011-05-07 16:45:19 -0400
committerSven Eckelmann <sven@narfation.org>2011-05-08 10:10:42 -0400
commit27aea2128ec09924dfe08e97739b2bf8b15c8619 (patch)
tree5b8c7435c40bf7e323a9582423d00647cf06b0a8 /net
parent6e215fd8eb4930373d01da0fac16a0889804fac3 (diff)
batman-adv: remove duplicate code from function is_bidirectional_neigh()
In function is_bidirectional_neigh the code that find out the one hop neighbor is duplicated. Signed-off-by: Daniele Furlan <daniele.furlan@gmail.com> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/routing.c74
1 files changed, 25 insertions, 49 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 7648b92aec47..bb1c3ec7e3ff 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -169,65 +169,41 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
169 uint8_t orig_eq_count, neigh_rq_count, tq_own; 169 uint8_t orig_eq_count, neigh_rq_count, tq_own;
170 int tq_asym_penalty, ret = 0; 170 int tq_asym_penalty, ret = 0;
171 171
172 if (orig_node == orig_neigh_node) { 172 /* find corresponding one hop neighbor */
173 rcu_read_lock(); 173 rcu_read_lock();
174 hlist_for_each_entry_rcu(tmp_neigh_node, node, 174 hlist_for_each_entry_rcu(tmp_neigh_node, node,
175 &orig_node->neigh_list, list) { 175 &orig_neigh_node->neigh_list, list) {
176
177 if (!compare_eth(tmp_neigh_node->addr,
178 orig_neigh_node->orig))
179 continue;
180
181 if (tmp_neigh_node->if_incoming != if_incoming)
182 continue;
183
184 if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
185 continue;
186
187 neigh_node = tmp_neigh_node;
188 }
189 rcu_read_unlock();
190 176
191 if (!neigh_node) 177 if (!compare_eth(tmp_neigh_node->addr, orig_neigh_node->orig))
192 neigh_node = create_neighbor(orig_node, 178 continue;
193 orig_neigh_node,
194 orig_neigh_node->orig,
195 if_incoming);
196 if (!neigh_node)
197 goto out;
198 179
199 neigh_node->last_valid = jiffies; 180 if (tmp_neigh_node->if_incoming != if_incoming)
200 } else { 181 continue;
201 /* find packet count of corresponding one hop neighbor */
202 rcu_read_lock();
203 hlist_for_each_entry_rcu(tmp_neigh_node, node,
204 &orig_neigh_node->neigh_list, list) {
205 182
206 if (!compare_eth(tmp_neigh_node->addr, 183 if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
207 orig_neigh_node->orig)) 184 continue;
208 continue;
209 185
210 if (tmp_neigh_node->if_incoming != if_incoming) 186 neigh_node = tmp_neigh_node;
211 continue; 187 break;
188 }
189 rcu_read_unlock();
212 190
213 if (!atomic_inc_not_zero(&tmp_neigh_node->refcount)) 191 if (!neigh_node)
214 continue; 192 neigh_node = create_neighbor(orig_neigh_node,
193 orig_neigh_node,
194 orig_neigh_node->orig,
195 if_incoming);
215 196
216 neigh_node = tmp_neigh_node; 197 if (!neigh_node)
217 } 198 goto out;
218 rcu_read_unlock();
219 199
220 if (!neigh_node) 200 /* if orig_node is direct neighbour update neigh_node last_valid */
221 neigh_node = create_neighbor(orig_neigh_node, 201 if (orig_node == orig_neigh_node)
222 orig_neigh_node, 202 neigh_node->last_valid = jiffies;
223 orig_neigh_node->orig,
224 if_incoming);
225 if (!neigh_node)
226 goto out;
227 }
228 203
229 orig_node->last_valid = jiffies; 204 orig_node->last_valid = jiffies;
230 205
206 /* find packet count of corresponding one hop neighbor */
231 spin_lock_bh(&orig_node->ogm_cnt_lock); 207 spin_lock_bh(&orig_node->ogm_cnt_lock);
232 orig_eq_count = orig_neigh_node->bcast_own_sum[if_incoming->if_num]; 208 orig_eq_count = orig_neigh_node->bcast_own_sum[if_incoming->if_num];
233 neigh_rq_count = neigh_node->real_packet_count; 209 neigh_rq_count = neigh_node->real_packet_count;