Staging: batman-adv: Update copyright years
[safe/jmp/linux-2.6] / drivers / staging / batman-adv / proc.c
1 /*
2  * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors:
3  *
4  * Marek Lindner, Simon Wunderlich
5  *
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.
9  *
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.
14  *
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
18  * 02110-1301, USA
19  *
20  */
21
22 #include "main.h"
23 #include "proc.h"
24 #include "routing.h"
25 #include "translation-table.h"
26 #include "hard-interface.h"
27 #include "types.h"
28 #include "hash.h"
29 #include "vis.h"
30
31 static struct proc_dir_entry *proc_batman_dir, *proc_interface_file;
32 static struct proc_dir_entry *proc_orig_interval_file, *proc_originators_file;
33 static struct proc_dir_entry *proc_transt_local_file;
34 static struct proc_dir_entry *proc_transt_global_file;
35 static struct proc_dir_entry *proc_vis_srv_file, *proc_vis_data_file;
36 static struct proc_dir_entry *proc_aggr_file;
37
38 static int proc_interfaces_read(struct seq_file *seq, void *offset)
39 {
40         struct batman_if *batman_if;
41
42         rcu_read_lock();
43         list_for_each_entry_rcu(batman_if, &if_list, list) {
44                 seq_printf(seq, "[%8s] %s %s\n",
45                            (batman_if->if_active == IF_ACTIVE ?
46                             "active" : "inactive"),
47                            batman_if->dev,
48                            (batman_if->if_active == IF_ACTIVE ?
49                             batman_if->addr_str : " "));
50         }
51         rcu_read_unlock();
52
53         return 0;
54 }
55
56 static int proc_interfaces_open(struct inode *inode, struct file *file)
57 {
58         return single_open(file, proc_interfaces_read, NULL);
59 }
60
61 static ssize_t proc_interfaces_write(struct file *instance,
62                                      const char __user *userbuffer,
63                                      size_t count, loff_t *data)
64 {
65         char *if_string, *colon_ptr = NULL, *cr_ptr = NULL;
66         int not_copied = 0, if_num = 0, add_success;
67         struct batman_if *batman_if = NULL;
68
69         if_string = kmalloc(count, GFP_KERNEL);
70
71         if (!if_string)
72                 return -ENOMEM;
73
74         if (count > IFNAMSIZ - 1) {
75                 printk(KERN_WARNING "batman-adv:Can't add interface: device name is too long\n");
76                 goto end;
77         }
78
79         not_copied = copy_from_user(if_string, userbuffer, count);
80         if_string[count - not_copied - 1] = 0;
81
82         colon_ptr = strchr(if_string, ':');
83         if (colon_ptr)
84                 *colon_ptr = 0;
85
86         if (!colon_ptr) {
87                 cr_ptr = strchr(if_string, '\n');
88                 if (cr_ptr)
89                         *cr_ptr = 0;
90         }
91
92         if (strlen(if_string) == 0) {
93                 shutdown_module();
94                 num_ifs = 0;
95                 goto end;
96         }
97
98         /* add interface */
99         rcu_read_lock();
100         list_for_each_entry_rcu(batman_if, &if_list, list) {
101                 if (strncmp(batman_if->dev, if_string, count) == 0) {
102                         printk(KERN_ERR "batman-adv:Given interface is already active: %s\n", if_string);
103                         rcu_read_unlock();
104                         goto end;
105
106                 }
107
108                 if_num++;
109         }
110         rcu_read_unlock();
111
112         add_success = hardif_add_interface(if_string, if_num);
113         if (add_success < 0)
114                 goto end;
115
116         num_ifs = if_num + 1;
117
118         if ((atomic_read(&module_state) == MODULE_INACTIVE) &&
119             (hardif_get_active_if_num() > 0))
120                 activate_module();
121
122         return count;
123 end:
124         kfree(if_string);
125         return count;
126 }
127
128 static int proc_orig_interval_read(struct seq_file *seq, void *offset)
129 {
130         seq_printf(seq, "%i\n", atomic_read(&originator_interval));
131
132         return 0;
133 }
134
135 static ssize_t proc_orig_interval_write(struct file *file,
136                                         const char __user *buffer,
137                                         size_t count, loff_t *ppos)
138 {
139         char *interval_string;
140         int not_copied = 0;
141         unsigned long originator_interval_tmp;
142         int retval;
143
144         interval_string = kmalloc(count, GFP_KERNEL);
145
146         if (!interval_string)
147                 return -ENOMEM;
148
149         not_copied = copy_from_user(interval_string, buffer, count);
150         interval_string[count - not_copied - 1] = 0;
151
152         retval = strict_strtoul(interval_string, 10, &originator_interval_tmp);
153         if (retval) {
154                 printk(KERN_ERR "batman-adv:New originator interval invalid\n");
155                 goto end;
156         }
157
158         if (originator_interval_tmp <= JITTER * 2) {
159                 printk(KERN_WARNING "batman-adv:New originator interval too small: %li (min: %i)\n",
160                        originator_interval_tmp, JITTER * 2);
161                 goto end;
162         }
163
164         printk(KERN_INFO "batman-adv:Changing originator interval from: %i to: %li\n",
165                atomic_read(&originator_interval), originator_interval_tmp);
166
167         atomic_set(&originator_interval, originator_interval_tmp);
168
169 end:
170         kfree(interval_string);
171         return count;
172 }
173
174 static int proc_orig_interval_open(struct inode *inode, struct file *file)
175 {
176         return single_open(file, proc_orig_interval_read, NULL);
177 }
178
179 static int proc_originators_read(struct seq_file *seq, void *offset)
180 {
181         HASHIT(hashit);
182         struct orig_node *orig_node;
183         struct neigh_node *neigh_node;
184         int batman_count = 0;
185         char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN];
186         unsigned long flags;
187
188         rcu_read_lock();
189         if (list_empty(&if_list)) {
190                 rcu_read_unlock();
191                 seq_printf(seq, "BATMAN disabled - please specify interfaces to enable it\n");
192                 goto end;
193         }
194
195         if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) {
196                 rcu_read_unlock();
197                 seq_printf(seq, "BATMAN disabled - primary interface not active\n");
198                 goto end;
199         }
200
201         seq_printf(seq,
202                    "  %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s]\n",
203                    "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF",
204                    "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR,
205                    ((struct batman_if *)if_list.next)->dev,
206                    ((struct batman_if *)if_list.next)->addr_str);
207
208         rcu_read_unlock();
209         spin_lock_irqsave(&orig_hash_lock, flags);
210
211         while (hash_iterate(orig_hash, &hashit)) {
212
213                 orig_node = hashit.bucket->data;
214
215                 if (!orig_node->router)
216                         continue;
217
218                 if (orig_node->router->tq_avg == 0)
219                         continue;
220
221                 batman_count++;
222
223                 addr_to_string(orig_str, orig_node->orig);
224                 addr_to_string(router_str, orig_node->router->addr);
225
226                 seq_printf(seq, "%-17s  (%3i) %17s [%10s]:",
227                            orig_str, orig_node->router->tq_avg,
228                            router_str, orig_node->router->if_incoming->dev);
229
230                 list_for_each_entry(neigh_node, &orig_node->neigh_list, list) {
231                         addr_to_string(orig_str, neigh_node->addr);
232                         seq_printf(seq, " %17s (%3i)",
233                                    orig_str, neigh_node->tq_avg);
234                 }
235
236                 seq_printf(seq, "\n");
237
238         }
239
240         spin_unlock_irqrestore(&orig_hash_lock, flags);
241
242         if (batman_count == 0)
243                 seq_printf(seq, "No batman nodes in range ...\n");
244
245 end:
246         return 0;
247 }
248
249 static int proc_originators_open(struct inode *inode, struct file *file)
250 {
251         return single_open(file, proc_originators_read, NULL);
252 }
253
254 static int proc_transt_local_read(struct seq_file *seq, void *offset)
255 {
256         char *buf;
257
258         buf = kmalloc(4096, GFP_KERNEL);
259         if (!buf)
260                 return 0;
261
262         rcu_read_lock();
263         if (list_empty(&if_list)) {
264                 rcu_read_unlock();
265                 seq_printf(seq, "BATMAN disabled - please specify interfaces to enable it\n");
266                 goto end;
267         }
268
269         rcu_read_unlock();
270
271         seq_printf(seq, "Locally retrieved addresses (from %s) announced via HNA:\n", soft_device->name);
272
273         hna_local_fill_buffer_text(buf, 4096);
274         seq_printf(seq, "%s", buf);
275
276 end:
277         kfree(buf);
278         return 0;
279 }
280
281 static int proc_transt_local_open(struct inode *inode, struct file *file)
282 {
283         return single_open(file, proc_transt_local_read, NULL);
284 }
285
286 static int proc_transt_global_read(struct seq_file *seq, void *offset)
287 {
288         char *buf;
289
290         buf = kmalloc(4096, GFP_KERNEL);
291         if (!buf)
292                 return 0;
293
294         rcu_read_lock();
295         if (list_empty(&if_list)) {
296                 rcu_read_unlock();
297                 seq_printf(seq, "BATMAN disabled - please specify interfaces to enable it\n");
298                 goto end;
299         }
300         rcu_read_unlock();
301
302
303         seq_printf(seq, "Globally announced HNAs received via the mesh (translation table):\n");
304
305         hna_global_fill_buffer_text(buf, 4096);
306         seq_printf(seq, "%s", buf);
307
308 end:
309         kfree(buf);
310         return 0;
311 }
312
313 static int proc_transt_global_open(struct inode *inode, struct file *file)
314 {
315         return single_open(file, proc_transt_global_read, NULL);
316 }
317
318 /* setting the mode of the vis server by the user */
319 static ssize_t proc_vis_srv_write(struct file *file, const char __user * buffer,
320                               size_t count, loff_t *ppos)
321 {
322         char *vis_mode_string;
323         int not_copied = 0;
324
325         vis_mode_string = kmalloc(count, GFP_KERNEL);
326
327         if (!vis_mode_string)
328                 return -ENOMEM;
329
330         not_copied = copy_from_user(vis_mode_string, buffer, count);
331         vis_mode_string[count - not_copied - 1] = 0;
332
333         if ((strcmp(vis_mode_string, "client") == 0) ||
334                         (strcmp(vis_mode_string, "disabled") == 0)) {
335                 printk(KERN_INFO "batman-adv:Setting VIS mode to client (disabling vis server)\n");
336                 atomic_set(&vis_mode, VIS_TYPE_CLIENT_UPDATE);
337         } else if ((strcmp(vis_mode_string, "server") == 0) ||
338                         (strcmp(vis_mode_string, "enabled") == 0)) {
339                 printk(KERN_INFO "batman-adv:Setting VIS mode to server (enabling vis server)\n");
340                 atomic_set(&vis_mode, VIS_TYPE_SERVER_SYNC);
341         } else
342                 printk(KERN_ERR "batman-adv:Unknown VIS mode: %s\n",
343                        vis_mode_string);
344
345         kfree(vis_mode_string);
346         return count;
347 }
348
349 static int proc_vis_srv_read(struct seq_file *seq, void *offset)
350 {
351         int vis_server = atomic_read(&vis_mode);
352
353         seq_printf(seq, "[%c] client mode (server disabled)\n",
354                         (vis_server == VIS_TYPE_CLIENT_UPDATE) ? 'x' : ' ');
355         seq_printf(seq, "[%c] server mode (server enabled)\n",
356                         (vis_server == VIS_TYPE_SERVER_SYNC) ? 'x' : ' ');
357
358         return 0;
359 }
360
361 static int proc_vis_srv_open(struct inode *inode, struct file *file)
362 {
363         return single_open(file, proc_vis_srv_read, NULL);
364 }
365
366 static int proc_vis_data_read(struct seq_file *seq, void *offset)
367 {
368         HASHIT(hashit);
369         struct vis_info *info;
370         struct vis_info_entry *entries;
371         HLIST_HEAD(vis_if_list);
372         struct if_list_entry *entry;
373         struct hlist_node *pos, *n;
374         int i;
375         char tmp_addr_str[ETH_STR_LEN];
376         unsigned long flags;
377         int vis_server = atomic_read(&vis_mode);
378
379         rcu_read_lock();
380         if (list_empty(&if_list) || (vis_server == VIS_TYPE_CLIENT_UPDATE)) {
381                 rcu_read_unlock();
382                 goto end;
383         }
384
385         rcu_read_unlock();
386
387         spin_lock_irqsave(&vis_hash_lock, flags);
388         while (hash_iterate(vis_hash, &hashit)) {
389                 info = hashit.bucket->data;
390                 entries = (struct vis_info_entry *)
391                         ((char *)info + sizeof(struct vis_info));
392
393                 for (i = 0; i < info->packet.entries; i++) {
394                         if (entries[i].quality == 0)
395                                 continue;
396                         proc_vis_insert_interface(entries[i].src, &vis_if_list,
397                                 compare_orig(entries[i].src,
398                                                 info->packet.vis_orig));
399                 }
400
401                 hlist_for_each_entry(entry, pos, &vis_if_list, list) {
402                         addr_to_string(tmp_addr_str, entry->addr);
403                         seq_printf(seq, "%s,", tmp_addr_str);
404
405                         for (i = 0; i < info->packet.entries; i++)
406                                 proc_vis_read_entry(seq, &entries[i],
407                                                 entry->addr, entry->primary);
408
409                         /* add primary/secondary records */
410                         if (compare_orig(entry->addr, info->packet.vis_orig))
411                                 proc_vis_read_prim_sec(seq, &vis_if_list);
412
413                         seq_printf(seq, "\n");
414                 }
415
416                 hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) {
417                         hlist_del(&entry->list);
418                         kfree(entry);
419                 }
420         }
421         spin_unlock_irqrestore(&vis_hash_lock, flags);
422
423 end:
424         return 0;
425 }
426
427 static int proc_vis_data_open(struct inode *inode, struct file *file)
428 {
429         return single_open(file, proc_vis_data_read, NULL);
430 }
431
432 static int proc_aggr_read(struct seq_file *seq, void *offset)
433 {
434         seq_printf(seq, "%i\n", atomic_read(&aggregation_enabled));
435
436         return 0;
437 }
438
439 static ssize_t proc_aggr_write(struct file *file, const char __user *buffer,
440                                size_t count, loff_t *ppos)
441 {
442         char *aggr_string;
443         int not_copied = 0;
444         unsigned long aggregation_enabled_tmp;
445         int retval;
446
447         aggr_string = kmalloc(count, GFP_KERNEL);
448
449         if (!aggr_string)
450                 return -ENOMEM;
451
452         not_copied = copy_from_user(aggr_string, buffer, count);
453         aggr_string[count - not_copied - 1] = 0;
454
455         retval = strict_strtoul(aggr_string, 10, &aggregation_enabled_tmp);
456
457         if (retval || aggregation_enabled_tmp > 1) {
458                 printk(KERN_ERR "batman-adv:Aggregation can only be enabled (1) or disabled (0), given value: %li\n", aggregation_enabled_tmp);
459         } else {
460                 printk(KERN_INFO "batman-adv:Changing aggregation from: %s (%i) to: %s (%li)\n",
461                        (atomic_read(&aggregation_enabled) == 1 ?
462                         "enabled" : "disabled"),
463                        atomic_read(&aggregation_enabled),
464                        (aggregation_enabled_tmp == 1 ? "enabled" : "disabled"),
465                        aggregation_enabled_tmp);
466                 atomic_set(&aggregation_enabled,
467                            (unsigned)aggregation_enabled_tmp);
468         }
469
470         kfree(aggr_string);
471         return count;
472 }
473
474 static int proc_aggr_open(struct inode *inode, struct file *file)
475 {
476         return single_open(file, proc_aggr_read, NULL);
477 }
478
479 /* satisfying different prototypes ... */
480 static ssize_t proc_dummy_write(struct file *file, const char __user *buffer,
481                                 size_t count, loff_t *ppos)
482 {
483         return count;
484 }
485
486 static const struct file_operations proc_aggr_fops = {
487         .owner          = THIS_MODULE,
488         .open           = proc_aggr_open,
489         .read           = seq_read,
490         .write          = proc_aggr_write,
491         .llseek         = seq_lseek,
492         .release        = single_release,
493 };
494
495 static const struct file_operations proc_vis_srv_fops = {
496         .owner          = THIS_MODULE,
497         .open           = proc_vis_srv_open,
498         .read           = seq_read,
499         .write          = proc_vis_srv_write,
500         .llseek         = seq_lseek,
501         .release        = single_release,
502 };
503
504 static const struct file_operations proc_vis_data_fops = {
505         .owner          = THIS_MODULE,
506         .open           = proc_vis_data_open,
507         .read           = seq_read,
508         .write          = proc_dummy_write,
509         .llseek         = seq_lseek,
510         .release        = single_release,
511 };
512
513 static const struct file_operations proc_originators_fops = {
514         .owner          = THIS_MODULE,
515         .open           = proc_originators_open,
516         .read           = seq_read,
517         .write          = proc_dummy_write,
518         .llseek         = seq_lseek,
519         .release        = single_release,
520 };
521
522 static const struct file_operations proc_transt_local_fops = {
523         .owner          = THIS_MODULE,
524         .open           = proc_transt_local_open,
525         .read           = seq_read,
526         .write          = proc_dummy_write,
527         .llseek         = seq_lseek,
528         .release        = single_release,
529 };
530
531 static const struct file_operations proc_transt_global_fops = {
532         .owner          = THIS_MODULE,
533         .open           = proc_transt_global_open,
534         .read           = seq_read,
535         .write          = proc_dummy_write,
536         .llseek         = seq_lseek,
537         .release        = single_release,
538 };
539
540 static const struct file_operations proc_interfaces_fops = {
541         .owner          = THIS_MODULE,
542         .open           = proc_interfaces_open,
543         .read           = seq_read,
544         .write          = proc_interfaces_write,
545         .llseek         = seq_lseek,
546         .release        = single_release,
547 };
548
549 static const struct file_operations proc_orig_interval_fops = {
550         .owner          = THIS_MODULE,
551         .open           = proc_orig_interval_open,
552         .read           = seq_read,
553         .write          = proc_orig_interval_write,
554         .llseek         = seq_lseek,
555         .release        = single_release,
556 };
557
558 void cleanup_procfs(void)
559 {
560         if (proc_transt_global_file)
561                 remove_proc_entry(PROC_FILE_TRANST_GLOBAL, proc_batman_dir);
562
563         if (proc_transt_local_file)
564                 remove_proc_entry(PROC_FILE_TRANST_LOCAL, proc_batman_dir);
565
566         if (proc_originators_file)
567                 remove_proc_entry(PROC_FILE_ORIGINATORS, proc_batman_dir);
568
569         if (proc_orig_interval_file)
570                 remove_proc_entry(PROC_FILE_ORIG_INTERVAL, proc_batman_dir);
571
572         if (proc_interface_file)
573                 remove_proc_entry(PROC_FILE_INTERFACES, proc_batman_dir);
574
575         if (proc_vis_data_file)
576                 remove_proc_entry(PROC_FILE_VIS_DATA, proc_batman_dir);
577
578         if (proc_vis_srv_file)
579                 remove_proc_entry(PROC_FILE_VIS_SRV, proc_batman_dir);
580
581         if (proc_aggr_file)
582                 remove_proc_entry(PROC_FILE_AGGR, proc_batman_dir);
583
584         if (proc_batman_dir)
585 #ifdef __NET_NET_NAMESPACE_H
586                 remove_proc_entry(PROC_ROOT_DIR, init_net.proc_net);
587 #else
588                 remove_proc_entry(PROC_ROOT_DIR, proc_net);
589 #endif
590 }
591
592 int setup_procfs(void)
593 {
594 #ifdef __NET_NET_NAMESPACE_H
595         proc_batman_dir = proc_mkdir(PROC_ROOT_DIR, init_net.proc_net);
596 #else
597         proc_batman_dir = proc_mkdir(PROC_ROOT_DIR, proc_net);
598 #endif
599
600         if (!proc_batman_dir) {
601                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s' folder failed\n", PROC_ROOT_DIR);
602                 return -EFAULT;
603         }
604
605         proc_interface_file = create_proc_entry(PROC_FILE_INTERFACES,
606                                                 S_IWUSR | S_IRUGO,
607                                                 proc_batman_dir);
608         if (proc_interface_file) {
609                 proc_interface_file->proc_fops = &proc_interfaces_fops;
610         } else {
611                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_INTERFACES);
612                 cleanup_procfs();
613                 return -EFAULT;
614         }
615
616         proc_orig_interval_file = create_proc_entry(PROC_FILE_ORIG_INTERVAL,
617                                                     S_IWUSR | S_IRUGO,
618                                                     proc_batman_dir);
619         if (proc_orig_interval_file) {
620                 proc_orig_interval_file->proc_fops = &proc_orig_interval_fops;
621         } else {
622                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_ORIG_INTERVAL);
623                 cleanup_procfs();
624                 return -EFAULT;
625         }
626
627         proc_originators_file = create_proc_entry(PROC_FILE_ORIGINATORS,
628                                                   S_IRUGO, proc_batman_dir);
629         if (proc_originators_file) {
630                 proc_originators_file->proc_fops = &proc_originators_fops;
631         } else {
632                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_ORIGINATORS);
633                 cleanup_procfs();
634                 return -EFAULT;
635         }
636
637         proc_transt_local_file = create_proc_entry(PROC_FILE_TRANST_LOCAL,
638                                                    S_IRUGO, proc_batman_dir);
639         if (proc_transt_local_file) {
640                 proc_transt_local_file->proc_fops = &proc_transt_local_fops;
641         } else {
642                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_TRANST_LOCAL);
643                 cleanup_procfs();
644                 return -EFAULT;
645         }
646
647         proc_transt_global_file = create_proc_entry(PROC_FILE_TRANST_GLOBAL,
648                                                     S_IRUGO, proc_batman_dir);
649         if (proc_transt_global_file) {
650                 proc_transt_global_file->proc_fops = &proc_transt_global_fops;
651         } else {
652                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_TRANST_GLOBAL);
653                 cleanup_procfs();
654                 return -EFAULT;
655         }
656
657         proc_vis_srv_file = create_proc_entry(PROC_FILE_VIS_SRV,
658                                                 S_IWUSR | S_IRUGO,
659                                                 proc_batman_dir);
660         if (proc_vis_srv_file) {
661                 proc_vis_srv_file->proc_fops = &proc_vis_srv_fops;
662         } else {
663                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_VIS_SRV);
664                 cleanup_procfs();
665                 return -EFAULT;
666         }
667
668         proc_vis_data_file = create_proc_entry(PROC_FILE_VIS_DATA, S_IRUGO,
669                                           proc_batman_dir);
670         if (proc_vis_data_file) {
671                 proc_vis_data_file->proc_fops = &proc_vis_data_fops;
672         } else {
673                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_VIS_DATA);
674                 cleanup_procfs();
675                 return -EFAULT;
676         }
677
678         proc_aggr_file = create_proc_entry(PROC_FILE_AGGR, S_IWUSR | S_IRUGO,
679                                            proc_batman_dir);
680         if (proc_aggr_file) {
681                 proc_aggr_file->proc_fops = &proc_aggr_fops;
682         } else {
683                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_AGGR);
684                 cleanup_procfs();
685                 return -EFAULT;
686         }
687
688         return 0;
689 }