public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@meshcoding.com>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Marek Lindner <lindner_marek@yahoo.de>,
	Antonio Quartulli <antonio@open-mesh.com>
Subject: [B.A.T.M.A.N.] [RFC 05/23] batman-adv: ELP - exporting neighbor list via debugfs
Date: Tue, 11 Feb 2014 13:48:05 +0100	[thread overview]
Message-ID: <1392122903-805-6-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1392122903-805-1-git-send-email-antonio@meshcoding.com>

From: Linus Luessing <linus.luessing@web.de>

Lists all neighbours detected by the Echo Locating Protocol
(ELP) and their metric values.

Initially Developed by Linus during a 6 months trainee study
period in Ascom (Switzerland) AG.

Signed-off-by: Linus Luessing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
 bat_v_elp.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 bat_v_elp.h |  1 +
 debugfs.c   | 17 +++++++++++++
 3 files changed, 98 insertions(+)

diff --git a/bat_v_elp.c b/bat_v_elp.c
index ee4207d..9c40415 100644
--- a/bat_v_elp.c
+++ b/bat_v_elp.c
@@ -379,3 +379,83 @@ out:
 	consume_skb(skb);
 	return NET_RX_SUCCESS;
 }
+
+/**
+ * batadv_v_elp_seq_print_neigh - print a single ELP neighbour node
+ * @seq: neighbour table seq_file struct
+ * @hard_iface: interface the neighbour is connected to
+ * @neigh: the neighbour node to print
+ */
+static void batadv_v_elp_seq_print_neigh(struct seq_file *seq,
+					 struct batadv_hard_iface *hard_iface,
+					 struct batadv_elp_neigh_node *neigh)
+{
+	int last_secs, last_msecs;
+	uint32_t metric;
+
+	last_secs = jiffies_to_msecs(jiffies - neigh->last_seen) / 1000;
+	last_msecs = jiffies_to_msecs(jiffies - neigh->last_seen) % 1000;
+	metric = ewma_read(&neigh->metric);
+
+	seq_printf(seq, "%pM %4i.%03is (%9u.%1u) [%10s]\n",
+		   neigh->addr, last_secs, last_msecs, metric / 10,
+		   metric % 10, hard_iface->net_dev->name);
+}
+
+/**
+ * batadv_v_elp_seq_print_text - print the neighbour table
+ * @seq: neighbour table seq_file struct
+ * @offset: not used
+ *
+ * Returns always 0.
+ */
+int batadv_v_elp_seq_print_text(struct seq_file *seq, void *offset)
+{
+	struct net_device *net_dev = (struct net_device *)seq->private;
+	struct batadv_priv *bat_priv = netdev_priv(net_dev);
+	struct batadv_hard_iface *hard_iface, *primary_if;
+	struct batadv_elp_neigh_node *neigh;
+	int batman_count = 0;
+
+	primary_if = batadv_primary_if_get_selected(bat_priv);
+
+	if (!primary_if) {
+		seq_printf(seq,
+			   "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
+			   net_dev->name);
+		goto out;
+	}
+
+	if (primary_if->if_status != BATADV_IF_ACTIVE) {
+		seq_printf(seq,
+			   "BATMAN mesh %s disabled - primary interface not active\n",
+			   net_dev->name);
+		goto out;
+	}
+
+	seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n",
+		   BATADV_SOURCE_VERSION, primary_if->net_dev->name,
+		   primary_if->net_dev->dev_addr, net_dev->name);
+	seq_printf(seq, "  %-15s %s (%11s) [%10s]\n", "Neighbor",
+		   "last-seen", "metric", "IF");
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
+		if (hard_iface->soft_iface != net_dev)
+			continue;
+
+		hlist_for_each_entry_rcu(neigh, &hard_iface->bat_v.neigh_list, list) {
+			batadv_v_elp_seq_print_neigh(seq, hard_iface, neigh);
+			batman_count++;
+		}
+	}
+	rcu_read_unlock();
+
+	if (batman_count == 0)
+		seq_printf(seq, "No batman nodes in range ...\n");
+
+out:
+	if (primary_if)
+		batadv_hardif_free_ref(primary_if);
+	return 0;
+}
diff --git a/bat_v_elp.h b/bat_v_elp.h
index 186ff4b..4f34ecb 100644
--- a/bat_v_elp.h
+++ b/bat_v_elp.h
@@ -32,5 +32,6 @@ void batadv_v_elp_iface_disable(struct batadv_hard_iface *hard_iface);
 void batadv_v_elp_primary_iface_set(struct batadv_hard_iface *hard_iface);
 int batadv_v_elp_packet_recv(struct sk_buff *skb,
 			     struct batadv_hard_iface *if_incoming);
+int batadv_v_elp_seq_print_text(struct seq_file *seq, void *offset);
 
 #endif /* _NET_BATMAN_ADV_BAT_V_ELP_H_ */
diff --git a/debugfs.c b/debugfs.c
index b758881..23990cf 100644
--- a/debugfs.c
+++ b/debugfs.c
@@ -20,6 +20,7 @@
 #include <linux/debugfs.h>
 
 #include "debugfs.h"
+#include "bat_v_elp.h"
 #include "translation-table.h"
 #include "originator.h"
 #include "hard-interface.h"
@@ -242,6 +243,16 @@ static int batadv_algorithms_open(struct inode *inode, struct file *file)
 	return single_open(file, batadv_algo_seq_print_text, NULL);
 }
 
