From patchwork Tue Dec 7 22:32:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 652 Return-Path: Received: from fmmailgate01.web.de (fmmailgate01.web.de [217.72.192.221]) by open-mesh.org (Postfix) with ESMTP id EC37515465F for ; Tue, 7 Dec 2010 23:32:41 +0100 (CET) Received: from smtp08.web.de ( [172.20.5.216]) by fmmailgate01.web.de (Postfix) with ESMTP id C694C180B80C2; Tue, 7 Dec 2010 23:32:39 +0100 (CET) Received: from [46.126.246.98] (helo=localhost) by smtp08.web.de with asmtp (TLSv1:AES128-SHA:128) (WEB.DE 4.110 #24) id 1PQ65P-0006qA-00; Tue, 07 Dec 2010 23:32:39 +0100 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Tue, 7 Dec 2010 23:32:21 +0100 Message-Id: <1291761150-29818-11-git-send-email-linus.luessing@saxnet.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <20101207221351.GA19474@Sellars> References: <20101207221351.GA19474@Sellars> MIME-Version: 1.0 Sender: linus.luessing@web.de X-Sender: linus.luessing@web.de X-Provags-ID: V01U2FsdGVkX1+/wkwHPBsqkYFkBRpUdcuWUD0NTSkRZNiv+mkc bWLWAQgUw1SN181OzRk3B/AvdSc5hEjN2/b/y7LC1wdTGv3ec1 xpGWhnNfMXME/tuCrVPQ== Cc: =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [B.A.T.M.A.N.] [PATCH 11/20] batman-adv: Output mcast forw table in debugfs X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 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: Tue, 07 Dec 2010 22:32:44 -0000 With this commit the full multicast forwarding table, which is used for determining whether to forward a multicast data packet or not, can now be displayed via mcast_forw_table in BATMAN's debugfs directory. Signed-off-by: Linus Lüssing --- bat_debugfs.c | 9 ++++++ multicast.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ multicast.h | 1 + 3 files changed, 93 insertions(+), 0 deletions(-) diff --git a/bat_debugfs.c b/bat_debugfs.c index 0ae81d0..7b1b57d 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 "multicast.h" static struct dentry *bat_debugfs; @@ -252,6 +253,12 @@ static int transtable_local_open(struct inode *inode, struct file *file) return single_open(file, hna_local_seq_print_text, net_dev); } +static int mcast_forw_table_open(struct inode *inode, struct file *file) +{ + struct net_device *net_dev = (struct net_device *)inode->i_private; + return single_open(file, mcast_forw_table_seq_print_text, net_dev); +} + static int vis_data_open(struct inode *inode, struct file *file) { struct net_device *net_dev = (struct net_device *)inode->i_private; @@ -280,6 +287,7 @@ static BAT_DEBUGINFO(gateways, S_IRUGO, gateways_open); static BAT_DEBUGINFO(softif_neigh, S_IRUGO, softif_neigh_open); static BAT_DEBUGINFO(transtable_global, S_IRUGO, transtable_global_open); static BAT_DEBUGINFO(transtable_local, S_IRUGO, transtable_local_open); +static BAT_DEBUGINFO(mcast_forw_table, S_IRUGO, mcast_forw_table_open); static BAT_DEBUGINFO(vis_data, S_IRUGO, vis_data_open); static struct bat_debuginfo *mesh_debuginfos[] = { @@ -288,6 +296,7 @@ static struct bat_debuginfo *mesh_debuginfos[] = { &bat_debuginfo_softif_neigh, &bat_debuginfo_transtable_global, &bat_debuginfo_transtable_local, + &bat_debuginfo_mcast_forw_table, &bat_debuginfo_vis_data, NULL, }; diff --git a/multicast.c b/multicast.c index c7edbef..edfe7e2 100644 --- a/multicast.c +++ b/multicast.c @@ -106,6 +106,24 @@ void mcast_tracker_reset(struct bat_priv *bat_priv) start_mcast_tracker(bat_priv); } +static inline int get_remaining_timeout( + struct mcast_forw_nexthop_entry *nexthop_entry, + struct bat_priv *bat_priv) +{ + int tracker_timeout = atomic_read(&bat_priv->mcast_tracker_timeout); + if (!tracker_timeout) + tracker_timeout = atomic_read(&bat_priv->mcast_tracker_interval) + * TRACKER_TIMEOUT_AUTO_X; + if (!tracker_timeout) + tracker_timeout = atomic_read(&bat_priv->orig_interval) + * TRACKER_TIMEOUT_AUTO_X / 2; + + tracker_timeout = jiffies_to_msecs(nexthop_entry->timeout) + + tracker_timeout - jiffies_to_msecs(jiffies); + + return (tracker_timeout > 0 ? tracker_timeout : 0); +} + static void prepare_forw_if_entry(struct list_head *forw_if_list, int16_t if_num, uint8_t *neigh_addr) { @@ -924,6 +942,71 @@ ok: return count; } +static inline struct batman_if *if_num_to_batman_if(int16_t if_num) +{ + struct batman_if *batman_if; + + list_for_each_entry_rcu(batman_if, &if_list, list) + if (batman_if->if_num == if_num) + return batman_if; + + return NULL; +} + +int mcast_forw_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); + unsigned long flags; + struct batman_if *batman_if; + struct mcast_forw_table_entry *table_entry; + struct mcast_forw_orig_entry *orig_entry; + struct mcast_forw_if_entry *if_entry; + struct mcast_forw_nexthop_entry *nexthop_entry; + + 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, "Multicast group MAC\tOriginator\t" + "Outgoing interface\tNexthop - timeout in msecs\n"); + + rcu_read_lock(); + spin_lock_irqsave(&bat_priv->mcast_forw_table_lock, flags); + list_for_each_entry(table_entry, &bat_priv->mcast_forw_table, list) { + seq_printf(seq, "%pM\n", table_entry->mcast_addr); + + list_for_each_entry(orig_entry, &table_entry->mcast_orig_list, + list) { + seq_printf(seq, "\t%pM\n", orig_entry->orig); + + list_for_each_entry(if_entry, + &orig_entry->mcast_if_list, list) { + batman_if = + if_num_to_batman_if(if_entry->if_num); + if (!batman_if) + continue; + + seq_printf(seq, "\t\t%s\n", + batman_if->net_dev->name); + + list_for_each_entry(nexthop_entry, + &if_entry->mcast_nexthop_list, + list) { + seq_printf(seq, "\t\t\t%pM - %i\n", + nexthop_entry->neigh_addr, + get_remaining_timeout( + nexthop_entry, bat_priv)); + } + } + } + } + spin_unlock_irqrestore(&bat_priv->mcast_forw_table_lock, flags); + rcu_read_unlock(); + + return 0; +} + int mcast_init(struct bat_priv *bat_priv) { INIT_DELAYED_WORK(&bat_priv->mcast_tracker_work, mcast_tracker_timer); diff --git a/multicast.h b/multicast.h index 2711d8b..0bd0590 100644 --- a/multicast.h +++ b/multicast.h @@ -30,6 +30,7 @@ void mcast_tracker_reset(struct bat_priv *bat_priv); void route_mcast_tracker_packet( struct mcast_tracker_packet *tracker_packet, int tracker_packet_len, struct bat_priv *bat_priv); +int mcast_forw_table_seq_print_text(struct seq_file *seq, void *offset); int mcast_init(struct bat_priv *bat_priv); void mcast_free(struct bat_priv *bat_priv);