diff options
Diffstat (limited to 'net/batman-adv/debugfs.c')
| -rw-r--r-- | net/batman-adv/debugfs.c | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index 391d4fb2026f..6f58ddd53bff 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include "vis.h" | 31 | #include "vis.h" |
| 32 | #include "icmp_socket.h" | 32 | #include "icmp_socket.h" |
| 33 | #include "bridge_loop_avoidance.h" | 33 | #include "bridge_loop_avoidance.h" |
| 34 | #include "distributed-arp-table.h" | ||
| 34 | 35 | ||
| 35 | static struct dentry *batadv_debugfs; | 36 | static struct dentry *batadv_debugfs; |
| 36 | 37 | ||
| @@ -99,15 +100,17 @@ int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) | |||
| 99 | 100 | ||
| 100 | static int batadv_log_open(struct inode *inode, struct file *file) | 101 | static int batadv_log_open(struct inode *inode, struct file *file) |
| 101 | { | 102 | { |
| 103 | if (!try_module_get(THIS_MODULE)) | ||
| 104 | return -EBUSY; | ||
| 105 | |||
| 102 | nonseekable_open(inode, file); | 106 | nonseekable_open(inode, file); |
| 103 | file->private_data = inode->i_private; | 107 | file->private_data = inode->i_private; |
| 104 | batadv_inc_module_count(); | ||
| 105 | return 0; | 108 | return 0; |
| 106 | } | 109 | } |
| 107 | 110 | ||
| 108 | static int batadv_log_release(struct inode *inode, struct file *file) | 111 | static int batadv_log_release(struct inode *inode, struct file *file) |
| 109 | { | 112 | { |
| 110 | batadv_dec_module_count(); | 113 | module_put(THIS_MODULE); |
| 111 | return 0; | 114 | return 0; |
| 112 | } | 115 | } |
| 113 | 116 | ||
| @@ -278,6 +281,19 @@ static int batadv_bla_backbone_table_open(struct inode *inode, | |||
| 278 | 281 | ||
| 279 | #endif | 282 | #endif |
| 280 | 283 | ||
| 284 | #ifdef CONFIG_BATMAN_ADV_DAT | ||
| 285 | /** | ||
| 286 | * batadv_dat_cache_open - Prepare file handler for reads from dat_chache | ||
| 287 | * @inode: inode which was opened | ||
| 288 | * @file: file handle to be initialized | ||
| 289 | */ | ||
| 290 | static int batadv_dat_cache_open(struct inode *inode, struct file *file) | ||
| 291 | { | ||
| 292 | struct net_device *net_dev = (struct net_device *)inode->i_private; | ||
| 293 | return single_open(file, batadv_dat_cache_seq_print_text, net_dev); | ||
| 294 | } | ||
| 295 | #endif | ||
| 296 | |||
| 281 | static int batadv_transtable_local_open(struct inode *inode, struct file *file) | 297 | static int batadv_transtable_local_open(struct inode *inode, struct file *file) |
| 282 | { | 298 | { |
| 283 | struct net_device *net_dev = (struct net_device *)inode->i_private; | 299 | struct net_device *net_dev = (struct net_device *)inode->i_private; |
| @@ -307,7 +323,17 @@ struct batadv_debuginfo batadv_debuginfo_##_name = { \ | |||
| 307 | } \ | 323 | } \ |
| 308 | }; | 324 | }; |
| 309 | 325 | ||
| 326 | /* the following attributes are general and therefore they will be directly | ||
| 327 | * placed in the BATADV_DEBUGFS_SUBDIR subdirectory of debugfs | ||
| 328 | */ | ||
| 310 | static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); | 329 | static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); |
| 330 | |||
| 331 | static struct batadv_debuginfo *batadv_general_debuginfos[] = { | ||
| 332 | &batadv_debuginfo_routing_algos, | ||
| 333 | NULL, | ||
| 334 | }; | ||
| 335 | |||
| 336 | /* The following attributes are per soft interface */ | ||
| 311 | static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open); | 337 | static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open); |
| 312 | static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open); | 338 | static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open); |
| 313 | static BATADV_DEBUGINFO(transtable_global, S_IRUGO, | 339 | static BATADV_DEBUGINFO(transtable_global, S_IRUGO, |
| @@ -317,6 +343,9 @@ static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open); | |||
| 317 | static BATADV_DEBUGINFO(bla_backbone_table, S_IRUGO, | 343 | static BATADV_DEBUGINFO(bla_backbone_table, S_IRUGO, |
| 318 | batadv_bla_backbone_table_open); | 344 | batadv_bla_backbone_table_open); |
| 319 | #endif | 345 | #endif |
| 346 | #ifdef CONFIG_BATMAN_ADV_DAT | ||
| 347 | static BATADV_DEBUGINFO(dat_cache, S_IRUGO, batadv_dat_cache_open); | ||
| 348 | #endif | ||
| 320 | static BATADV_DEBUGINFO(transtable_local, S_IRUGO, | 349 | static BATADV_DEBUGINFO(transtable_local, S_IRUGO, |
| 321 | batadv_transtable_local_open); | 350 | batadv_transtable_local_open); |
| 322 | static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); | 351 | static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); |
| @@ -329,6 +358,9 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { | |||
| 329 | &batadv_debuginfo_bla_claim_table, | 358 | &batadv_debuginfo_bla_claim_table, |
| 330 | &batadv_debuginfo_bla_backbone_table, | 359 | &batadv_debuginfo_bla_backbone_table, |
| 331 | #endif | 360 | #endif |
| 361 | #ifdef CONFIG_BATMAN_ADV_DAT | ||
| 362 | &batadv_debuginfo_dat_cache, | ||
| 363 | #endif | ||
| 332 | &batadv_debuginfo_transtable_local, | 364 | &batadv_debuginfo_transtable_local, |
| 333 | &batadv_debuginfo_vis_data, | 365 | &batadv_debuginfo_vis_data, |
| 334 | NULL, | 366 | NULL, |
| @@ -336,7 +368,7 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { | |||
| 336 | 368 | ||
| 337 | void batadv_debugfs_init(void) | 369 | void batadv_debugfs_init(void) |
| 338 | { | 370 | { |
| 339 | struct batadv_debuginfo *bat_debug; | 371 | struct batadv_debuginfo **bat_debug; |
| 340 | struct dentry *file; | 372 | struct dentry *file; |
| 341 | 373 | ||
| 342 | batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL); | 374 | batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL); |
| @@ -344,17 +376,23 @@ void batadv_debugfs_init(void) | |||
| 344 | batadv_debugfs = NULL; | 376 | batadv_debugfs = NULL; |
| 345 | 377 | ||
| 346 | if (!batadv_debugfs) | 378 | if (!batadv_debugfs) |
| 347 | goto out; | 379 | goto err; |
| 348 | 380 | ||
| 349 | bat_debug = &batadv_debuginfo_routing_algos; | 381 | for (bat_debug = batadv_general_debuginfos; *bat_debug; ++bat_debug) { |
| 350 | file = debugfs_create_file(bat_debug->attr.name, | 382 | file = debugfs_create_file(((*bat_debug)->attr).name, |
| 351 | S_IFREG | bat_debug->attr.mode, | 383 | S_IFREG | ((*bat_debug)->attr).mode, |
| 352 | batadv_debugfs, NULL, &bat_debug->fops); | 384 | batadv_debugfs, NULL, |
| 353 | if (!file) | 385 | &(*bat_debug)->fops); |
| 354 | pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name); | 386 | if (!file) { |
| 387 | pr_err("Can't add general debugfs file: %s\n", | ||
| 388 | ((*bat_debug)->attr).name); | ||
| 389 | goto err; | ||
| 390 | } | ||
| 391 | } | ||
| 355 | 392 | ||
| 356 | out: | ||
| 357 | return; | 393 | return; |
| 394 | err: | ||
| 395 | debugfs_remove_recursive(batadv_debugfs); | ||
| 358 | } | 396 | } |
| 359 | 397 | ||
| 360 | void batadv_debugfs_destroy(void) | 398 | void batadv_debugfs_destroy(void) |
