b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Quartulli <ordex@autistici.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Subject: [B.A.T.M.A.N.] [PATCH 10/16] batman-adv: export claim tables through debugfs
Date: Thu,  5 Apr 2012 12:38:56 +0200	[thread overview]
Message-ID: <1333622342-6128-11-git-send-email-ordex@autistici.org> (raw)
In-Reply-To: <1333622342-6128-1-git-send-email-ordex@autistici.org>

From: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 Documentation/networking/batman-adv.txt |    5 ++-
 net/batman-adv/bat_debugfs.c            |   10 ++++++
 net/batman-adv/bridge_loop_avoidance.c  |   53 +++++++++++++++++++++++++++++++
 net/batman-adv/bridge_loop_avoidance.h  |    1 +
 4 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/Documentation/networking/batman-adv.txt b/Documentation/networking/batman-adv.txt
index 9523e9e..220a58c 100644
--- a/Documentation/networking/batman-adv.txt
+++ b/Documentation/networking/batman-adv.txt
@@ -77,9 +77,8 @@ folder:
 There is a special folder for debugging information:
 
 #  ls /sys/kernel/debug/batman_adv/bat0/
-#  gateways     socket        transtable_global  vis_data
-#  originators  softif_neigh  transtable_local
-
+# bla_claim_table    log                socket             transtable_local
+# gateways           originators        transtable_global  vis_data
 
 Some of the files contain all sort of status information  regard-
 ing  the  mesh  network.  For  example, you can view the table of
diff --git a/net/batman-adv/bat_debugfs.c b/net/batman-adv/bat_debugfs.c
index 165ff62..0e35177 100644
--- a/net/batman-adv/bat_debugfs.c
+++ b/net/batman-adv/bat_debugfs.c
@@ -32,6 +32,7 @@
 #include "soft-interface.h"
 #include "vis.h"
 #include "icmp_socket.h"
+#include "bridge_loop_avoidance.h"
 
 static struct dentry *bat_debugfs;
 
@@ -244,6 +245,13 @@ static int transtable_global_open(struct inode *inode, struct file *file)
 	return single_open(file, tt_global_seq_print_text, net_dev);
 }
 
+static int bla_claim_table_open(struct inode *inode, struct file *file)
+{
+	struct net_device *net_dev = (struct net_device *)inode->i_private;
+	return single_open(file, bla_claim_table_seq_print_text, net_dev);
+}
+
+
 static int transtable_local_open(struct inode *inode, struct file *file)
 {
 	struct net_device *net_dev = (struct net_device *)inode->i_private;
@@ -277,6 +285,7 @@ static BAT_DEBUGINFO(routing_algos, S_IRUGO, bat_algorithms_open);
 static BAT_DEBUGINFO(originators, S_IRUGO, originators_open);
 static BAT_DEBUGINFO(gateways, S_IRUGO, gateways_open);
 static BAT_DEBUGINFO(transtable_global, S_IRUGO, transtable_global_open);
+static BAT_DEBUGINFO(bla_claim_table, S_IRUGO, bla_claim_table_open);
 static BAT_DEBUGINFO(transtable_local, S_IRUGO, transtable_local_open);
 static BAT_DEBUGINFO(vis_data, S_IRUGO, vis_data_open);
 
@@ -284,6 +293,7 @@ static struct bat_debuginfo *mesh_debuginfos[] = {
 	&bat_debuginfo_originators,
 	&bat_debuginfo_gateways,
 	&bat_debuginfo_transtable_global,
+	&bat_debuginfo_bla_claim_table,
 	&bat_debuginfo_transtable_local,
 	&bat_debuginfo_vis_data,
 	NULL,
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index e86cc90..e8b4435 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1299,3 +1299,56 @@ out:
 		claim_free_ref(claim);
 	return ret;
 }
+
+int bla_claim_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 hashtable_t *hash = bat_priv->claim_hash;
+	struct claim *claim;
+	struct hard_iface *primary_if;
+	struct hlist_node *node;
+	struct hlist_head *head;
+	uint32_t i;
+	bool is_own;
+	int ret = 0;
+
+	primary_if = primary_if_get_selected(bat_priv);
+	if (!primary_if) {
+		ret = seq_printf(seq,
+				 "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
+				 net_dev->name);
+		goto out;
+	}
+
+	if (primary_if->if_status != IF_ACTIVE) {
+		ret = seq_printf(seq,
+				 "BATMAN mesh %s disabled - primary interface not active\n",
+				 net_dev->name);
+		goto out;
+	}
+
+	seq_printf(seq, "Claims announced for the mesh %s (orig %pM)\n",
+		   net_dev->name, primary_if->net_dev->dev_addr);
+	seq_printf(seq, "   %-17s    %-5s    %-17s [o] (%-4s)\n",
+		   "Client", "VID", "Originator", "CRC");
+	for (i = 0; i < hash->size; i++) {
+		head = &hash->table[i];
+
+		rcu_read_lock();
+		hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
+			is_own = compare_eth(claim->backbone_gw->orig,
+					     primary_if->net_dev->dev_addr);
+			seq_printf(seq,	" * %pM on % 5d by %pM [%c] (%04x)\n",
+				   claim->addr, claim->vid,
+				   claim->backbone_gw->orig,
+				   (is_own ? 'x' : ' '),
+				   claim->backbone_gw->crc);
+		}
+		rcu_read_unlock();
+	}
+out:
+	if (primary_if)
+		hardif_free_ref(primary_if);
+	return ret;
+}
diff --git a/net/batman-adv/bridge_loop_avoidance.h b/net/batman-adv/bridge_loop_avoidance.h
index 488d778..d9e3480 100644
--- a/net/batman-adv/bridge_loop_avoidance.h
+++ b/net/batman-adv/bridge_loop_avoidance.h
@@ -26,6 +26,7 @@ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
 int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
 int bla_is_backbone_gw(struct sk_buff *skb,
 		       struct orig_node *orig_node, int hdr_size);
