2 * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors:
4 * Marek Lindner, Simon Wunderlich
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU General Public
8 * License as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include "translation-table.h"
27 #include "hard-interface.h"
33 static uint8_t vis_format
= DOT_DRAW
;
35 static struct proc_dir_entry
*proc_batman_dir
, *proc_interface_file
;
36 static struct proc_dir_entry
*proc_orig_interval_file
, *proc_originators_file
;
37 static struct proc_dir_entry
*proc_log_file
, *proc_log_level_file
;
38 static struct proc_dir_entry
*proc_transt_local_file
;
39 static struct proc_dir_entry
*proc_transt_global_file
;
40 static struct proc_dir_entry
*proc_vis_file
, *proc_vis_format_file
;
41 static struct proc_dir_entry
*proc_aggr_file
;
43 static int proc_interfaces_read(struct seq_file
*seq
, void *offset
)
45 struct batman_if
*batman_if
;
48 list_for_each_entry_rcu(batman_if
, &if_list
, list
) {
49 seq_printf(seq
, "[%8s] %s %s \n",
50 (batman_if
->if_active
== IF_ACTIVE
?
51 "active" : "inactive"),
53 (batman_if
->if_active
== IF_ACTIVE
?
54 batman_if
->addr_str
: " "));
61 static int proc_interfaces_open(struct inode
*inode
, struct file
*file
)
63 return single_open(file
, proc_interfaces_read
, NULL
);
66 static ssize_t
proc_interfaces_write(struct file
*instance
,
67 const char __user
*userbuffer
,
68 size_t count
, loff_t
*data
)
70 char *if_string
, *colon_ptr
= NULL
, *cr_ptr
= NULL
;
71 int not_copied
= 0, if_num
= 0;
72 struct batman_if
*batman_if
= NULL
;
74 if_string
= kmalloc(count
, GFP_KERNEL
);
79 if (count
> IFNAMSIZ
- 1) {
80 debug_log(LOG_TYPE_WARN
,
81 "Can't add interface: device name is too long\n");
85 not_copied
= copy_from_user(if_string
, userbuffer
, count
);
86 if_string
[count
- not_copied
- 1] = 0;
88 colon_ptr
= strchr(if_string
, ':');
93 cr_ptr
= strchr(if_string
, '\n');
98 if (strlen(if_string
) == 0) {
106 list_for_each_entry_rcu(batman_if
, &if_list
, list
) {
107 if (strncmp(batman_if
->dev
, if_string
, count
) == 0) {
108 debug_log(LOG_TYPE_WARN
, "Given interface is already active: %s\n", if_string
);
118 hardif_add_interface(if_string
, if_num
);
120 if ((atomic_read(&module_state
) == MODULE_INACTIVE
) &&
121 (hardif_get_active_if_num() > 0))
125 if (list_empty(&if_list
)) {
131 num_ifs
= if_num
+ 1;
139 static int proc_orig_interval_read(struct seq_file
*seq
, void *offset
)
141 seq_printf(seq
, "%i\n", atomic_read(&originator_interval
));
146 static ssize_t
proc_orig_interval_write(struct file
*file
,
147 const char __user
*buffer
,
148 size_t count
, loff_t
*ppos
)
150 char *interval_string
;
152 unsigned long originator_interval_tmp
;
155 interval_string
= kmalloc(count
, GFP_KERNEL
);
157 if (!interval_string
)
160 not_copied
= copy_from_user(interval_string
, buffer
, count
);
161 interval_string
[count
- not_copied
- 1] = 0;
163 retval
= strict_strtoul(interval_string
, 10, &originator_interval_tmp
);
165 debug_log(LOG_TYPE_WARN
, "New originator interval invalid\n");
169 if (originator_interval_tmp
<= JITTER
* 2) {
170 debug_log(LOG_TYPE_WARN
,
171 "New originator interval too small: %i (min: %i)\n",
172 originator_interval_tmp
, JITTER
* 2);
176 debug_log(LOG_TYPE_NOTICE
,
177 "Changing originator interval from: %i to: %i\n",
178 atomic_read(&originator_interval
), originator_interval_tmp
);
180 atomic_set(&originator_interval
, originator_interval_tmp
);
183 kfree(interval_string
);
187 static int proc_orig_interval_open(struct inode
*inode
, struct file
*file
)
189 return single_open(file
, proc_orig_interval_read
, NULL
);
192 static int proc_originators_read(struct seq_file
*seq
, void *offset
)
194 struct hash_it_t
*hashit
= NULL
;
195 struct orig_node
*orig_node
;
196 struct neigh_node
*neigh_node
;
197 int batman_count
= 0;
198 char orig_str
[ETH_STR_LEN
], router_str
[ETH_STR_LEN
];
201 if (list_empty(&if_list
)) {
203 seq_printf(seq
, "BATMAN disabled - please specify interfaces to enable it \n");
207 if (((struct batman_if
*)if_list
.next
)->if_active
!= IF_ACTIVE
) {
209 seq_printf(seq
, "BATMAN disabled - primary interface not active \n");
214 " %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s] \n",
215 "Originator", "#", TQ_MAX_VALUE
, "Nexthop", "outgoingIF",
216 "Potential nexthops", SOURCE_VERSION
, REVISION_VERSION_STR
,
217 ((struct batman_if
*)if_list
.next
)->dev
,
218 ((struct batman_if
*)if_list
.next
)->addr_str
);
221 spin_lock(&orig_hash_lock
);
223 while (NULL
!= (hashit
= hash_iterate(orig_hash
, hashit
))) {
225 orig_node
= hashit
->bucket
->data
;
227 if (!orig_node
->router
)
230 if (orig_node
->router
->tq_avg
== 0)
235 addr_to_string(orig_str
, orig_node
->orig
);
236 addr_to_string(router_str
, orig_node
->router
->addr
);
238 seq_printf(seq
, "%-17s (%3i) %17s [%10s]:",
239 orig_str
, orig_node
->router
->tq_avg
,
240 router_str
, orig_node
->router
->if_incoming
->dev
);
242 list_for_each_entry(neigh_node
, &orig_node
->neigh_list
, list
) {
243 addr_to_string(orig_str
, neigh_node
->addr
);
244 seq_printf(seq
, " %17s (%3i)",
245 orig_str
, neigh_node
->tq_avg
);
248 seq_printf(seq
, "\n");
252 spin_unlock(&orig_hash_lock
);
254 if (batman_count
== 0)
255 seq_printf(seq
, "No batman nodes in range ... \n");
261 static int proc_originators_open(struct inode
*inode
, struct file
*file
)
263 return single_open(file
, proc_originators_read
, NULL
);
266 static int proc_log_level_read(struct seq_file
*seq
, void *offset
)
269 seq_printf(seq
, "[x] %s (%d)\n", LOG_TYPE_CRIT_NAME
, LOG_TYPE_CRIT
);
270 seq_printf(seq
, "[%c] %s (%d)\n",
271 (LOG_TYPE_WARN
& log_level
) ? 'x' : ' ',
272 LOG_TYPE_WARN_NAME
, LOG_TYPE_WARN
);
273 seq_printf(seq
, "[%c] %s (%d)\n",
274 (LOG_TYPE_NOTICE
& log_level
) ? 'x' : ' ',
275 LOG_TYPE_NOTICE_NAME
, LOG_TYPE_NOTICE
);
276 seq_printf(seq
, "[%c] %s (%d)\n",
277 (LOG_TYPE_BATMAN
& log_level
) ? 'x' : ' ',
278 LOG_TYPE_BATMAN_NAME
, LOG_TYPE_BATMAN
);
279 seq_printf(seq
, "[%c] %s (%d)\n",
280 (LOG_TYPE_ROUTES
& log_level
) ? 'x' : ' ',
281 LOG_TYPE_ROUTES_NAME
, LOG_TYPE_ROUTES
);
285 static int proc_log_level_open(struct inode
*inode
, struct file
*file
)
287 return single_open(file
, proc_log_level_read
, NULL
);
290 static ssize_t
proc_log_level_write(struct file
*instance
,
291 const char __user
*userbuffer
,
292 size_t count
, loff_t
*data
)
294 char *log_level_string
, *tokptr
, *cp
;
295 int finished
, not_copied
= 0;
296 unsigned long log_level_tmp
= 0;
298 log_level_string
= kmalloc(count
, GFP_KERNEL
);
300 if (!log_level_string
)
303 not_copied
= copy_from_user(log_level_string
, userbuffer
, count
);
304 log_level_string
[count
- not_copied
- 1] = 0;
306 if (strict_strtoul(log_level_string
, 10, &log_level_tmp
) < 0) {
307 /* was not a number, doing textual parsing */
309 tokptr
= log_level_string
;
311 for (cp
= log_level_string
, finished
= 0; !finished
; cp
++) {
320 if (strcmp(tokptr
, LOG_TYPE_WARN_NAME
) == 0)
321 log_level_tmp
|= LOG_TYPE_WARN
;
322 if (strcmp(tokptr
, LOG_TYPE_NOTICE_NAME
) == 0)
323 log_level_tmp
|= LOG_TYPE_NOTICE
;
324 if (strcmp(tokptr
, LOG_TYPE_BATMAN_NAME
) == 0)
325 log_level_tmp
|= LOG_TYPE_BATMAN
;
326 if (strcmp(tokptr
, LOG_TYPE_ROUTES_NAME
) == 0)
327 log_level_tmp
|= LOG_TYPE_ROUTES
;
336 debug_log(LOG_TYPE_CRIT
, "Changing log_level from: %i to: %i\n",
337 log_level
, log_level_tmp
);
338 log_level
= log_level_tmp
;
340 kfree(log_level_string
);
344 static int proc_transt_local_read(struct seq_file
*seq
, void *offset
)
348 buf
= kmalloc(4096, GFP_KERNEL
);
353 if (list_empty(&if_list
)) {
355 seq_printf(seq
, "BATMAN disabled - please specify interfaces to enable it \n");
361 seq_printf(seq
, "Locally retrieved addresses (from %s) announced via HNA:\n", soft_device
->name
);
363 hna_local_fill_buffer_text(buf
, 4096);
364 seq_printf(seq
, "%s", buf
);
371 static int proc_transt_local_open(struct inode
*inode
, struct file
*file
)
373 return single_open(file
, proc_transt_local_read
, NULL
);
376 static int proc_transt_global_read(struct seq_file
*seq
, void *offset
)
380 buf
= kmalloc(4096, GFP_KERNEL
);
385 if (list_empty(&if_list
)) {
387 seq_printf(seq
, "BATMAN disabled - please specify interfaces to enable it \n");
393 seq_printf(seq
, "Globally announced HNAs received via the mesh (translation table):\n");
395 hna_global_fill_buffer_text(buf
, 4096);
396 seq_printf(seq
, "%s", buf
);
403 static int proc_transt_global_open(struct inode
*inode
, struct file
*file
)
405 return single_open(file
, proc_transt_global_read
, NULL
);
408 /* insert interface to the list of interfaces of one originator */
410 static void proc_vis_insert_interface(const uint8_t *interface
,
411 struct vis_if_list
**if_entry
,
414 /* Did we get an empty list? (then insert imediately) */
415 if(*if_entry
== NULL
) {
416 *if_entry
= kmalloc(sizeof(struct vis_if_list
), GFP_KERNEL
);
417 if (*if_entry
== NULL
)
420 (*if_entry
)->primary
= primary
;
421 (*if_entry
)->next
= NULL
;
422 memcpy((*if_entry
)->addr
, interface
, ETH_ALEN
);
424 struct vis_if_list
*head_if_entry
= *if_entry
;
425 /* Do we already have this interface in our list? */
426 while (!compare_orig((*if_entry
)->addr
, (void *)interface
)) {
428 /* Or did we reach the end (then append the interface) */
429 if ((*if_entry
)->next
== NULL
) {
430 (*if_entry
)->next
= kmalloc(sizeof(struct vis_if_list
), GFP_KERNEL
);
431 if ((*if_entry
)->next
== NULL
)
434 memcpy((*if_entry
)->next
->addr
, interface
, ETH_ALEN
);
435 (*if_entry
)->next
->primary
= primary
;
436 (*if_entry
)->next
->next
= NULL
;
439 *if_entry
= (*if_entry
)->next
;
441 /* Rewind the list to its head */
442 *if_entry
= head_if_entry
;
447 static void proc_vis_read_entry(struct seq_file
*seq
,
448 struct vis_info_entry
*entry
,
449 struct vis_if_list
**if_entry
,
451 uint8_t current_format
,
456 int int_part
, frac_part
;
458 addr_to_string(to
, entry
->dest
);
459 if (entry
->quality
== 0) {
460 #ifndef VIS_SUBCLUSTERS_DISABLED
461 proc_vis_insert_interface(vis_orig
, if_entry
, true);
462 #endif /* VIS_SUBCLUSTERS_DISABLED */
463 addr_to_string(from
, vis_orig
);
464 if (current_format
== DOT_DRAW
) {
465 seq_printf(seq
, "\t\"%s\" -> \"%s\" [label=\"HNA\"]\n",
469 "%s\t{ router : \"%s\", gateway : \"%s\", label : \"HNA\" }",
470 (first_line
? "" : ",\n"), from
, to
);
473 #ifndef VIS_SUBCLUSTERS_DISABLED
474 proc_vis_insert_interface(entry
->src
, if_entry
, compare_orig(entry
->src
, vis_orig
));
475 #endif /* VIS_SUBCLUSTERS_DISABLED */
476 addr_to_string(from
, entry
->src
);
478 /* kernel has no printf-support for %f? it'd be better to return
481 int_part
= TQ_MAX_VALUE
/ entry
->quality
;
482 frac_part
= 1000 * TQ_MAX_VALUE
/ entry
->quality
- int_part
* 1000;
484 if (current_format
== DOT_DRAW
) {
486 "\t\"%s\" -> \"%s\" [label=\"%d.%d\"]\n",
487 from
, to
, int_part
, frac_part
);
490 "%s\t{ router : \"%s\", neighbour : \"%s\", label : %d.%d }",
491 (first_line
? "" : ",\n"), from
, to
, int_part
, frac_part
);
497 static int proc_vis_read(struct seq_file
*seq
, void *offset
)
499 struct hash_it_t
*hashit
= NULL
;
500 struct vis_info
*info
;
501 struct vis_info_entry
*entries
;
502 struct vis_if_list
*if_entries
= NULL
;
504 uint8_t current_format
, first_line
= 1;
505 #ifndef VIS_SUBCLUSTERS_DISABLED
506 char tmp_addr_str
[ETH_STR_LEN
];
507 struct vis_if_list
*tmp_if_next
;
508 #endif /* VIS_SUBCLUSTERS_DISABLED */
510 current_format
= vis_format
;
513 if (list_empty(&if_list
) || (!is_vis_server())) {
515 if (current_format
== DOT_DRAW
)
516 seq_printf(seq
, "digraph {\n}\n");
522 if (current_format
== DOT_DRAW
)
523 seq_printf(seq
, "digraph {\n");
525 spin_lock(&vis_hash_lock
);
526 while (NULL
!= (hashit
= hash_iterate(vis_hash
, hashit
))) {
527 info
= hashit
->bucket
->data
;
528 entries
= (struct vis_info_entry
*)
529 ((char *)info
+ sizeof(struct vis_info
));
531 for (i
= 0; i
< info
->packet
.entries
; i
++) {
532 proc_vis_read_entry(seq
, &entries
[i
], &if_entries
,
533 info
->packet
.vis_orig
,
534 current_format
, first_line
);
539 #ifndef VIS_SUBCLUSTERS_DISABLED
540 /* Generate subgraphs from the collected items */
541 if (current_format
== DOT_DRAW
) {
543 addr_to_string(tmp_addr_str
, info
->packet
.vis_orig
);
544 seq_printf(seq
, "\tsubgraph \"cluster_%s\" {\n", tmp_addr_str
);
545 while (if_entries
!= NULL
) {
547 addr_to_string(tmp_addr_str
, if_entries
->addr
);
548 if (if_entries
->primary
)
549 seq_printf(seq
, "\t\t\"%s\" [peripheries=2]\n", tmp_addr_str
);
551 seq_printf(seq
, "\t\t\"%s\"\n", tmp_addr_str
);
553 /* ... and empty the list while doing this */
554 tmp_if_next
= if_entries
->next
;
556 if_entries
= tmp_if_next
;
558 seq_printf(seq
, "\t}\n");
560 #endif /* VIS_SUBCLUSTERS_DISABLED */
562 spin_unlock(&vis_hash_lock
);
564 if (current_format
== DOT_DRAW
)
565 seq_printf(seq
, "}\n");
567 seq_printf(seq
, "\n");
572 /* setting the mode of the vis server by the user */
573 static ssize_t
proc_vis_write(struct file
*file
, const char __user
* buffer
,
574 size_t count
, loff_t
*ppos
)
576 char *vis_mode_string
;
579 vis_mode_string
= kmalloc(count
, GFP_KERNEL
);
581 if (!vis_mode_string
)
584 not_copied
= copy_from_user(vis_mode_string
, buffer
, count
);
585 vis_mode_string
[count
- not_copied
- 1] = 0;
587 if (strcmp(vis_mode_string
, "client") == 0) {
588 debug_log(LOG_TYPE_NOTICE
, "Setting VIS mode to client\n");
589 vis_set_mode(VIS_TYPE_CLIENT_UPDATE
);
590 } else if (strcmp(vis_mode_string
, "server") == 0) {
591 debug_log(LOG_TYPE_NOTICE
, "Setting VIS mode to server\n");
592 vis_set_mode(VIS_TYPE_SERVER_SYNC
);
594 debug_log(LOG_TYPE_WARN
, "Unknown VIS mode: %s\n",
597 kfree(vis_mode_string
);
601 static int proc_vis_open(struct inode
*inode
, struct file
*file
)
603 return single_open(file
, proc_vis_read
, NULL
);
606 static int proc_vis_format_read(struct seq_file
*seq
, void *offset
)
608 uint8_t current_format
= vis_format
;
610 seq_printf(seq
, "[%c] %s\n",
611 (current_format
== DOT_DRAW
) ? 'x' : ' ',
613 seq_printf(seq
, "[%c] %s\n",
614 (current_format
== JSON
) ? 'x' : ' ',
615 VIS_FORMAT_JSON_NAME
);
619 static int proc_vis_format_open(struct inode
*inode
, struct file
*file
)
621 return single_open(file
, proc_vis_format_read
, NULL
);
624 static ssize_t
proc_vis_format_write(struct file
*file
,
625 const char __user
*buffer
,
626 size_t count
, loff_t
*ppos
)
628 char *vis_format_string
;
631 vis_format_string
= kmalloc(count
, GFP_KERNEL
);
633 if (!vis_format_string
)
636 not_copied
= copy_from_user(vis_format_string
, buffer
, count
);
637 vis_format_string
[count
- not_copied
- 1] = 0;
639 if (strcmp(vis_format_string
, VIS_FORMAT_DD_NAME
) == 0) {
640 debug_log(LOG_TYPE_NOTICE
, "Setting VIS output format to: %s\n",
642 vis_format
= DOT_DRAW
;
643 } else if (strcmp(vis_format_string
, VIS_FORMAT_JSON_NAME
) == 0) {
644 debug_log(LOG_TYPE_NOTICE
, "Setting VIS output format to: %s\n",
645 VIS_FORMAT_JSON_NAME
);
648 debug_log(LOG_TYPE_WARN
, "Unknown VIS output format: %s\n",
651 kfree(vis_format_string
);
655 static int proc_aggr_read(struct seq_file
*seq
, void *offset
)
657 seq_printf(seq
, "%i\n", atomic_read(&aggregation_enabled
));
662 static ssize_t
proc_aggr_write(struct file
*file
, const char __user
*buffer
,
663 size_t count
, loff_t
*ppos
)
667 unsigned long aggregation_enabled_tmp
;
669 aggr_string
= kmalloc(count
, GFP_KERNEL
);
674 not_copied
= copy_from_user(aggr_string
, buffer
, count
);
675 aggr_string
[count
- not_copied
- 1] = 0;
677 strict_strtoul(aggr_string
, 10, &aggregation_enabled_tmp
);
679 if ((aggregation_enabled_tmp
!= 0) && (aggregation_enabled_tmp
!= 1)) {
680 debug_log(LOG_TYPE_WARN
, "Aggregation can only be enabled (1) or disabled (0), given value: %li\n", aggregation_enabled_tmp
);
684 debug_log(LOG_TYPE_NOTICE
, "Changing aggregation from: %s (%i) to: %s (%li)\n",
685 (atomic_read(&aggregation_enabled
) == 1 ?
686 "enabled" : "disabled"),
687 atomic_read(&aggregation_enabled
),
688 (aggregation_enabled_tmp
== 1 ? "enabled" : "disabled"),
689 aggregation_enabled_tmp
);
691 atomic_set(&aggregation_enabled
, (unsigned)aggregation_enabled_tmp
);
697 static int proc_aggr_open(struct inode
*inode
, struct file
*file
)
699 return single_open(file
, proc_aggr_read
, NULL
);
702 /* satisfying different prototypes ... */
703 static ssize_t
proc_dummy_write(struct file
*file
, const char __user
*buffer
,
704 size_t count
, loff_t
*ppos
)
709 static const struct file_operations proc_aggr_fops
= {
710 .owner
= THIS_MODULE
,
711 .open
= proc_aggr_open
,
713 .write
= proc_aggr_write
,
715 .release
= single_release
,
718 static const struct file_operations proc_vis_format_fops
= {
719 .owner
= THIS_MODULE
,
720 .open
= proc_vis_format_open
,
722 .write
= proc_vis_format_write
,
724 .release
= single_release
,
727 static const struct file_operations proc_vis_fops
= {
728 .owner
= THIS_MODULE
,
729 .open
= proc_vis_open
,
731 .write
= proc_vis_write
,
733 .release
= single_release
,
736 static const struct file_operations proc_originators_fops
= {
737 .owner
= THIS_MODULE
,
738 .open
= proc_originators_open
,
740 .write
= proc_dummy_write
,
742 .release
= single_release
,
745 static const struct file_operations proc_transt_local_fops
= {
746 .owner
= THIS_MODULE
,
747 .open
= proc_transt_local_open
,
749 .write
= proc_dummy_write
,
751 .release
= single_release
,
754 static const struct file_operations proc_transt_global_fops
= {
755 .owner
= THIS_MODULE
,
756 .open
= proc_transt_global_open
,
758 .write
= proc_dummy_write
,
760 .release
= single_release
,
763 static const struct file_operations proc_log_level_fops
= {
764 .owner
= THIS_MODULE
,
765 .open
= proc_log_level_open
,
767 .write
= proc_log_level_write
,
769 .release
= single_release
,
772 static const struct file_operations proc_interfaces_fops
= {
773 .owner
= THIS_MODULE
,
774 .open
= proc_interfaces_open
,
776 .write
= proc_interfaces_write
,
778 .release
= single_release
,
781 static const struct file_operations proc_orig_interval_fops
= {
782 .owner
= THIS_MODULE
,
783 .open
= proc_orig_interval_open
,
785 .write
= proc_orig_interval_write
,
787 .release
= single_release
,
790 void cleanup_procfs(void)
792 if (proc_transt_global_file
)
793 remove_proc_entry(PROC_FILE_TRANST_GLOBAL
, proc_batman_dir
);
795 if (proc_transt_local_file
)
796 remove_proc_entry(PROC_FILE_TRANST_LOCAL
, proc_batman_dir
);
799 remove_proc_entry(PROC_FILE_LOG
, proc_batman_dir
);
801 if (proc_log_level_file
)
802 remove_proc_entry(PROC_FILE_LOG_LEVEL
, proc_batman_dir
);
804 if (proc_originators_file
)
805 remove_proc_entry(PROC_FILE_ORIGINATORS
, proc_batman_dir
);
807 if (proc_orig_interval_file
)
808 remove_proc_entry(PROC_FILE_ORIG_INTERVAL
, proc_batman_dir
);
810 if (proc_interface_file
)
811 remove_proc_entry(PROC_FILE_INTERFACES
, proc_batman_dir
);
814 remove_proc_entry(PROC_FILE_VIS
, proc_batman_dir
);
816 if (proc_vis_format_file
)
817 remove_proc_entry(PROC_FILE_VIS_FORMAT
, proc_batman_dir
);
820 remove_proc_entry(PROC_FILE_AGGR
, proc_batman_dir
);
823 #ifdef __NET_NET_NAMESPACE_H
824 remove_proc_entry(PROC_ROOT_DIR
, init_net
.proc_net
);
826 remove_proc_entry(PROC_ROOT_DIR
, proc_net
);
830 int setup_procfs(void)
832 #ifdef __NET_NET_NAMESPACE_H
833 proc_batman_dir
= proc_mkdir(PROC_ROOT_DIR
, init_net
.proc_net
);
835 proc_batman_dir
= proc_mkdir(PROC_ROOT_DIR
, proc_net
);
838 if (!proc_batman_dir
) {
839 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s' folder failed\n", PROC_ROOT_DIR
);
843 proc_interface_file
= create_proc_entry(PROC_FILE_INTERFACES
,
846 if (proc_interface_file
) {
847 proc_interface_file
->proc_fops
= &proc_interfaces_fops
;
849 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR
, PROC_FILE_INTERFACES
);
854 proc_orig_interval_file
= create_proc_entry(PROC_FILE_ORIG_INTERVAL
,
857 if (proc_orig_interval_file
) {
858 proc_orig_interval_file
->proc_fops
= &proc_orig_interval_fops
;
860 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR
, PROC_FILE_ORIG_INTERVAL
);
865 proc_log_level_file
= create_proc_entry(PROC_FILE_LOG_LEVEL
,
868 if (proc_log_level_file
) {
869 proc_log_level_file
->proc_fops
= &proc_log_level_fops
;
871 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR
, PROC_FILE_LOG_LEVEL
);
876 proc_originators_file
= create_proc_entry(PROC_FILE_ORIGINATORS
,
877 S_IRUGO
, proc_batman_dir
);
878 if (proc_originators_file
) {
879 proc_originators_file
->proc_fops
= &proc_originators_fops
;
881 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR
, PROC_FILE_ORIGINATORS
);
886 proc_log_file
= create_proc_entry(PROC_FILE_LOG
,
887 S_IRUGO
, proc_batman_dir
);
889 proc_log_file
->proc_fops
= &proc_log_operations
;
891 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_FILE_LOG
, PROC_FILE_GATEWAYS
);
896 proc_transt_local_file
= create_proc_entry(PROC_FILE_TRANST_LOCAL
,
897 S_IRUGO
, proc_batman_dir
);
898 if (proc_transt_local_file
) {
899 proc_transt_local_file
->proc_fops
= &proc_transt_local_fops
;
901 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR
, PROC_FILE_TRANST_LOCAL
);
906 proc_transt_global_file
= create_proc_entry(PROC_FILE_TRANST_GLOBAL
,
907 S_IRUGO
, proc_batman_dir
);
908 if (proc_transt_global_file
) {
909 proc_transt_global_file
->proc_fops
= &proc_transt_global_fops
;
911 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR
, PROC_FILE_TRANST_GLOBAL
);
916 proc_vis_file
= create_proc_entry(PROC_FILE_VIS
, S_IWUSR
| S_IRUGO
,
919 proc_vis_file
->proc_fops
= &proc_vis_fops
;
921 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR
, PROC_FILE_VIS
);
926 proc_vis_format_file
= create_proc_entry(PROC_FILE_VIS_FORMAT
,
929 if (proc_vis_format_file
) {
930 proc_vis_format_file
->proc_fops
= &proc_vis_format_fops
;
932 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR
, PROC_FILE_VIS_FORMAT
);
937 proc_aggr_file
= create_proc_entry(PROC_FILE_AGGR
, S_IWUSR
| S_IRUGO
,
939 if (proc_aggr_file
) {
940 proc_aggr_file
->proc_fops
= &proc_aggr_fops
;
942 printk(KERN_ERR
"batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR
, PROC_FILE_AGGR
);