[v2] batman-adv: move neigh_node->if_incoming->if_status check in find_router()

Message ID 1304880777-19702-1-git-send-email-ordex@autistici.org (mailing list archive)
State Accepted, archived
Commit de7607d5f8bed4143c5f1fc94ccd424e1f1875a0
Headers

Commit Message

Antonio Quartulli May 8, 2011, 6:52 p.m. UTC
  Every time that find_router() is invoked, if_status has to be compared with
IF_ACTIVE. Moving this comparison inside find_router() will avoid to write it
each time.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
In this version the reference counting of 'router' has been corrected.

 routing.c |    3 +++
 unicast.c |    3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Marek Lindner May 9, 2011, 11:27 a.m. UTC | #1
On Sunday 08 May 2011 20:52:57 Antonio Quartulli wrote:
> Every time that find_router() is invoked, if_status has to be compared with
> IF_ACTIVE. Moving this comparison inside find_router() will avoid to write
> it each time.

Applied in revision de7607d.

Thanks,
Marek
  

Patch

diff --git a/routing.c b/routing.c
index bb1c3ec..8c403ce 100644
--- a/routing.c
+++ b/routing.c
@@ -1240,6 +1240,9 @@  struct neigh_node *find_router(struct bat_priv *bat_priv,
 		router = find_ifalter_router(primary_orig_node, recv_if);
 
 return_router:
+	if (router && router->if_incoming->if_status != IF_ACTIVE)
+		goto err_unlock;
+
 	rcu_read_unlock();
 	return router;
 err_unlock:
diff --git a/unicast.c b/unicast.c
index 19c3daf..bab6076 100644
--- a/unicast.c
+++ b/unicast.c
@@ -314,9 +314,6 @@  find_router:
 	if (!neigh_node)
 		goto out;
 
-	if (neigh_node->if_incoming->if_status != IF_ACTIVE)
-		goto out;
-
 	if (my_skb_head_push(skb, sizeof(struct unicast_packet)) < 0)
 		goto out;