All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Linus Lüssing" <linus.luessing@saxnet.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Linus Lüssing" <linus.luessing@saxnet.de>
Subject: [B.A.T.M.A.N.] [PATCH 12/19] batman-adv: Purge timeouted entries in mcast forw table
Date: Sat, 22 Jan 2011 02:21:35 +0100	[thread overview]
Message-ID: <1295659302-7171-13-git-send-email-linus.luessing@saxnet.de> (raw)
In-Reply-To: <1295659302-7171-1-git-send-email-linus.luessing@saxnet.de>

With this commit, the multicast forwarding table, which has been
previously filled up due to multicast tracker packets, will now be
checked frequently (once per second) for timeouted entries. If so these
entries get removed from the table.

Note, that a more frequent check interval is not necessary, as multicast
data will not only be forwarded if an entry exists, but also if that one
might not have timeouted yet.

Signed-off-by: Linus Lüssing <linus.luessing@saxnet.de>
---
 multicast.c  |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 multicast.h  |    1 +
 originator.c |    2 +
 3 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/batman-adv/multicast.c b/batman-adv/multicast.c
index 686e10b..e47cc56 100644
--- a/batman-adv/multicast.c
+++ b/batman-adv/multicast.c
@@ -898,6 +898,76 @@ out:
 	rcu_read_unlock();
 }
 
+static void purge_mcast_nexthop_list(struct list_head *mcast_nexthop_list,
+				     int *num_nexthops,
+				     struct bat_priv *bat_priv)
+{
+	struct mcast_forw_nexthop_entry *nexthop_entry, *tmp_nexthop_entry;
+
+	list_for_each_entry_safe(nexthop_entry, tmp_nexthop_entry,
+				 mcast_nexthop_list, list) {
+		if (get_remaining_timeout(nexthop_entry, bat_priv))
+			continue;
+
+		list_del(&nexthop_entry->list);
+		kfree(nexthop_entry);
+		*num_nexthops = *num_nexthops - 1;
+	}
+}
+
+static void purge_mcast_if_list(struct list_head *mcast_if_list,
+				struct bat_priv *bat_priv)
+{
+	struct mcast_forw_if_entry *if_entry, *tmp_if_entry;
+
+	list_for_each_entry_safe(if_entry, tmp_if_entry, mcast_if_list, list) {
+		purge_mcast_nexthop_list(&if_entry->mcast_nexthop_list,
+					 &if_entry->num_nexthops,
+					 bat_priv);
+
+		if (!list_empty(&if_entry->mcast_nexthop_list))
+				continue;
+
+		list_del(&if_entry->list);
+		kfree(if_entry);
+	}
+}
+
+static void purge_mcast_orig_list(struct list_head *mcast_orig_list,
+				  struct bat_priv *bat_priv)
+{
+	struct mcast_forw_orig_entry *orig_entry, *tmp_orig_entry;
+
+	list_for_each_entry_safe(orig_entry, tmp_orig_entry, mcast_orig_list,
+				 list) {
+		purge_mcast_if_list(&orig_entry->mcast_if_list, bat_priv);
+
+		if (!list_empty(&orig_entry->mcast_if_list))
+			continue;
+
+		list_del(&orig_entry->list);
+		kfree(orig_entry);
+	}
+}
+
+void purge_mcast_forw_table(struct bat_priv *bat_priv)
+{
+	struct mcast_forw_table_entry *table_entry, *tmp_table_entry;
+
+	spin_lock_bh(&bat_priv->mcast_forw_table_lock);
+	list_for_each_entry_safe(table_entry, tmp_table_entry,
+				 &bat_priv->mcast_forw_table, list) {
+		purge_mcast_orig_list(&table_entry->mcast_orig_list, bat_priv);
+
+		if (!list_empty(&table_entry->mcast_orig_list))
+			continue;
+
+		list_del(&table_entry->list);
+		kfree(table_entry);
+	}
+	spin_unlock_bh(&bat_priv->mcast_forw_table_lock);
+}
+
 static void mcast_tracker_timer(struct work_struct *work)
 {
 	struct bat_priv *bat_priv = container_of(work, struct bat_priv,
diff --git a/batman-adv/multicast.h b/batman-adv/multicast.h
index 0bd0590..7312afa 100644
--- a/batman-adv/multicast.h
+++ b/batman-adv/multicast.h
@@ -30,6 +30,7 @@ void mcast_tracker_reset(struct bat_priv *bat_priv);
 void route_mcast_tracker_packet(
 			struct mcast_tracker_packet *tracker_packet,
 			int tracker_packet_len, struct bat_priv *bat_priv);
+void purge_mcast_forw_table(struct bat_priv *bat_priv);
 int mcast_forw_table_seq_print_text(struct seq_file *seq, void *offset);
 int mcast_init(struct bat_priv *bat_priv);
 void mcast_free(struct bat_priv *bat_priv);
diff --git a/batman-adv/originator.c b/batman-adv/originator.c
index aee77d3..6c964e5 100644
--- a/batman-adv/originator.c
+++ b/batman-adv/originator.c
@@ -30,6 +30,7 @@
 #include "hard-interface.h"
 #include "unicast.h"
 #include "soft-interface.h"
+#include "multicast.h"
 
 static void purge_orig(struct work_struct *work);
 
@@ -402,6 +403,7 @@ static void purge_orig(struct work_struct *work)
 	struct bat_priv *bat_priv =
 		container_of(delayed_work, struct bat_priv, orig_work);
 
+	purge_mcast_forw_table(bat_priv);
 	_purge_orig(bat_priv);
 	start_purge_timer(bat_priv);
 }
-- 
1.7.2.3


  parent reply	other threads:[~2011-01-22  1:21 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-22  1:21 [B.A.T.M.A.N.] B.A.T.M.A.N.-Advanced Multicast Optimizations, v2 Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 01/19] batman-adv: Add packet structures for multicast optimizations Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 02/19] batman-adv: Adding configurable variables " Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 03/19] batman-adv: compat macros/defines for local multicast group fetching Linus Lüssing
2011-01-23  0:50   ` Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 04/19] batman-adv: Attach local MCAs to OGMs Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 05/19] batman-adv: Add periodic multicast tracker timer Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 06/19] batman-adv: Buffer other originator's received MCA entries Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 07/19] batman-adv: Prepare and send own multicast tracker packets Linus Lüssing
2011-01-22 22:00   ` Simon Wunderlich
2011-01-30  4:49     ` Linus Lüssing
2011-01-23  0:52   ` Linus Lüssing
2011-01-23  2:52   ` Simon Wunderlich
2011-01-23  3:00   ` Simon Wunderlich
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 08/19] batman-adv: Add length check for (received) " Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 09/19] batman-adv: Route multicast " Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 10/19] batman-adv: Add/refresh entries to/in mcast forwarding table Linus Lüssing
2011-01-22 22:13   ` Simon Wunderlich
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 11/19] batman-adv: Output mcast forw table in debugfs Linus Lüssing
2011-01-22  1:21 ` Linus Lüssing [this message]
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 13/19] batman-adv: Send own BAT_MCAST packets in proact_tracking multicast mode Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 14/19] batman-adv: Export broadcast packet ethernet header checks Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 15/19] batman-adv: Receive multicast data packets BAT_MCAST Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 16/19] batman-adv: Forward multicast data in proact_tracking mode Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 17/19] batman-adv: Add duplicate checks for multicast data Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 18/19] batman-adv: Still flood multicast packets we are not a receiver of Linus Lüssing
2011-01-22  1:21 ` [B.A.T.M.A.N.] [PATCH 19/19] batman-adv: Make number of (re)broadcasts configurable via sysfs Linus Lüssing
2011-01-22 16:16 ` [B.A.T.M.A.N.] B.A.T.M.A.N.-Advanced Multicast Optimizations, v2 Linus Lüssing

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=1295659302-7171-13-git-send-email-linus.luessing@saxnet.de \
    --to=linus.luessing@saxnet.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 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.