diff options
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/debugfs.c | 73 | ||||
-rw-r--r-- | net/batman-adv/debugfs.h | 2 | ||||
-rw-r--r-- | net/batman-adv/hard-interface.c | 9 | ||||
-rw-r--r-- | net/batman-adv/types.h | 2 |
4 files changed, 86 insertions, 0 deletions
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index 0adbcee80d24..2ea36952139a 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c | |||
@@ -369,6 +369,25 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { | |||
369 | NULL, | 369 | NULL, |
370 | }; | 370 | }; |
371 | 371 | ||
372 | #define BATADV_HARDIF_DEBUGINFO(_name, _mode, _open) \ | ||
373 | struct batadv_debuginfo batadv_hardif_debuginfo_##_name = { \ | ||
374 | .attr = { \ | ||
375 | .name = __stringify(_name), \ | ||
376 | .mode = _mode, \ | ||
377 | }, \ | ||
378 | .fops = { \ | ||
379 | .owner = THIS_MODULE, \ | ||
380 | .open = _open, \ | ||
381 | .read = seq_read, \ | ||
382 | .llseek = seq_lseek, \ | ||
383 | .release = single_release, \ | ||
384 | }, \ | ||
385 | }; | ||
386 | |||
387 | static struct batadv_debuginfo *batadv_hardif_debuginfos[] = { | ||
388 | NULL, | ||
389 | }; | ||
390 | |||
372 | void batadv_debugfs_init(void) | 391 | void batadv_debugfs_init(void) |
373 | { | 392 | { |
374 | struct batadv_debuginfo **bat_debug; | 393 | struct batadv_debuginfo **bat_debug; |
@@ -396,6 +415,7 @@ void batadv_debugfs_init(void) | |||
396 | return; | 415 | return; |
397 | err: | 416 | err: |
398 | debugfs_remove_recursive(batadv_debugfs); | 417 | debugfs_remove_recursive(batadv_debugfs); |
418 | batadv_debugfs = NULL; | ||
399 | } | 419 | } |
400 | 420 | ||
401 | void batadv_debugfs_destroy(void) | 421 | void batadv_debugfs_destroy(void) |
@@ -404,6 +424,59 @@ void batadv_debugfs_destroy(void) | |||
404 | batadv_debugfs = NULL; | 424 | batadv_debugfs = NULL; |
405 | } | 425 | } |
406 | 426 | ||
427 | /** | ||
428 | * batadv_debugfs_add_hardif - creates the base directory for a hard interface | ||
429 | * in debugfs. | ||
430 | * @hard_iface: hard interface which should be added. | ||
431 | */ | ||
432 | int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface) | ||
433 | { | ||
434 | struct batadv_debuginfo **bat_debug; | ||
435 | struct dentry *file; | ||
436 | |||
437 | if (!batadv_debugfs) | ||
438 | goto out; | ||
439 | |||
440 | hard_iface->debug_dir = debugfs_create_dir(hard_iface->net_dev->name, | ||
441 | batadv_debugfs); | ||
442 | if (!hard_iface->debug_dir) | ||
443 | goto out; | ||
444 | |||
445 | for (bat_debug = batadv_hardif_debuginfos; *bat_debug; ++bat_debug) { | ||
446 | file = debugfs_create_file(((*bat_debug)->attr).name, | ||
447 | S_IFREG | ((*bat_debug)->attr).mode, | ||
448 | hard_iface->debug_dir, | ||
449 | hard_iface->net_dev, | ||
450 | &(*bat_debug)->fops); | ||
451 | if (!file) | ||
452 | goto rem_attr; | ||
453 | } | ||
454 | |||
455 | return 0; | ||
456 | rem_attr: | ||
457 | debugfs_remove_recursive(hard_iface->debug_dir); | ||
458 | hard_iface->debug_dir = NULL; | ||
459 | out: | ||
460 | #ifdef CONFIG_DEBUG_FS | ||
461 | return -ENOMEM; | ||
462 | #else | ||
463 | return 0; | ||
464 | #endif /* CONFIG_DEBUG_FS */ | ||
465 | } | ||
466 | |||
467 | /** | ||
468 | * batadv_debugfs_del_hardif - delete the base directory for a hard interface | ||
469 | * in debugfs. | ||
470 | * @hard_iface: hard interface which is deleted. | ||
471 | */ | ||
472 | void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface) | ||
473 | { | ||
474 | if (batadv_debugfs) { | ||
475 | debugfs_remove_recursive(hard_iface->debug_dir); | ||
476 | hard_iface->debug_dir = NULL; | ||
477 | } | ||
478 | } | ||
479 | |||
407 | int batadv_debugfs_add_meshif(struct net_device *dev) | 480 | int batadv_debugfs_add_meshif(struct net_device *dev) |
408 | { | 481 | { |
409 | struct batadv_priv *bat_priv = netdev_priv(dev); | 482 | struct batadv_priv *bat_priv = netdev_priv(dev); |
diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h index 0861b629e1a8..981794f6d420 100644 --- a/net/batman-adv/debugfs.h +++ b/net/batman-adv/debugfs.h | |||
@@ -24,5 +24,7 @@ void batadv_debugfs_init(void); | |||
24 | void batadv_debugfs_destroy(void); | 24 | void batadv_debugfs_destroy(void); |
25 | int batadv_debugfs_add_meshif(struct net_device *dev); | 25 | int batadv_debugfs_add_meshif(struct net_device *dev); |
26 | void batadv_debugfs_del_meshif(struct net_device *dev); | 26 | void batadv_debugfs_del_meshif(struct net_device *dev); |
27 | int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface); | ||
28 | void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface); | ||
27 | 29 | ||
28 | #endif /* _NET_BATMAN_ADV_DEBUGFS_H_ */ | 30 | #endif /* _NET_BATMAN_ADV_DEBUGFS_H_ */ |
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index bebd46ce0ebd..3f0e41a50514 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "translation-table.h" | 23 | #include "translation-table.h" |
24 | #include "routing.h" | 24 | #include "routing.h" |
25 | #include "sysfs.h" | 25 | #include "sysfs.h" |
26 | #include "debugfs.h" | ||
26 | #include "originator.h" | 27 | #include "originator.h" |
27 | #include "hash.h" | 28 | #include "hash.h" |
28 | #include "bridge_loop_avoidance.h" | 29 | #include "bridge_loop_avoidance.h" |
@@ -539,6 +540,7 @@ static void batadv_hardif_remove_interface_finish(struct work_struct *work) | |||
539 | hard_iface = container_of(work, struct batadv_hard_iface, | 540 | hard_iface = container_of(work, struct batadv_hard_iface, |
540 | cleanup_work); | 541 | cleanup_work); |
541 | 542 | ||
543 | batadv_debugfs_del_hardif(hard_iface); | ||
542 | batadv_sysfs_del_hardif(&hard_iface->hardif_obj); | 544 | batadv_sysfs_del_hardif(&hard_iface->hardif_obj); |
543 | batadv_hardif_free_ref(hard_iface); | 545 | batadv_hardif_free_ref(hard_iface); |
544 | } | 546 | } |
@@ -569,6 +571,11 @@ batadv_hardif_add_interface(struct net_device *net_dev) | |||
569 | hard_iface->net_dev = net_dev; | 571 | hard_iface->net_dev = net_dev; |
570 | hard_iface->soft_iface = NULL; | 572 | hard_iface->soft_iface = NULL; |
571 | hard_iface->if_status = BATADV_IF_NOT_IN_USE; | 573 | hard_iface->if_status = BATADV_IF_NOT_IN_USE; |
574 | |||
575 | ret = batadv_debugfs_add_hardif(hard_iface); | ||
576 | if (ret) | ||
577 | goto free_sysfs; | ||
578 | |||
572 | INIT_LIST_HEAD(&hard_iface->list); | 579 | INIT_LIST_HEAD(&hard_iface->list); |
573 | INIT_WORK(&hard_iface->cleanup_work, | 580 | INIT_WORK(&hard_iface->cleanup_work, |
574 | batadv_hardif_remove_interface_finish); | 581 | batadv_hardif_remove_interface_finish); |
@@ -585,6 +592,8 @@ batadv_hardif_add_interface(struct net_device *net_dev) | |||
585 | 592 | ||
586 | return hard_iface; | 593 | return hard_iface; |
587 | 594 | ||
595 | free_sysfs: | ||
596 | batadv_sysfs_del_hardif(&hard_iface->hardif_obj); | ||
588 | free_if: | 597 | free_if: |
589 | kfree(hard_iface); | 598 | kfree(hard_iface); |
590 | release_dev: | 599 | release_dev: |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 1409279cb5d2..529b3747a085 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
@@ -84,6 +84,7 @@ struct batadv_hard_iface_bat_iv { | |||
84 | * @rcu: struct used for freeing in an RCU-safe manner | 84 | * @rcu: struct used for freeing in an RCU-safe manner |
85 | * @bat_iv: BATMAN IV specific per hard interface data | 85 | * @bat_iv: BATMAN IV specific per hard interface data |
86 | * @cleanup_work: work queue callback item for hard interface deinit | 86 | * @cleanup_work: work queue callback item for hard interface deinit |
87 | * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs | ||
87 | */ | 88 | */ |
88 | struct batadv_hard_iface { | 89 | struct batadv_hard_iface { |
89 | struct list_head list; | 90 | struct list_head list; |
@@ -98,6 +99,7 @@ struct batadv_hard_iface { | |||
98 | struct rcu_head rcu; | 99 | struct rcu_head rcu; |
99 | struct batadv_hard_iface_bat_iv bat_iv; | 100 | struct batadv_hard_iface_bat_iv bat_iv; |
100 | struct work_struct cleanup_work; | 101 | struct work_struct cleanup_work; |
102 | struct dentry *debug_dir; | ||
101 | }; | 103 | }; |
102 | 104 | ||
103 | /** | 105 | /** |