batman-adv: gw_node_update() now adds a new gw_node if no curr_gw is selected

Message ID 1303723103-29582-1-git-send-email-ordex@autistici.org (mailing list archive)
State Superseded, archived
Headers

Commit Message

Antonio Quartulli April 25, 2011, 9:18 a.m. UTC
  gw_node_update() doesn't add a new gw_node in case of empty curr_gw.
This means that at the beginning no gw_node is added, leading to an
empty gateway list.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 gateway_client.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gateway_client.c b/gateway_client.c
index 2acd7a6..db4468c 100644
--- a/gateway_client.c
+++ b/gateway_client.c
@@ -311,10 +311,10 @@  void gw_node_update(struct bat_priv *bat_priv,
 	struct gw_node *gw_node, *curr_gw;
 
 	curr_gw = gw_get_selected_gw_node(bat_priv);
+	rcu_read_lock();
 	if (!curr_gw)
-		goto out;
+		goto gw_node_add;
 
-	rcu_read_lock();
 	hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) {
 		if (gw_node->orig_node != orig_node)
 			continue;
@@ -340,6 +340,7 @@  void gw_node_update(struct bat_priv *bat_priv,
 		goto unlock;
 	}
 
+gw_node_add:
 	if (new_gwflags == 0)
 		goto unlock;
 
@@ -350,7 +351,7 @@  deselect:
 	gw_deselect(bat_priv);
 unlock:
 	rcu_read_unlock();
-out:
+
 	if (curr_gw)
 		gw_node_free_ref(curr_gw);
 }