+#ifdef CONFIG_BATMAN_ADV_BATMAN_V
+int batadv_v_elp_seq_print_text(struct seq_file *seq, void *offset);
+
+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, batadv_v_elp_seq_print_text, net_dev);
+}
+#endif
+
 static int batadv_originators_open(struct inode *inode, struct file *file)
 {
 	struct net_device *net_dev = (struct net_device *)inode->i_private;
@@ -346,6 +357,9 @@ static struct batadv_debuginfo *batadv_general_debuginfos[] = {
 };
 
 /* The following attributes are per soft interface */
+#ifdef CONFIG_BATMAN_ADV_BATMAN_V
+static BATADV_DEBUGINFO(neighbors, S_IRUGO, neighbors_open);
+#endif
 static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open);
 static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open);
 static BATADV_DEBUGINFO(transtable_global, S_IRUGO,
@@ -365,6 +379,9 @@ static BATADV_DEBUGINFO(nc_nodes, S_IRUGO, batadv_nc_nodes_open);
 #endif
 
 static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
+#ifdef CONFIG_BATMAN_ADV_BATMAN_V
+	&batadv_debuginfo_neighbors,
+#endif
 	&batadv_debuginfo_originators,
 	&batadv_debuginfo_gateways,
 	&batadv_debuginfo_transtable_global,
-- 
1.8.5.3


  parent reply	other threads:[~2014-02-11 12:48 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-11 12:48 [B.A.T.M.A.N.] [RFC 00/23] Introducing a new routing protocol: B.A.T.M.A.N. V Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 01/23] batman-adv: invoke ogm_schedule() only when the interface is activated Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 02/23] batman-adv: Add hard_iface specific sysfs wrapper macros for UINT Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 03/23] batman-adv: ELP - adding basic infrastructure Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 04/23] batman-adv: ELP - creating neighbor structures Antonio Quartulli
2014-02-11 15:32   ` Andrew Lunn
2014-02-11 16:02     ` Antonio Quartulli
2014-02-11 16:11       ` Lew Pitcher
2014-02-11 16:26         ` Antonio Quartulli
2014-02-11 12:48 ` Antonio Quartulli [this message]
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 06/23] batman-adv: ELP - adding sysfs parameter for elp interval Antonio Quartulli
2014-02-11 16:59   ` Andrew Lunn
2014-02-11 17:08     ` Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 07/23] batman-adv: OGMv2 - add basic infrastructure Antonio Quartulli
2014-02-11 17:12   ` Andrew Lunn
2014-02-11 17:52     ` Antonio Quartulli
2014-02-12  7:44       ` Andrew Lunn
2014-02-12  7:58         ` Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 08/23] batman-adv: OGMv2 - implement originators logic Antonio Quartulli
2014-02-11 17:22   ` Andrew Lunn
2014-02-11 17:30     ` Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 09/23] batman-adv: OGMv2 - purge obsolete potential routers Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 10/23] batman-adv: split name from variable for uint mesh attributes Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 11/23] batman-adv: add throughput attribute to hard_ifaces Antonio Quartulli
2014-02-12  8:42   ` Andrew Lunn
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 12/23] batman-adv: add base throughput attribute Antonio Quartulli
2014-02-12  8:40   ` Andrew Lunn
2014-02-12 12:20     ` Antonio Quartulli
2014-02-13  9:36       ` Andrew Lunn
2014-02-13  9:53         ` Antonio Quartulli
2014-02-13  9:57           ` Andrew Lunn
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 13/23] batman-adv: add last_unicast_tx to struct neigh_node_elp Antonio Quartulli
2014-02-12  8:49   ` Andrew Lunn
2014-02-12 12:25     ` Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 14/23] batman-adv: ELP - compute the metric based on the estimated throughput Antonio Quartulli
2014-02-12  8:58   ` Andrew Lunn
2014-02-12 12:27     ` Antonio Quartulli
2014-02-12 15:44       ` Antonio Quartulli
2014-02-13  9:45         ` Andrew Lunn
2014-02-13  9:46           ` Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 15/23] batman-adv: ELP - send unicast ELP packets for throughput sampling Antonio Quartulli
2014-02-12  9:12   ` Andrew Lunn
2014-02-12 12:12     ` Antonio Quartulli
2014-02-12 12:54       ` Felix Fietkau
2014-02-12 12:56         ` Antonio Quartulli
2014-02-12 13:02           ` Antonio Quartulli
2014-02-13  9:55           ` Andrew Lunn
2014-02-13 10:02             ` Antonio Quartulli
2014-02-13 10:09               ` Andrew Lunn
2014-02-13 10:13                 ` Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 16/23] batman-adv: ELP - read estimated throughput from cfg80211 Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 17/23] batman-adv: ELP - implement dead neigh node detection Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics Antonio Quartulli
2014-02-13  8:17   ` Antonio Quartulli
2014-02-13  8:19     ` Antonio Quartulli
2014-02-13 10:52   ` Andrew Lunn
2014-02-13 11:02     ` Antonio Quartulli
2014-02-13 11:44       ` Andrew Lunn
2014-02-14  8:24         ` Antonio Quartulli
2014-02-14 17:38           ` Andrew Lunn
2014-02-14 17:46             ` Antonio Quartulli
2014-02-14 18:18               ` Andrew Lunn
2014-02-14 19:18                 ` Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 19/23] batman-adv: add bat_neigh_free() API Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 20/23] batman-adv: B.A.T.M.A.N. V - implement " Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 21/23] batman-adv: B.A.T.M.A.N. V - implement neigh_is_equiv_or_better API Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 22/23] batman-adv: B.A.T.M.A.N. V - implement bat_neigh_cmp API Antonio Quartulli
2014-02-11 12:48 ` [B.A.T.M.A.N.] [RFC 23/23] batman-adv: B.A.T.M.A.N. V - implement bat_orig_print API 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=1392122903-805-6-git-send-email-antonio@meshcoding.com \
    --to=antonio@meshcoding.com \
    --cc=antonio@open-mesh.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=lindner_marek@yahoo.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