From bd5b80d51a6c4a68f7d4b9b92c495329f47e53d4 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Mon, 20 Aug 2012 23:37:26 +0200 Subject: batman-adv: Check return value of try_module_get New operations should not be started when they need an increased module reference counter and try_module_get failed. This patch addresses Coverity #712284: Unchecked return value Signed-off-by: Sven Eckelmann Signed-off-by: Antonio Quartulli --- net/batman-adv/debugfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'net/batman-adv/debugfs.c') diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index 391d4fb..bd032bc 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c @@ -99,15 +99,17 @@ int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) static int batadv_log_open(struct inode *inode, struct file *file) { + if (!try_module_get(THIS_MODULE)) + return -EBUSY; + nonseekable_open(inode, file); file->private_data = inode->i_private; - batadv_inc_module_count(); return 0; } static int batadv_log_release(struct inode *inode, struct file *file) { - batadv_dec_module_count(); + module_put(THIS_MODULE); return 0; } -- cgit v1.1 From 2f1dfbe185075a50dc8f0490a136377af53a1c62 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Sat, 30 Jun 2012 20:01:19 +0200 Subject: batman-adv: Distributed ARP Table - implement local storage Since batman-adv cannot inter-operate with the host ARP table, this patch introduces a batman-adv private storage for ARP entries exchanged within DAT. This storage will represent the node local cache in the DAT protocol. Signed-off-by: Antonio Quartulli --- net/batman-adv/debugfs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'net/batman-adv/debugfs.c') diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index bd032bc..ebc5f4d 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c @@ -31,6 +31,7 @@ #include "vis.h" #include "icmp_socket.h" #include "bridge_loop_avoidance.h" +#include "distributed-arp-table.h" static struct dentry *batadv_debugfs; @@ -280,6 +281,18 @@ static int batadv_bla_backbone_table_open(struct inode *inode, #endif +/** + * batadv_dat_cache_open - Prepare file handler for reads from dat_chache + * @inode: inode which was opened + * @file: file handle to be initialized + */ +static int batadv_dat_cache_open(struct inode *inode, struct file *file) +{ + struct net_device *net_dev = (struct net_device *)inode->i_private; + return single_open(file, batadv_dat_cache_seq_print_text, net_dev); +} + + static int batadv_transtable_local_open(struct inode *inode, struct file *file) { struct net_device *net_dev = (struct net_device *)inode->i_private; @@ -319,6 +332,7 @@ static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open); static BATADV_DEBUGINFO(bla_backbone_table, S_IRUGO, batadv_bla_backbone_table_open); #endif +static BATADV_DEBUGINFO(dat_cache, S_IRUGO, batadv_dat_cache_open); static BATADV_DEBUGINFO(transtable_local, S_IRUGO, batadv_transtable_local_open); static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); @@ -331,6 +345,7 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { &batadv_debuginfo_bla_claim_table, &batadv_debuginfo_bla_backbone_table, #endif + &batadv_debuginfo_dat_cache, &batadv_debuginfo_transtable_local, &batadv_debuginfo_vis_data, NULL, -- cgit v1.1 From 172244748204c894864def59133d0133ccfabe30 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Sun, 6 Nov 2011 12:23:55 +0100 Subject: batman-adv: Distributed ARP Table - add compile option This patch makes it possible to decide whether to include DAT within the batman-adv binary or not. It is extremely useful when the user wants to reduce the size of the resulting module by cutting off any not needed feature. Signed-off-by: Antonio Quartulli --- net/batman-adv/debugfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'net/batman-adv/debugfs.c') diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index ebc5f4d..3f679cb 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c @@ -281,6 +281,7 @@ static int batadv_bla_backbone_table_open(struct inode *inode, #endif +#ifdef CONFIG_BATMAN_ADV_DAT /** * batadv_dat_cache_open - Prepare file handler for reads from dat_chache * @inode: inode which was opened @@ -291,7 +292,7 @@ static int batadv_dat_cache_open(struct inode *inode, struct file *file) struct net_device *net_dev = (struct net_device *)inode->i_private; return single_open(file, batadv_dat_cache_seq_print_text, net_dev); } - +#endif static int batadv_transtable_local_open(struct inode *inode, struct file *file) { @@ -332,7 +333,9 @@ static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open); static BATADV_DEBUGINFO(bla_backbone_table, S_IRUGO, batadv_bla_backbone_table_open); #endif +#ifdef CONFIG_BATMAN_ADV_DAT static BATADV_DEBUGINFO(dat_cache, S_IRUGO, batadv_dat_cache_open); +#endif static BATADV_DEBUGINFO(transtable_local, S_IRUGO, batadv_transtable_local_open); static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); @@ -345,7 +348,9 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { &batadv_debuginfo_bla_claim_table, &batadv_debuginfo_bla_backbone_table, #endif +#ifdef CONFIG_BATMAN_ADV_DAT &batadv_debuginfo_dat_cache, +#endif &batadv_debuginfo_transtable_local, &batadv_debuginfo_vis_data, NULL, -- cgit v1.1 From 637fbd12947b5645d8c16c982aa15c17ab695b0a Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Tue, 16 Oct 2012 10:04:39 +0200 Subject: batman-adv: support array of debugfs general attributes This patch adds support for an array of debugfs general (not soft_iface specific) attributes. With this change it will be possible to add more general attributes by simply appending them to the array without touching the rest of the code. Reported-by: Marek Lindner Signed-off-by: Antonio Quartulli Acked-by: Sven Eckelmann Signed-off-by: Marek Lindner --- net/batman-adv/debugfs.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'net/batman-adv/debugfs.c') diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index 3f679cb..6f58ddd 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c @@ -323,7 +323,17 @@ struct batadv_debuginfo batadv_debuginfo_##_name = { \ } \ }; +/* the following attributes are general and therefore they will be directly + * placed in the BATADV_DEBUGFS_SUBDIR subdirectory of debugfs + */ static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); + +static struct batadv_debuginfo *batadv_general_debuginfos[] = { + &batadv_debuginfo_routing_algos, + NULL, +}; + +/* The following attributes are per soft interface */ 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, @@ -358,7 +368,7 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { void batadv_debugfs_init(void) { - struct batadv_debuginfo *bat_debug; + struct batadv_debuginfo **bat_debug; struct dentry *file; batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL); @@ -366,17 +376,23 @@ void batadv_debugfs_init(void) batadv_debugfs = NULL; if (!batadv_debugfs) - goto out; + goto err; - bat_debug = &batadv_debuginfo_routing_algos; - file = debugfs_create_file(bat_debug->attr.name, - S_IFREG | bat_debug->attr.mode, - batadv_debugfs, NULL, &bat_debug->fops); - if (!file) - pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name); + for (bat_debug = batadv_general_debuginfos; *bat_debug; ++bat_debug) { + file = debugfs_create_file(((*bat_debug)->attr).name, + S_IFREG | ((*bat_debug)->attr).mode, + batadv_debugfs, NULL, + &(*bat_debug)->fops); + if (!file) { + pr_err("Can't add general debugfs file: %s\n", + ((*bat_debug)->attr).name); + goto err; + } + } -out: return; +err: + debugfs_remove_recursive(batadv_debugfs); } void batadv_debugfs_destroy(void) -- cgit v1.1