b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: "Linus Lüssing" <linus.luessing@ascom.ch>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Linus Lüssing" <linus.luessing@ascom.ch>
Subject: [B.A.T.M.A.N.] [PATCH 06/11] batman-adv: Adding ndp debugfs output
Date: Fri, 14 Jan 2011 01:59:49 +0100	[thread overview]
Message-ID: <1294966794-17780-7-git-send-email-linus.luessing@ascom.ch> (raw)
In-Reply-To: <1294966794-17780-1-git-send-email-linus.luessing@ascom.ch>

Lists all neighbours and their tq/rq values detected and measured by the
Neighbor Discovery Protocol (NDP).

Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
---
 bat_debugfs.c |    9 ++++++++
 ndp.c         |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ndp.h         |    1 +
 3 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/batman-adv/bat_debugfs.c b/batman-adv/bat_debugfs.c
index 0ae81d0..602aa15 100644
--- a/batman-adv/bat_debugfs.c
+++ b/batman-adv/bat_debugfs.c
@@ -25,6 +25,7 @@
 
 #include "bat_debugfs.h"
 #include "translation-table.h"
+#include "ndp.h"
 #include "originator.h"
 #include "hard-interface.h"
 #include "gateway_common.h"
@@ -222,6 +223,12 @@ static void debug_log_cleanup(struct bat_priv *bat_priv)
 }
 #endif
 
+static int neighbors_open(struct inode *inode, struct file *file)
+{
+	struct net_device *net_dev = (struct net_device *)inode->i_private;
+	return single_open(file, ndp_seq_print_text, net_dev);
+}
+
 static int originators_open(struct inode *inode, struct file *file)
 {
 	struct net_device *net_dev = (struct net_device *)inode->i_private;
@@ -275,6 +282,7 @@ struct bat_debuginfo bat_debuginfo_##_name = {	\
 		}				\
 };
 
+static BAT_DEBUGINFO(neighbors, S_IRUGO, neighbors_open);
 static BAT_DEBUGINFO(originators, S_IRUGO, originators_open);
 static BAT_DEBUGINFO(gateways, S_IRUGO, gateways_open);
 static BAT_DEBUGINFO(softif_neigh, S_IRUGO, softif_neigh_open);
@@ -283,6 +291,7 @@ static BAT_DEBUGINFO(transtable_local, S_IRUGO, transtable_local_open);
 static BAT_DEBUGINFO(vis_data, S_IRUGO, vis_data_open);
 
 static struct bat_debuginfo *mesh_debuginfos[] = {
+	&bat_debuginfo_neighbors,
 	&bat_debuginfo_originators,
 	&bat_debuginfo_gateways,
 	&bat_debuginfo_softif_neigh,
diff --git a/batman-adv/ndp.c b/batman-adv/ndp.c
index 5be2639..1fd107c 100644
--- a/batman-adv/ndp.c
+++ b/batman-adv/ndp.c
@@ -286,3 +286,63 @@ ret:
 	spin_unlock_bh(&batman_if->neigh_list_lock);
 	return ret;
 }
+
+int ndp_seq_print_text(struct seq_file *seq, void *offset)
+{
+	struct neigh_node *neigh_node;
+	struct batman_if *batman_if;
+	struct hlist_node *node;
+	int last_seen_secs;
+	int last_seen_msecs;
+	int batman_count = 0;
+	struct net_device *net_dev = (struct net_device *)seq->private;
+	struct bat_priv *bat_priv = netdev_priv(net_dev);
+
+	if ((!bat_priv->primary_if) ||
+	    (bat_priv->primary_if->if_status != IF_ACTIVE)) {
+		if (!bat_priv->primary_if)
+			return seq_printf(seq, "BATMAN mesh %s disabled - "
+				    "please specify interfaces to enable it\n",
+				    net_dev->name);
+
+		return seq_printf(seq, "BATMAN mesh %s "
+				  "disabled - primary interface not active\n",
+				  net_dev->name);
+	}
+
+	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, "  %-15s %s (%s/%i) [%10s]\n",
+		   "Neighbor", "last-seen", "#TQ,#RQ", TQ_MAX_VALUE, "IF");
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(batman_if, &if_list, list) {
+		if (batman_if->if_status != IF_ACTIVE)
+			continue;
+
+		spin_lock_bh(&batman_if->neigh_list_lock);
+		hlist_for_each_entry(neigh_node, node, &batman_if->neigh_list,
+				    list) {
+			last_seen_secs = jiffies_to_msecs(jiffies -
+						neigh_node->last_valid) / 1000;
+			last_seen_msecs = jiffies_to_msecs(jiffies -
+						neigh_node->last_valid) % 1000;
+
+			seq_printf(seq, "%pM %4i.%03is     (%3i,%3i) [%10s]\n",
+				   neigh_node->addr, last_seen_secs,
+				   last_seen_msecs, neigh_node->tq_avg,
+				   neigh_node->rq, batman_if->net_dev->name);
+
+			batman_count++;
+		}
+		spin_unlock_bh(&batman_if->neigh_list_lock);
+	}
+	rcu_read_unlock();
+
+	if ((batman_count == 0))
+		seq_printf(seq, "No batman nodes in range ...\n");
+
+	return 0;
+}
diff --git a/batman-adv/ndp.h b/batman-adv/ndp.h
index a828362..f528bcf 100644
--- a/batman-adv/ndp.h
+++ b/batman-adv/ndp.h
@@ -32,5 +32,6 @@ uint8_t ndp_fetch_tq(struct batman_packet_ndp *packet,
 void ndp_purge_neighbors(void);
 int ndp_update_neighbor(uint8_t my_tq, uint32_t seqno,
 			struct batman_if *batman_if, uint8_t *neigh_addr);
+int ndp_seq_print_text(struct seq_file *seq, void *offset);
 
 #endif /* _NET_BATMAN_ADV_NDP_H_ */
-- 
1.7.1


  parent reply	other threads:[~2011-01-14  0:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-14  0:59 [B.A.T.M.A.N.] NDP patches v5 Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 01/11] batman-adv: Rename packet type / structure / functions for OGMs Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 02/11] batman-adv: Adding workqueue for new ndp packets Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 03/11] batman-adv: Send neighbor discovery packets Linus Lüssing
2011-01-15 13:53   ` Andrew Lunn
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 04/11] batman-adv: Creating neighbor structures, updating LQs Linus Lüssing
2011-01-15 14:14   ` Andrew Lunn
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 05/11] batman-adv: Purge outdated ndp neighbours Linus Lüssing
2011-01-14  0:59 ` Linus Lüssing [this message]
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 07/11] batman-adv: Adding batman_if specific sysfs wrapper macros for UINT Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 08/11] batman-adv: Adding sysfs parameter for ndp interval Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 09/11] batman-adv: Use local tq values determined by NDP on OGMs Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 10/11] batman-adv: Use rcu locking + ref-counting for neigh_list Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 11/11] batman-adv: Adding sysfs ABI documentation for ndp_interval 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=1294966794-17780-7-git-send-email-linus.luessing@ascom.ch \
    --to=linus.luessing@ascom.ch \
    --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).