All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH v2] batman-adv: remove duplicate code from function is_bidirectional_neigh()
@ 2011-05-05 11:49 Daniele Furlan
  2011-05-05 18:52 ` Sven Eckelmann
  0 siblings, 1 reply; 4+ messages in thread
From: Daniele Furlan @ 2011-05-05 11:49 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

Is there an error in the previous version.
I'm sorry, this version instead works for me.

Signed-off-by: Daniele Furlan <daniele.furlan@gmail.com>
---
 routing.c |   75 ++++++++++++++++++++----------------------------------------
 1 files changed, 25 insertions(+), 50 deletions(-)

diff --git a/routing.c b/routing.c
index 49f5715..c5dec8c 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.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH v2] batman-adv: remove duplicate code from function is_bidirectional_neigh()
  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   ` [B.A.T.M.A.N.] [PATCHv3] " Sven Eckelmann
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Eckelmann @ 2011-05-05 18:52 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: Text/Plain, Size: 654 bytes --]

Daniele Furlan wrote:
> Is there an error in the previous version.
> I'm sorry, this version instead works for me.
> 
> Signed-off-by: Daniele Furlan <daniele.furlan@gmail.com>

Could you please send a patch which isn't malformed... please :)

The biggest problem seems to be the gmail client. Please use something else 
like git-send-email (or anything else which doesn't play around with the stuff 
you gave him) and read through
 http://www.open-mesh.org/wiki/open-mesh/Contribute#Submitting-patches

Also add a real commit message and only add additional comments after the 
"---" (right before the diffstats).

Kind regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [B.A.T.M.A.N.] [PATCHv3] batman-adv: remove duplicate code from function is_bidirectional_neigh()
  2011-05-05 18:52 ` Sven Eckelmann
@ 2011-05-07 20:45   ` Sven Eckelmann
  2011-05-08 13:06     ` Marek Lindner
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Eckelmann @ 2011-05-07 20:45 UTC (permalink / raw)
  To: b.a.t.m.a.n

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCHv3] batman-adv: remove duplicate code from function is_bidirectional_neigh()
  2011-05-07 20:45   ` [B.A.T.M.A.N.] [PATCHv3] " Sven Eckelmann
@ 2011-05-08 13:06     ` Marek Lindner
  0 siblings, 0 replies; 4+ messages in thread
From: Marek Lindner @ 2011-05-08 13:06 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Saturday 07 May 2011 22:45:19 Sven Eckelmann wrote:
> From: Daniele Furlan <daniele.furlan@gmail.com>
> 
> In function is_bidirectional_neigh the code that find out the one hop
> neighbor is duplicated.

Applied in revision fea56a5.

Thanks,
Marek

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-08 13:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [B.A.T.M.A.N.] [PATCHv3] " Sven Eckelmann
2011-05-08 13:06     ` Marek Lindner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.