+int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
 void bla_update_orig_address(struct bat_priv *bat_priv,
 			     struct hard_iface *primary_if,
 			     struct hard_iface *oldif);
-- 
1.7.9.4


  parent reply	other threads:[~2012-04-05 10:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-05 10:38 [B.A.T.M.A.N.] pull request: batman-adv 2012-04-05 Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 01/16] MAINTAINERS: add additional maintainer for net/batman-adv Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 02/16] batman-adv: clean up Kconfig Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 03/16] batman-adv: use ETH_ALEN instead of hardcoded numeric constants Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 04/16] batman-adv: Replace bitarray operations with bitmap Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 05/16] batman-adv: Remove declaration of only locally used functions Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 06/16] batman-adv: encourage batman to take shorter routes by changing the default hop penalty Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 07/16] batman-adv: remove old bridge loop avoidance code Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 08/16] batman-adv: add basic " Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 09/16] batman-adv: make bridge loop avoidance switchable Antonio Quartulli
2012-04-05 10:38 ` Antonio Quartulli [this message]
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 11/16] batman-adv: allow multiple entries in tt_global_entries Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 12/16] batman-adv: don't let backbone gateways exchange tt entries Antonio Quartulli
2012-04-05 10:38 ` [B.A.T.M.A.N.] [PATCH 13/16] batman-adv: add broadcast duplicate check Antonio Quartulli
2012-04-05 10:39 ` [B.A.T.M.A.N.] [PATCH 14/16] batman-adv: drop STP over batman Antonio Quartulli
2012-04-05 10:39 ` [B.A.T.M.A.N.] [PATCH 15/16] batman-adv: form groups in the bridge loop avoidance Antonio Quartulli
2012-04-05 10:39 ` [B.A.T.M.A.N.] [PATCH 16/16] batman-adv: add bridge loop avoidance compile option Antonio Quartulli
2012-04-05 23:15 ` [B.A.T.M.A.N.] pull request: batman-adv 2012-04-05 David Miller
2012-04-07 18:49 [B.A.T.M.A.N.] pull request: batman-adv 2012-04-07 Antonio Quartulli
2012-04-07 18:49 ` [B.A.T.M.A.N.] [PATCH 10/16] batman-adv: export claim tables through debugfs Antonio Quartulli
2012-04-11 12:50 [B.A.T.M.A.N.] pull request: batman-adv 2012-04-11 Antonio Quartulli
2012-04-11 12:50 ` [B.A.T.M.A.N.] [PATCH 10/16] batman-adv: export claim tables through debugfs Antonio Quartulli

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=1333622342-6128-11-git-send-email-ordex@autistici.org \
    --to=ordex@autistici.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=siwu@hrz.tu-chemnitz.de \
    /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).