From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCHv3] batman-adv: remove duplicate code from function is_bidirectional_neigh()
Date: Sat, 7 May 2011 22:45:19 +0200 [thread overview]
Message-ID: <1304801119-3083-1-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <201105052052.06909.sven@narfation.org>
From: Daniele Furlan <daniele.furlan@gmail.com>
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>
---
No answer yet, but I would like to get this patch into net-next-2.6. I
did the change myself and compared both versions by ignoring spaces. No
real differences were shown... so I would say that this change looks
good :)
routing.c | 73 ++++++++++++++++++++-----------------------------------------
1 files changed, 24 insertions(+), 49 deletions(-)
diff --git a/routing.c b/routing.c
index 7648b92..d562566 100644
--- a/routing.c
+++ b/routing.c
@@ -169,65 +169,40 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
uint8_t orig_eq_count, neigh_rq_count, tq_own;
int tq_asym_penalty, ret = 0;
- if (orig_node == orig_neigh_node) {
- rcu_read_lock();
- hlist_for_each_entry_rcu(tmp_neigh_node, node,
- &orig_node->neigh_list, list) {
+ /* find corresponding one hop neighbor */
+ rcu_read_lock();
+ hlist_for_each_entry_rcu(tmp_neigh_node, node,
+ &orig_neigh_node->neigh_list, list) {
- if (!compare_eth(tmp_neigh_node->addr,
- orig_neigh_node->orig))
- continue;
+ if (!compare_eth(tmp_neigh_node->addr, orig_neigh_node->orig))
+ continue;
- if (tmp_neigh_node->if_incoming != if_incoming)
- continue;
+ if (tmp_neigh_node->if_incoming != if_incoming)
+ continue;
- if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
- continue;
+ if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
+ continue;
- neigh_node = tmp_neigh_node;
- }
- rcu_read_unlock();
+ 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;
+ if (!neigh_node)
+ neigh_node = create_neighbor(orig_neigh_node,
+ orig_neigh_node,
+ orig_neigh_node->orig,
+ if_incoming);
+ if (!neigh_node)
+ goto out;
+
+ /* if orig_node is direct neighbour update neigh_node last_valid */
+ if (orig_node == orig_neigh_node)
neigh_node->last_valid = jiffies;
- } else {
- /* find packet count of corresponding one hop neighbor */
- rcu_read_lock();
- hlist_for_each_entry_rcu(tmp_neigh_node, node,
- &orig_neigh_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_neigh_node,
- orig_neigh_node,
- orig_neigh_node->orig,
- if_incoming);
- if (!neigh_node)
- goto out;
- }
orig_node->last_valid = jiffies;
+ /* find packet count of corresponding one hop neighbor */
spin_lock_bh(&orig_node->ogm_cnt_lock);
orig_eq_count = orig_neigh_node->bcast_own_sum[if_incoming->if_num];
neigh_rq_count = neigh_node->real_packet_count;
--
1.7.5.1
next prev parent reply other threads:[~2011-05-07 20:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-05 11:49 [B.A.T.M.A.N.] [PATCH v2] batman-adv: remove duplicate code from function is_bidirectional_neigh() Daniele Furlan
2011-05-05 18:52 ` Sven Eckelmann
2011-05-07 20:45 ` Sven Eckelmann [this message]
2011-05-08 13:06 ` [B.A.T.M.A.N.] [PATCHv3] " Marek Lindner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1304801119-3083-1-git-send-email-sven@narfation.org \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox