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 09/18] batman-adv: Output mcast forw table in debugfs
Date: Sun, 30 Jan 2011 05:39:17 +0100 [thread overview]
Message-ID: <1296362366-3852-10-git-send-email-linus.luessing@saxnet.de> (raw)
In-Reply-To: <1296362366-3852-1-git-send-email-linus.luessing@saxnet.de>
With this commit the full multicast forwarding table, which is used for
determining whether to forward a multicast data packet or not, can now
be displayed via mcast_forw_table in BATMAN's debugfs directory.
Signed-off-by: Linus Lüssing <linus.luessing@saxnet.de>
---
bat_debugfs.c | 9 +++++
multicast.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
multicast.h | 1 +
3 files changed, 113 insertions(+), 0 deletions(-)
diff --git a/batman-adv/bat_debugfs.c b/batman-adv/bat_debugfs.c
index 0e9d435..30cd4e9 100644
--- a/batman-adv/bat_debugfs.c
+++ b/batman-adv/bat_debugfs.c
@@ -32,6 +32,7 @@
#include "soft-interface.h"
#include "vis.h"
#include "icmp_socket.h"
+#include "multicast.h"
static struct dentry *bat_debugfs;
@@ -250,6 +251,12 @@ static int transtable_local_open(struct inode *inode, struct file *file)
return single_open(file, hna_local_seq_print_text, net_dev);
}
+static int mcast_forw_table_open(struct inode *inode, struct file *file)
+{
+ struct net_device *net_dev = (struct net_device *)inode->i_private;
+ return single_open(file, mcast_forw_table_seq_print_text, net_dev);
+}
+
static int vis_data_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
@@ -278,6 +285,7 @@ static BAT_DEBUGINFO(gateways, S_IRUGO, gateways_open);
static BAT_DEBUGINFO(softif_neigh, S_IRUGO, softif_neigh_open);
static BAT_DEBUGINFO(transtable_global, S_IRUGO, transtable_global_open);
static BAT_DEBUGINFO(transtable_local, S_IRUGO, transtable_local_open);
+static BAT_DEBUGINFO(mcast_forw_table, S_IRUGO, mcast_forw_table_open);
static BAT_DEBUGINFO(vis_data, S_IRUGO, vis_data_open);
static struct bat_debuginfo *mesh_debuginfos[] = {
@@ -286,6 +294,7 @@ static struct bat_debuginfo *mesh_debuginfos[] = {
&bat_debuginfo_softif_neigh,
&bat_debuginfo_transtable_global,
&bat_debuginfo_transtable_local,
+ &bat_debuginfo_mcast_forw_table,
&bat_debuginfo_vis_data,
NULL,
};
diff --git a/batman-adv/multicast.c b/batman-adv/multicast.c
index b1718c6..b53825f 100644
--- a/batman-adv/multicast.c
+++ b/batman-adv/multicast.c
@@ -164,6 +164,24 @@ void mcast_tracker_reset(struct bat_priv *bat_priv)
start_mcast_tracker(bat_priv);
}
+static inline int get_remaining_timeout(
+ struct mcast_forw_nexthop_entry *nexthop_entry,
+ struct bat_priv *bat_priv)
+{
+ int tracker_timeout = atomic_read(&bat_priv->mcast_tracker_timeout);
+ if (!tracker_timeout)
+ tracker_timeout = atomic_read(&bat_priv->mcast_tracker_interval)
+ * TRACKER_TIMEOUT_AUTO_X;
+ if (!tracker_timeout)
+ tracker_timeout = atomic_read(&bat_priv->orig_interval)
+ * TRACKER_TIMEOUT_AUTO_X / 2;
+
+ tracker_timeout = jiffies_to_msecs(nexthop_entry->timeout) +
+ tracker_timeout - jiffies_to_msecs(jiffies);
+
+ return (tracker_timeout > 0 ? tracker_timeout : 0);
+}
+
static void prepare_forw_if_entry(struct hlist_head *forw_if_list,
int16_t if_num, uint8_t *neigh_addr)
{
@@ -961,6 +979,91 @@ ok:
return count;
}
+static inline struct batman_if *if_num_to_batman_if(int16_t if_num)
+{
+ struct batman_if *batman_if;
+
+ list_for_each_entry_rcu(batman_if, &if_list, list)
+ if (batman_if->if_num == if_num)
+ return batman_if;
+
+ return NULL;
+}
+
+static void seq_print_if_entry(struct mcast_forw_if_entry *if_entry,
+ struct bat_priv *bat_priv, struct seq_file *seq)
+{
+ struct mcast_forw_nexthop_entry *nexthop_entry;
+ struct hlist_node *node;
+ struct batman_if *batman_if;
+
+ rcu_read_lock();
+ batman_if = if_num_to_batman_if(if_entry->if_num);
+ if (!batman_if) {
+ rcu_read_unlock();
+ return;
+ }
+
+ seq_printf(seq, "\t\t%s\n", batman_if->net_dev->name);
+ rcu_read_unlock();
+
+ hlist_for_each_entry(nexthop_entry, node,
+ &if_entry->mcast_nexthop_list, list)
+ seq_printf(seq, "\t\t\t%pM - %i\n", nexthop_entry->neigh_addr,
+ get_remaining_timeout(nexthop_entry, bat_priv));
+}
+
+static void seq_print_orig_entry(struct mcast_forw_orig_entry *orig_entry,
+ struct bat_priv *bat_priv,
+ struct seq_file *seq)
+{
+ struct mcast_forw_if_entry *if_entry;
+ struct hlist_node *node;
+
+ seq_printf(seq, "\t%pM\n", orig_entry->orig);
+ hlist_for_each_entry(if_entry, node, &orig_entry->mcast_if_list,
+ list)
+ seq_print_if_entry(if_entry, bat_priv, seq);
+}
+
+static void seq_print_table_entry(struct mcast_forw_table_entry *table_entry,
+ struct bat_priv *bat_priv,
+ struct seq_file *seq)
+{
+ struct mcast_forw_orig_entry *orig_entry;
+ struct hlist_node *node;
+
+ seq_printf(seq, "%pM\n", table_entry->mcast_addr);
+ hlist_for_each_entry(orig_entry, node, &table_entry->mcast_orig_list,
+ list)
+ seq_print_orig_entry(orig_entry, bat_priv, seq);
+}
+
+int mcast_forw_table_seq_print_text(struct seq_file *seq, void *offset)
+{
+ struct net_device *net_dev = (struct net_device *)seq->private;
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ struct mcast_forw_table_entry *table_entry;
+ struct hlist_node *node;
+
+ seq_printf(seq, "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n",
+ SOURCE_VERSION, REVISION_VERSION_STR,
+ bat_priv->primary_if->net_dev->name,
+ bat_priv->primary_if->net_dev->dev_addr, net_dev->name);
+ seq_printf(seq, "Multicast group MAC\tOriginator\t"
+ "Outgoing interface\tNexthop - timeout in msecs\n");
+
+ spin_lock_bh(&bat_priv->mcast_forw_table_lock);
+
+ hlist_for_each_entry(table_entry, node, &bat_priv->mcast_forw_table,
+ list)
+ seq_print_table_entry(table_entry, bat_priv, seq);
+
+ spin_unlock_bh(&bat_priv->mcast_forw_table_lock);
+
+ return 0;
+}
+
int mcast_init(struct bat_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->mcast_tracker_work, mcast_tracker_timer);
diff --git a/batman-adv/multicast.h b/batman-adv/multicast.h
index d1a3e83..63d0e97 100644
--- a/batman-adv/multicast.h
+++ b/batman-adv/multicast.h
@@ -29,6 +29,7 @@ int mcast_tracker_timeout_set(struct net_device *net_dev, char *buff,
void mcast_tracker_reset(struct bat_priv *bat_priv);
void route_mcast_tracker_packet(struct sk_buff *tracker_packet,
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);
--
1.7.2.3
next prev parent reply other threads:[~2011-01-30 4:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-30 4:39 [B.A.T.M.A.N.] B.A.T.M.A.N.-Advanced Multicast Optimizations, v3 Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 01/18] batman-adv: Adding configurable variables for multicast optimizations Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 02/18] batman-adv: Attach local MCAs to OGMs Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 03/18] batman-adv: Add periodic multicast tracker timer Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 04/18] batman-adv: Buffer other originator's received MCA entries Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 05/18] batman-adv: Prepare and send own multicast tracker packets Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 06/18] batman-adv: Add length check for (received) " Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 07/18] batman-adv: Route multicast " Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 08/18] batman-adv: Add/refresh entries to/in mcast forwarding table Linus Lüssing
2011-01-30 4:39 ` Linus Lüssing [this message]
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 10/18] batman-adv: Purge timeouted entries in mcast forw table Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 11/18] batman-adv: Send own BAT_MCAST packets in proact_tracking multicast mode Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 12/18] batman-adv: Export broadcast packet ethernet header checks Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 13/18] batman-adv: Receive multicast data packets BAT_MCAST Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 14/18] batman-adv: Forward multicast data in proact_tracking mode Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 15/18] batman-adv: Add duplicate checks for multicast data Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 16/18] batman-adv: Still flood multicast packets we are not a receiver of Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 17/18] batman-adv: Make number of (re)broadcasts configurable via sysfs Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 18/18] batman-adv: Use rcu-locking for multicast forwarding table 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=1296362366-3852-10-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 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).