From patchwork Thu Mar 22 21:51:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1605 Return-Path: Received: from nm23-vm6.bullet.mail.ukl.yahoo.com (nm23-vm6.bullet.mail.ukl.yahoo.com [217.146.176.150]) by open-mesh.org (Postfix) with SMTP id 1AC6D600841 for ; Thu, 22 Mar 2012 22:51:47 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.180] by nm23.bullet.mail.ukl.yahoo.com with NNFMP; 22 Mar 2012 21:51:46 -0000 Received: from [217.146.183.127] by tm11.bullet.mail.ukl.yahoo.com with NNFMP; 22 Mar 2012 21:51:46 -0000 Received: from [127.0.0.1] by smtp104.mail.ukl.yahoo.com with NNFMP; 22 Mar 2012 21:51:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1332453106; bh=ST56FVXlTbXb2LeOwhKLz+avRA+2UKNrhZSMfr/ftgQ=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=hrqoIJp9DUH6I1wzuRb8Vq8ys2uJ2NoeDF8yJA9/71TtgqtTWeUnoAcCxG0lESE4XSTxpeJwSjS2R4LNybbtkWP4AfPAX+fn6hE6xWoHTEgQTxLWFIIiQDr7oxvEuPytL48YXFvQHnHnSJvk4c0T5fz7CrZAr0waC9Q0R77gXqw= X-Yahoo-Newman-Id: 867057.49983.bm@smtp104.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: oFEOTqIVM1n8teOI5v5G8kLSTjc3oTlyrGDxCbEh4WGEqUa O69YLsknlPcsJsJNfOta6UDAHAOz2.7X2XCCK1ScMIR.rJk_CrNK4sR4py.A Ze4nyWmIdkopc1z_FvteS3GH4ztJ1mAV6OnHOcKBFLW3EnbUfKr3PLcD2Zp_ Q1lZuR949K6wWssXQmi6rcEgntS6PBvt54CmSXdWwO_k8PMAnaCj0FiWxlQR PFTA7Ttb2rWnvdMvmFH4tbyeLqcTZG4FXUSJ253eneuSNfif8ntQm9tdaE0L DqLV8asoj1xmA4WvZ6gP8GqyGhBP6aN9gplTUIrVL6_sIQuRG724QSUWbkaP 1x45imgtC8v7pHEyxiKLkmdYDhxF.yOWAKYsonoc6dwcj63zDH1_5i1ZouDo yHMih2yslcZ.YGYbK9NvwfhI3syTF1FlIya9MJqCZsLsP3Vh0Ro0hpY1xiSh xkBPv4zvWjTWobls- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@217.85.92.241 with plain) by smtp104.mail.ukl.yahoo.com with SMTP; 22 Mar 2012 14:51:45 -0700 PDT From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 22 Mar 2012 22:51:13 +0100 Message-Id: <1332453075-27999-3-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1332453075-27999-1-git-send-email-lindner_marek@yahoo.de> References: <201203222250.31309.lindner_marek@yahoo.de> <1332453075-27999-1-git-send-email-lindner_marek@yahoo.de> Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [RFC 3/5] batman-adv: ELP - exporting neighbor list via debugfs X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Mar 2012 21:51:47 -0000 From: Linus Luessing Lists all neighbours and their tq/rq values detected and measured by the Echo Location Protocol (ELP). Developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG. Signed-off-by: Linus Luessing Signed-off-by: Marek Lindner --- bat_debugfs.c | 16 +++++++++++++ bat_v_elp.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 0 deletions(-) diff --git a/bat_debugfs.c b/bat_debugfs.c index 3b588f8..5365554 100644 --- a/bat_debugfs.c +++ b/bat_debugfs.c @@ -227,6 +227,16 @@ static int bat_algorithms_open(struct inode *inode, struct file *file) return single_open(file, bat_algo_seq_print_text, NULL); } +#ifdef CONFIG_BATMAN_ADV_BATMAN_V +int bat_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, bat_v_elp_seq_print_text, net_dev); +} +#endif + static int originators_open(struct inode *inode, struct file *file) { struct net_device *net_dev = (struct net_device *)inode->i_private; @@ -283,6 +293,9 @@ struct bat_debuginfo bat_debuginfo_##_name = { \ }; static BAT_DEBUGINFO(routing_algos, S_IRUGO, bat_algorithms_open); +#ifdef CONFIG_BATMAN_ADV_BATMAN_V +static BAT_DEBUGINFO(neighbors, S_IRUGO, neighbors_open); +#endif 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); @@ -293,6 +306,9 @@ 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[] = { +#ifdef CONFIG_BATMAN_ADV_BATMAN_V + &bat_debuginfo_neighbors, +#endif &bat_debuginfo_originators, &bat_debuginfo_gateways, &bat_debuginfo_transtable_global, diff --git a/bat_v_elp.c b/bat_v_elp.c index e252c04..9232f28 100644 --- a/bat_v_elp.c +++ b/bat_v_elp.c @@ -394,6 +394,73 @@ out: return NET_RX_SUCCESS; } +static void bat_v_elp_seq_print_neigh(struct seq_file *seq, + struct hard_iface *hard_iface, + struct neigh_node *neigh_node) +{ + int last_secs, last_msecs; + + last_secs = jiffies_to_msecs(jiffies - neigh_node->last_seen) / 1000; + last_msecs = jiffies_to_msecs(jiffies - neigh_node->last_seen) % 1000; + + seq_printf(seq, "%pM %4i.%03is (%3i,%3i) [%10s]\n", + neigh_node->addr, last_secs, last_msecs, neigh_node->tq, + neigh_node->rq, hard_iface->net_dev->name); +} + +int bat_v_elp_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 hard_iface *hard_iface, *primary_if; + struct neigh_node *neigh_node; + struct hlist_node *node; + int ret = 0, batman_count = 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, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", + SOURCE_VERSION, primary_if->net_dev->name, + 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(hard_iface, &hardif_list, list) { + if (hard_iface->soft_iface != net_dev) + continue; + + hlist_for_each_entry_rcu(neigh_node, node, + &hard_iface->neigh_list, list) { + bat_v_elp_seq_print_neigh(seq, hard_iface, neigh_node); + batman_count++; + } + } + rcu_read_unlock(); + + if (batman_count == 0) + seq_printf(seq, "No batman nodes in range ...\n"); + +out: + if (primary_if) + hardif_free_ref(primary_if); + return ret; +} + static struct bat_algo_ops batman_v __read_mostly = { .name = "BATMAN V", .bat_iface_enable = bat_v_elp_iface_enable,