From patchwork Sat Nov 5 17:24:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 1351 Return-Path: Received: from cora.hrz.tu-chemnitz.de (cora.hrz.tu-chemnitz.de [134.109.228.40]) by open-mesh.org (Postfix) with ESMTPS id B44E7600845 for ; Sat, 5 Nov 2011 18:24:53 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@tu-chemnitz.de; dkim-adsp=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tu-chemnitz.de; s=dkim2010; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=jezgCMclMInWvryfQGEaPUUss3+fTHSXhJ2ZfTE7Pbc=; b=iz7Z2oilWI48yN8CpATUTpMIA7qOdnQx41/PWTUlgX6loqNZcjO/4Y3vHGS8oAzO6EuAaHU2dS6LWWc5ytpGM49PKvj9nIC4Y+8TPQmwACzh6vD9d/PoPw6OT9MeLVNrMjbGGcRRy1VHrgzEqWrgw++/Xn9N2RkDjj9WorCdblE=; Received: from p57aa0226.dip0.t-ipconnect.de ([87.170.2.38] helo=pandem0nium) by cora.hrz.tu-chemnitz.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1RMjz7-00016e-S6; Sat, 05 Nov 2011 18:24:53 +0100 Received: from dotslash by pandem0nium with local (Exim 4.72) (envelope-from ) id 1RMjz0-0007OU-2l; Sat, 05 Nov 2011 18:24:42 +0100 From: Simon Wunderlich To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 5 Nov 2011 18:24:15 +0100 Message-Id: <1320513862-28360-5-git-send-email-siwu@hrz.tu-chemnitz.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1320513862-28360-1-git-send-email-siwu@hrz.tu-chemnitz.de> References: <1320513862-28360-1-git-send-email-siwu@hrz.tu-chemnitz.de> X-Spam-Score: -1.0 (-) X-Spam-Report: --- Textanalyse SpamAssassin 3.3.1 (-1.0 Punkte) Fragen an/questions to: Postmaster TU Chemnitz * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP --- Ende Textanalyse X-Scan-Signature: 0f7bcf3a378725c23bfad2a90cf65541 Cc: Simon Wunderlich Subject: [B.A.T.M.A.N.] [PATCH 04/11] batman-adv: export claim tables through 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: Sat, 05 Nov 2011 17:24:53 -0000 Signed-off-by: Simon Wunderlich --- [2011-10-27] Changes suggested by Marek Lindner: * move rcu_read_lock() more into the loops [2011-10-30] Changes suggested by Marek Lindner: * pimp up claim table debugfs output [2011-11-04] remove primary_addr Signed-off-by: Simon Wunderlich --- bat_debugfs.c | 10 +++++++++ bridge_loop_avoidance.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ bridge_loop_avoidance.h | 1 + 3 files changed, 63 insertions(+), 0 deletions(-) diff --git a/bat_debugfs.c b/bat_debugfs.c index 492eec7..20d3fc9 100644 --- a/bat_debugfs.c +++ b/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; @@ -239,6 +240,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; @@ -271,6 +279,7 @@ struct bat_debuginfo bat_debuginfo_##_name = { \ 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); @@ -278,6 +287,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/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index f18774f..725c0f5 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1308,3 +1308,55 @@ 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; + 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) + seq_printf(seq, " * %pM on % 5d by %pM [%c] (%04x)\n", + claim->addr, claim->vid, + claim->backbone_gw->orig, + (compare_eth(claim->backbone_gw->orig, + primary_if->net_dev->dev_addr) + ? 'x' : ' '), + claim->backbone_gw->crc); + rcu_read_unlock(); + } +out: + if (primary_if) + hardif_free_ref(primary_if); + return ret; +} diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index e26848f..3b312aa 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -23,6 +23,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); int bla_init(struct bat_priv *bat_priv);