Commit 27aea212 authored by Daniele Furlan's avatar Daniele Furlan Committed by Sven Eckelmann

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: default avatarDaniele Furlan <daniele.furlan@gmail.com>
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
parent 6e215fd8
...@@ -169,42 +169,12 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, ...@@ -169,42 +169,12 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
uint8_t orig_eq_count, neigh_rq_count, tq_own; uint8_t orig_eq_count, neigh_rq_count, tq_own;
int tq_asym_penalty, ret = 0; int tq_asym_penalty, ret = 0;
if (orig_node == orig_neigh_node) { /* find corresponding one hop neighbor */
rcu_read_lock();
hlist_for_each_entry_rcu(tmp_neigh_node, node,
&orig_node->neigh_list, list) {
if (!compare_eth(tmp_neigh_node->addr,
orig_neigh_node->orig))
continue;
if (tmp_neigh_node->if_incoming != if_incoming)
continue;
if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
continue;
neigh_node = tmp_neigh_node;
}
rcu_read_unlock();
if (!neigh_node)
neigh_node = create_neighbor(orig_node,
orig_neigh_node,
orig_neigh_node->orig,
if_incoming);
if (!neigh_node)
goto out;
neigh_node->last_valid = jiffies;
} else {
/* find packet count of corresponding one hop neighbor */
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(tmp_neigh_node, node, hlist_for_each_entry_rcu(tmp_neigh_node, node,
&orig_neigh_node->neigh_list, list) { &orig_neigh_node->neigh_list, list) {
if (!compare_eth(tmp_neigh_node->addr, if (!compare_eth(tmp_neigh_node->addr, orig_neigh_node->orig))
orig_neigh_node->orig))
continue; continue;
if (tmp_neigh_node->if_incoming != if_incoming) if (tmp_neigh_node->if_incoming != if_incoming)
...@@ -214,6 +184,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, ...@@ -214,6 +184,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
continue; continue;
neigh_node = tmp_neigh_node; neigh_node = tmp_neigh_node;
break;
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -222,12 +193,17 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, ...@@ -222,12 +193,17 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
orig_neigh_node, orig_neigh_node,
orig_neigh_node->orig, orig_neigh_node->orig,
if_incoming); if_incoming);
if (!neigh_node) if (!neigh_node)
goto out; goto out;
}
/* if orig_node is direct neighbour update neigh_node last_valid */
if (orig_node == orig_neigh_node)
neigh_node->last_valid = jiffies;
orig_node->last_valid = jiffies; orig_node->last_valid = jiffies;
/* find packet count of corresponding one hop neighbor */
spin_lock_bh(&orig_node->ogm_cnt_lock); spin_lock_bh(&orig_node->ogm_cnt_lock);
orig_eq_count = orig_neigh_node->bcast_own_sum[if_incoming->if_num]; orig_eq_count = orig_neigh_node->bcast_own_sum[if_incoming->if_num];
neigh_rq_count = neigh_node->real_packet_count; neigh_rq_count = neigh_node->real_packet_count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment