b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Marek Lindner <lindner_marek@yahoo.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Marek Lindner <lindner_marek@yahoo.de>
Subject: [B.A.T.M.A.N.] [PATCH 1/8] batman-adv: remove redundant gw_node_list_free() function
Date: Thu,  4 Nov 2010 18:20:58 +0100	[thread overview]
Message-ID: <1288891265-16035-1-git-send-email-lindner_marek@yahoo.de> (raw)
In-Reply-To: <201011041820.44518.lindner_marek@yahoo.de>

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
---
 batman-adv/gateway_client.c |   30 +++++++++---------------------
 batman-adv/gateway_client.h |    3 +--
 batman-adv/main.c           |    2 +-
 batman-adv/originator.c     |    2 +-
 4 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/batman-adv/gateway_client.c b/batman-adv/gateway_client.c
index 24c12b4..e10dc90 100644
--- a/batman-adv/gateway_client.c
+++ b/batman-adv/gateway_client.c
@@ -305,7 +305,7 @@ void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node)
 	return gw_node_update(bat_priv, orig_node, 0);
 }
 
-void gw_node_purge_deleted(struct bat_priv *bat_priv)
+void gw_node_purge(struct bat_priv *bat_priv)
 {
 	struct gw_node *gw_node;
 	struct hlist_node *node, *node_tmp;
@@ -314,32 +314,20 @@ void gw_node_purge_deleted(struct bat_priv *bat_priv)
 	spin_lock_bh(&bat_priv->gw_list_lock);
 
 	hlist_for_each_entry_safe(gw_node, node, node_tmp,
-						&bat_priv->gw_list, list) {
-		if ((gw_node->deleted) &&
-		    (time_after(jiffies, gw_node->deleted + timeout))) {
-
-			hlist_del_rcu(&gw_node->list);
-			call_rcu(&gw_node->rcu, gw_node_free_rcu);
-		}
-	}
-
-	spin_unlock_bh(&bat_priv->gw_list_lock);
-}
-
-void gw_node_list_free(struct bat_priv *bat_priv)
-{
-	struct gw_node *gw_node;
-	struct hlist_node *node, *node_tmp;
+				  &bat_priv->gw_list, list) {
+		if (((!gw_node->deleted) ||
+		     (time_before(jiffies, gw_node->deleted + timeout))) &&
+		    atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE)
+			continue;
 
-	spin_lock_bh(&bat_priv->gw_list_lock);
+		if (bat_priv->curr_gw == gw_node)
+			gw_deselect(bat_priv);
 
-	hlist_for_each_entry_safe(gw_node, node, node_tmp,
-				 &bat_priv->gw_list, list) {
 		hlist_del_rcu(&gw_node->list);
 		call_rcu(&gw_node->rcu, gw_node_free_rcu);
 	}
 
-	gw_deselect(bat_priv);
+
 	spin_unlock_bh(&bat_priv->gw_list_lock);
 }
 
diff --git a/batman-adv/gateway_client.h b/batman-adv/gateway_client.h
index ce0b4f0..38699ba 100644
--- a/batman-adv/gateway_client.h
+++ b/batman-adv/gateway_client.h
@@ -29,8 +29,7 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node);
 void gw_node_update(struct bat_priv *bat_priv,
 		    struct orig_node *orig_node, uint8_t new_gwflags);
 void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node);
-void gw_node_purge_deleted(struct bat_priv *bat_priv);
-void gw_node_list_free(struct bat_priv *bat_priv);
+void gw_node_purge(struct bat_priv *bat_priv);
 int gw_client_seq_print_text(struct seq_file *seq, void *offset);
 bool gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb);
 
diff --git a/batman-adv/main.c b/batman-adv/main.c
index e4e4eca..c91e635 100644
--- a/batman-adv/main.c
+++ b/batman-adv/main.c
@@ -132,7 +132,7 @@ void mesh_free(struct net_device *soft_iface)
 
 	vis_quit(bat_priv);
 
-	gw_node_list_free(bat_priv);
+	gw_node_purge(bat_priv);
 	originator_free(bat_priv);
 
 	hna_local_free(bat_priv);
diff --git a/batman-adv/originator.c b/batman-adv/originator.c
index 8930446..89ec021 100644
--- a/batman-adv/originator.c
+++ b/batman-adv/originator.c
@@ -293,7 +293,7 @@ static void _purge_orig(struct bat_priv *bat_priv)
 
 	spin_unlock_bh(&bat_priv->orig_hash_lock);
 
-	gw_node_purge_deleted(bat_priv);
+	gw_node_purge(bat_priv);
 	gw_election(bat_priv);
 
 	softif_neigh_purge(bat_priv);
-- 
1.7.1


  reply	other threads:[~2010-11-04 17:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04 17:20 [B.A.T.M.A.N.] batman-adv gateway handling [v2] Marek Lindner
2010-11-04 17:20 ` Marek Lindner [this message]
2010-11-04 17:20 ` [B.A.T.M.A.N.] [PATCH 2/8] batman-adv: gateways silently drop DHCP requests Marek Lindner
2010-11-04 17:21 ` [B.A.T.M.A.N.] [PATCH 3/8] batman-adv: move gateway selection class into its own sysfs file Marek Lindner
2010-11-04 17:21 ` [B.A.T.M.A.N.] [PATCH 4/8] batman-adv: move gateway bandwidth " Marek Lindner
2010-11-04 17:21 ` [B.A.T.M.A.N.] [PATCH 5/8] batman-adv: cleanup gw mode sysfs file to only accept one value Marek Lindner
2010-11-04 17:21 ` [B.A.T.M.A.N.] [PATCH 6/8] batctl: support new gateway sysfs API Marek Lindner
2010-11-04 17:21 ` [B.A.T.M.A.N.] [PATCH 7/8] batman-adv: document gateway sysfs ABI Marek Lindner
2010-11-04 17:21 ` [B.A.T.M.A.N.] [PATCH 8/8] batman-adv: add gateway IPv6 support by filtering DHCPv6 messages Marek Lindner
2010-11-07 12:56 ` [B.A.T.M.A.N.] batman-adv gateway handling [v2] Marek Lindner
  -- strict thread matches above, loose matches on Subject: below --
2010-10-24  1:13 [B.A.T.M.A.N.] batman-adv gateway handling Marek Lindner
2010-10-24  1:14 ` [B.A.T.M.A.N.] [PATCH 1/8] batman-adv: remove redundant gw_node_list_free() function 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=1288891265-16035-1-git-send-email-lindner_marek@yahoo.de \
    --to=lindner_marek@yahoo.de \
    --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;
as well as URLs for NNTP newsgroup(s).