Changeset 1594

Show
Ignore:
Timestamp:
03/11/10 20:18:53 (6 months ago)
Author:
marek
Message:

batman-adv: convert multiple /proc files to use sysfs

This is the first patch in a series of patches which aim to convert
all batman-adv /proc files to sysfs. To keep the changes in a
digestable size it has been split up into smaller chunks. During
the transition period batman-adv will use /proc as well as sysfs.

As a first step the following files have been converted:
aggregate_ogm, bonding, originators, transtable_global, transtable_local

Signed-off-by: Marek Lindner <lindner_marek@…>

Location:
trunk/batman-adv-kernelland
Files:
1 added
15 modified
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/batman-adv-kernelland/Makefile.kbuild

    r1556 r1594  
    3333 
    3434obj-m += batman-adv.o 
    35 batman-adv-objs := main.o proc.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o gateway_common.o gateway_client.o $(shell [ "2" -eq "$(VERSION)" ] 2>&- && [ "6" -eq "$(PATCHLEVEL)" ] 2>&- && [ "$(SUBLEVEL)" -le "28" ] 2>&- && echo bat_printk.o) 
     35batman-adv-objs := main.o proc.o bat_sysfs.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o gateway_common.o gateway_client.o $(shell [ "2" -eq "$(VERSION)" ] 2>&- && [ "6" -eq "$(PATCHLEVEL)" ] 2>&- && [ "$(SUBLEVEL)" -le "28" ] 2>&- && echo bat_printk.o) 
  • trunk/batman-adv-kernelland/aggregation.c

    r1517 r1594  
    160160void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len, 
    161161                            struct batman_if *if_incoming, char own_packet, 
    162                             unsigned long send_time) 
     162                            unsigned long send_time, 
     163                            struct bat_priv *bat_priv) 
    163164{ 
    164165        /** 
     
    176177        spin_lock_irqsave(&forw_bat_list_lock, flags); 
    177178        /* own packets are not to be aggregated */ 
    178         if ((atomic_read(&aggregation_enabled)) && (!own_packet)) { 
     179        if ((atomic_read(&bat_priv->aggregation_enabled)) && (!own_packet)) { 
    179180                hlist_for_each_entry(forw_packet_pos, tmp_node, &forw_bat_list, 
    180181                                     list) { 
  • trunk/batman-adv-kernelland/aggregation.h

    r1462 r1594  
    3333void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len, 
    3434                            struct batman_if *if_outgoing, char own_packet, 
    35                             unsigned long send_time); 
     35                            unsigned long send_time, 
     36                            struct bat_priv *bat_priv); 
    3637void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff, 
    3738                             int packet_len, struct batman_if *if_incoming); 
  • trunk/batman-adv-kernelland/bat_sysfs.h

    r1494 r1594  
    11/* 
    2  * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: 
     2 * Copyright (C) 2010 B.A.T.M.A.N. contributors: 
    33 * 
    4  * Marek Lindner, Simon Wunderlich 
     4 * Marek Lindner 
    55 * 
    66 * This program is free software; you can redistribute it and/or 
     
    2020 */ 
    2121 
    22 int originator_init(void); 
    23 void free_orig_node(void *data); 
    24 void originator_free(void); 
    25 void purge_orig(struct work_struct *work); 
    26 struct orig_node *orig_find(char *mac); 
    27 struct orig_node *get_orig_node(uint8_t *addr); 
    28 struct neigh_node * 
    29 create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, 
    30                 uint8_t *neigh, struct batman_if *if_incoming); 
     22 
     23#define SYSFS_IF_MESH_SUBDIR "mesh" 
     24 
     25int sysfs_add_meshif(struct net_device *dev); 
     26void sysfs_del_meshif(struct net_device *dev); 
  • trunk/batman-adv-kernelland/main.c

    r1557 r1594  
    2222#include "main.h" 
    2323#include "proc.h" 
     24#include "bat_sysfs.h" 
    2425#include "routing.h" 
    2526#include "send.h" 
     
    4849atomic_t vis_interval; 
    4950atomic_t vis_mode; 
    50 atomic_t aggregation_enabled; 
    51 atomic_t bonding_enabled; 
    5251int16_t num_hna; 
    5352int16_t num_ifs; 
     
    9089                                         * for debugging now. */ 
    9190        atomic_set(&vis_mode, VIS_TYPE_CLIENT_UPDATE); 
    92         atomic_set(&aggregation_enabled, 1); 
    93         atomic_set(&bonding_enabled, 0); 
    9491        atomic_set(&gw_mode, GW_MODE_OFF); 
    9592        atomic_set(&gw_srv_class, 0); 
     
    125122        } 
    126123 
     124        retval = sysfs_add_meshif(soft_device); 
     125 
     126        if (retval < 0) 
     127                goto unreg_soft_device; 
     128 
    127129        register_netdevice_notifier(&hard_if_notifier); 
    128130        dev_add_pack(&batman_adv_packet_type); 
     
    133135        return 0; 
    134136 
     137unreg_soft_device: 
     138        unregister_netdevice(soft_device); 
    135139free_soft_device: 
    136140        free_netdev(soft_device); 
     
    145149 
    146150        if (soft_device) { 
     151                sysfs_del_meshif(soft_device); 
    147152                unregister_netdev(soft_device); 
    148153                soft_device = NULL; 
  • trunk/batman-adv-kernelland/main.h

    r1557 r1594  
    137137extern atomic_t vis_interval; 
    138138extern atomic_t vis_mode; 
    139 extern atomic_t aggregation_enabled; 
    140139extern atomic_t bonding_enabled; 
    141140extern int16_t num_hna; 
  • trunk/batman-adv-kernelland/originator.c

    r1551 r1594  
    211211static bool purge_orig_node(struct orig_node *orig_node) 
    212212{ 
     213        /* FIXME: each batman_if will be attached to a softif */ 
     214        struct bat_priv *bat_priv = netdev_priv(soft_device); 
    213215        struct neigh_node *best_neigh_node; 
    214216 
     
    228230                        /* update bonding candidates, we could have lost 
    229231                         * some candidates. */ 
    230                         update_bonding_candidates(orig_node); 
     232                        update_bonding_candidates(orig_node, bat_priv); 
    231233                } 
    232234        } 
     
    259261        start_purge_timer(); 
    260262} 
     263 
     264ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off) 
     265{ 
     266        HASHIT(hashit); 
     267        struct orig_node *orig_node; 
     268        struct neigh_node *neigh_node; 
     269        size_t hdr_len, tmp_len; 
     270        int batman_count = 0, bytes_written = 0; 
     271        unsigned long flags; 
     272        char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN]; 
     273 
     274        rcu_read_lock(); 
     275        hdr_len = sprintf(buff, 
     276                   "  %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s] \n", 
     277                   "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", 
     278                   "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR, 
     279                   ((struct batman_if *)if_list.next)->dev, 
     280                   ((struct batman_if *)if_list.next)->addr_str); 
     281        rcu_read_unlock(); 
     282 
     283        if (off < hdr_len) 
     284                bytes_written = hdr_len; 
     285 
     286        spin_lock_irqsave(&orig_hash_lock, flags); 
     287 
     288        while (hash_iterate(orig_hash, &hashit)) { 
     289 
     290                orig_node = hashit.bucket->data; 
     291 
     292                if (!orig_node->router) 
     293                        continue; 
     294 
     295                if (orig_node->router->tq_avg == 0) 
     296                        continue; 
     297 
     298                /* estimated line length */ 
     299                if (count < bytes_written + 200) 
     300                        break; 
     301 
     302                addr_to_string(orig_str, orig_node->orig); 
     303                addr_to_string(router_str, orig_node->router->addr); 
     304 
     305                tmp_len = sprintf(buff + bytes_written, 
     306                                  "%-17s  (%3i) %17s [%10s]:", 
     307                                   orig_str, orig_node->router->tq_avg, 
     308                                   router_str, 
     309                                   orig_node->router->if_incoming->dev); 
     310 
     311                list_for_each_entry(neigh_node, &orig_node->neigh_list, list) { 
     312                        addr_to_string(orig_str, neigh_node->addr); 
     313                        tmp_len += sprintf(buff + bytes_written + tmp_len, 
     314                                           " %17s (%3i)", orig_str, 
     315                                           neigh_node->tq_avg); 
     316                } 
     317 
     318                tmp_len += sprintf(buff + bytes_written + tmp_len, "\n"); 
     319 
     320                batman_count++; 
     321                hdr_len += tmp_len; 
     322 
     323                if (off >= hdr_len) 
     324                        continue; 
     325 
     326                bytes_written += tmp_len; 
     327        } 
     328 
     329        spin_unlock_irqrestore(&orig_hash_lock, flags); 
     330 
     331        if ((batman_count == 0) && (off == 0)) 
     332                bytes_written += sprintf(buff + bytes_written, 
     333                                        "No batman nodes in range ... \n"); 
     334 
     335        return bytes_written; 
     336} 
  • trunk/batman-adv-kernelland/originator.h

    r1494 r1594  
    2929create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, 
    3030                uint8_t *neigh, struct batman_if *if_incoming); 
     31ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off); 
  • trunk/batman-adv-kernelland/proc.c

    r1589 r1594  
    3333 
    3434static struct proc_dir_entry *proc_batman_dir, *proc_interface_file; 
    35 static struct proc_dir_entry *proc_orig_interval_file, *proc_originators_file; 
    36 static struct proc_dir_entry *proc_transt_local_file; 
    37 static struct proc_dir_entry *proc_transt_global_file; 
     35static struct proc_dir_entry *proc_orig_interval_file; 
    3836static struct proc_dir_entry *proc_vis_srv_file, *proc_vis_data_file; 
    39 static struct proc_dir_entry *proc_aggr_file, *proc_bond_file; 
    4037static struct proc_dir_entry *proc_gw_mode_file, *proc_gw_srv_list_file; 
    4138 
     
    179176{ 
    180177        return single_open(file, proc_orig_interval_read, NULL); 
    181 } 
    182  
    183 static int proc_originators_read(struct seq_file *seq, void *offset) 
    184 { 
    185         HASHIT(hashit); 
    186         struct orig_node *orig_node; 
    187         struct neigh_node *neigh_node; 
    188         int batman_count = 0; 
    189         char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN]; 
    190         unsigned long flags; 
    191  
    192         rcu_read_lock(); 
    193         if (list_empty(&if_list)) { 
    194                 rcu_read_unlock(); 
    195                 seq_printf(seq, "BATMAN disabled - please specify interfaces to enable it \n"); 
    196                 goto end; 
    197         } 
    198  
    199         if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) { 
    200                 rcu_read_unlock(); 
    201                 seq_printf(seq, "BATMAN disabled - primary interface not active \n"); 
    202                 goto end; 
    203         } 
    204  
    205         seq_printf(seq, 
    206                    "  %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s] \n", 
    207                    "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", 
    208                    "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR, 
    209                    ((struct batman_if *)if_list.next)->dev, 
    210                    ((struct batman_if *)if_list.next)->addr_str); 
    211  
    212         rcu_read_unlock(); 
    213         spin_lock_irqsave(&orig_hash_lock, flags); 
    214  
    215         while (hash_iterate(orig_hash, &hashit)) { 
    216  
    217                 orig_node = hashit.bucket->data; 
    218  
    219                 if (!orig_node->router) 
    220                         continue; 
    221  
    222                 if (orig_node->router->tq_avg == 0) 
    223                         continue; 
    224  
    225                 batman_count++; 
    226  
    227                 addr_to_string(orig_str, orig_node->orig); 
    228                 addr_to_string(router_str, orig_node->router->addr); 
    229  
    230                 seq_printf(seq, "%-17s  (%3i) %17s [%10s]:", 
    231                            orig_str, orig_node->router->tq_avg, 
    232                            router_str, orig_node->router->if_incoming->dev); 
    233  
    234                 list_for_each_entry(neigh_node, &orig_node->neigh_list, list) { 
    235                         addr_to_string(orig_str, neigh_node->addr); 
    236                         seq_printf(seq, " %17s (%3i)", 
    237                                    orig_str, neigh_node->tq_avg); 
    238                 } 
    239  
    240                 seq_printf(seq, "\n"); 
    241  
    242         } 
    243  
    244         spin_unlock_irqrestore(&orig_hash_lock, flags); 
    245  
    246         if (batman_count == 0) 
    247                 seq_printf(seq, "No batman nodes in range ... \n"); 
    248  
    249 end: 
    250         return 0; 
    251 } 
    252  
    253 static int proc_originators_open(struct inode *inode, struct file *file) 
    254 { 
    255         return single_open(file, proc_originators_read, NULL); 
    256 } 
    257  
    258 static int proc_transt_local_read(struct seq_file *seq, void *offset) 
    259 { 
    260         char *buf; 
    261  
    262         buf = kmalloc(4096, GFP_KERNEL); 
    263         if (!buf) 
    264                 return 0; 
    265  
    266         rcu_read_lock(); 
    267         if (list_empty(&if_list)) { 
    268                 rcu_read_unlock(); 
    269                 seq_printf(seq, "BATMAN disabled - please specify interfaces to enable it \n"); 
    270                 goto end; 
    271         } 
    272  
    273         rcu_read_unlock(); 
    274  
    275         seq_printf(seq, "Locally retrieved addresses (from %s) announced via HNA:\n", soft_device->name); 
    276  
    277         hna_local_fill_buffer_text(buf, 4096); 
    278         seq_printf(seq, "%s", buf); 
    279  
    280 end: 
    281         kfree(buf); 
    282         return 0; 
    283 } 
    284  
    285 static int proc_transt_local_open(struct inode *inode, struct file *file) 
    286 { 
    287         return single_open(file, proc_transt_local_read, NULL); 
    288 } 
    289  
    290 static int proc_transt_global_read(struct seq_file *seq, void *offset) 
    291 { 
    292         char *buf; 
    293  
    294         buf = kmalloc(4096, GFP_KERNEL); 
    295         if (!buf) 
    296                 return 0; 
    297  
    298         rcu_read_lock(); 
    299         if (list_empty(&if_list)) { 
    300                 rcu_read_unlock(); 
    301                 seq_printf(seq, "BATMAN disabled - please specify interfaces to enable it \n"); 
    302                 goto end; 
    303         } 
    304         rcu_read_unlock(); 
    305  
    306  
    307         seq_printf(seq, "Globally announced HNAs received via the mesh (translation table):\n"); 
    308  
    309         hna_global_fill_buffer_text(buf, 4096); 
    310         seq_printf(seq, "%s", buf); 
    311  
    312 end: 
    313         kfree(buf); 
    314         return 0; 
    315 } 
    316  
    317 static int proc_transt_global_open(struct inode *inode, struct file *file) 
    318 { 
    319         return single_open(file, proc_transt_global_read, NULL); 
    320178} 
    321179 
     
    434292} 
    435293 
    436 static int proc_aggr_read(struct seq_file *seq, void *offset) 
    437 { 
    438         seq_printf(seq, "%i\n", atomic_read(&aggregation_enabled)); 
    439  
    440         return 0; 
    441 } 
    442  
    443 static ssize_t proc_aggr_write(struct file *file, const char __user *buffer, 
    444                                size_t count, loff_t *ppos) 
    445 { 
    446         char *aggr_string; 
    447         int not_copied = 0; 
    448         unsigned long aggregation_enabled_tmp; 
    449         int retval; 
    450  
    451         aggr_string = kmalloc(count, GFP_KERNEL); 
    452  
    453         if (!aggr_string) 
    454                 return -ENOMEM; 
    455  
    456         not_copied = copy_from_user(aggr_string, buffer, count); 
    457         aggr_string[count - not_copied - 1] = 0; 
    458  
    459         retval = strict_strtoul(aggr_string, 10, &aggregation_enabled_tmp); 
    460  
    461         if (retval || aggregation_enabled_tmp > 1) { 
    462                 printk(KERN_ERR "batman-adv:Aggregation can only be enabled (1) or disabled (0), given value: %li\n", aggregation_enabled_tmp); 
    463         } else { 
    464                 printk(KERN_INFO "batman-adv:Changing aggregation from: %s (%i) to: %s (%li)\n", 
    465                        (atomic_read(&aggregation_enabled) == 1 ? 
    466                         "enabled" : "disabled"), 
    467                        atomic_read(&aggregation_enabled), 
    468                        (aggregation_enabled_tmp == 1 ? "enabled" : "disabled"), 
    469                        aggregation_enabled_tmp); 
    470                 atomic_set(&aggregation_enabled,  
    471                                                 (unsigned)aggregation_enabled_tmp); 
    472         } 
    473  
    474         kfree(aggr_string); 
    475         return count; 
    476 } 
    477  
    478 static int proc_aggr_open(struct inode *inode, struct file *file) 
    479 { 
    480         return single_open(file, proc_aggr_read, NULL); 
    481 } 
    482  
    483294static int proc_gw_mode_read(struct seq_file *seq, void *offset) 
    484295{ 
     
    573384} 
    574385 
    575  
    576 static int proc_bond_read(struct seq_file *seq, void *offset) 
    577 { 
    578         seq_printf(seq, "%i\n", atomic_read(&bonding_enabled)); 
    579  
    580         return 0; 
    581 } 
    582  
    583 static ssize_t proc_bond_write(struct file *file, const char __user *buffer, 
    584                                size_t count, loff_t *ppos) 
    585 { 
    586         char *bond_string; 
    587         int not_copied = 0; 
    588         unsigned long bonding_enabled_tmp; 
    589         int retval; 
    590  
    591         bond_string = kmalloc(count, GFP_KERNEL); 
    592  
    593         if (!bond_string) 
    594                 return -ENOMEM; 
    595  
    596         not_copied = copy_from_user(bond_string, buffer, count); 
    597         bond_string[count - not_copied - 1] = 0; 
    598  
    599         retval = strict_strtoul(bond_string, 10, &bonding_enabled_tmp); 
    600  
    601         if (retval || bonding_enabled_tmp > 1) { 
    602                 printk(KERN_ERR "batman-adv: Bonding can only be enabled (1) or disabled (0), given value: %li\n", bonding_enabled_tmp); 
    603         } else { 
    604                 printk(KERN_INFO "batman-adv:Changing bonding from: %s (%i) to: %s (%li)\n", 
    605                        (atomic_read(&bonding_enabled) == 1 ? 
    606                         "enabled" : "disabled"), 
    607                        atomic_read(&bonding_enabled), 
    608                        (bonding_enabled_tmp == 1 ? "enabled" : "disabled"), 
    609                        bonding_enabled_tmp); 
    610                 atomic_set(&bonding_enabled, 
    611                                                 (unsigned)bonding_enabled_tmp); 
    612         } 
    613  
    614         kfree(bond_string); 
    615         return count; 
    616 } 
    617  
    618 static int proc_bond_open(struct inode *inode, struct file *file) 
    619 { 
    620         return single_open(file, proc_bond_read, NULL); 
    621 } 
    622  
    623386/* satisfying different prototypes ... */ 
    624387static ssize_t proc_dummy_write(struct file *file, const char __user *buffer, 
     
    646409}; 
    647410 
    648 static const struct file_operations proc_aggr_fops = { 
    649         .owner          = THIS_MODULE, 
    650         .open           = proc_aggr_open, 
    651         .read           = seq_read, 
    652         .write          = proc_aggr_write, 
    653         .llseek         = seq_lseek, 
    654         .release        = single_release, 
    655 }; 
    656  
    657 static const struct file_operations proc_bond_fops = { 
    658         .owner          = THIS_MODULE, 
    659         .open           = proc_bond_open, 
    660         .read           = seq_read, 
    661         .write          = proc_bond_write, 
    662         .llseek         = seq_lseek, 
    663         .release        = single_release, 
    664 }; 
    665  
    666411static const struct file_operations proc_vis_srv_fops = { 
    667412        .owner          = THIS_MODULE, 
     
    682427}; 
    683428 
    684 static const struct file_operations proc_originators_fops = { 
    685         .owner          = THIS_MODULE, 
    686         .open           = proc_originators_open, 
    687         .read           = seq_read, 
    688         .write          = proc_dummy_write, 
    689         .llseek         = seq_lseek, 
    690         .release        = single_release, 
    691 }; 
    692  
    693 static const struct file_operations proc_transt_local_fops = { 
    694         .owner          = THIS_MODULE, 
    695         .open           = proc_transt_local_open, 
    696         .read           = seq_read, 
    697         .write          = proc_dummy_write, 
    698         .llseek         = seq_lseek, 
    699         .release        = single_release, 
    700 }; 
    701  
    702 static const struct file_operations proc_transt_global_fops = { 
    703         .owner          = THIS_MODULE, 
    704         .open           = proc_transt_global_open, 
    705         .read           = seq_read, 
    706         .write          = proc_dummy_write, 
    707         .llseek         = seq_lseek, 
    708         .release        = single_release, 
    709 }; 
    710  
    711429static const struct file_operations proc_interfaces_fops = { 
    712430        .owner          = THIS_MODULE, 
     
    729447void cleanup_procfs(void) 
    730448{ 
    731         if (proc_transt_global_file) 
    732                 remove_proc_entry(PROC_FILE_TRANST_GLOBAL, proc_batman_dir); 
    733  
    734         if (proc_transt_local_file) 
    735                 remove_proc_entry(PROC_FILE_TRANST_LOCAL, proc_batman_dir); 
    736  
    737         if (proc_originators_file) 
    738                 remove_proc_entry(PROC_FILE_ORIGINATORS, proc_batman_dir); 
    739  
    740449        if (proc_orig_interval_file) 
    741450                remove_proc_entry(PROC_FILE_ORIG_INTERVAL, proc_batman_dir); 
     
    750459                remove_proc_entry(PROC_FILE_VIS_SRV, proc_batman_dir); 
    751460 
    752         if (proc_aggr_file) 
    753                 remove_proc_entry(PROC_FILE_AGGR, proc_batman_dir); 
    754  
    755461        if (proc_gw_mode_file) 
    756462                remove_proc_entry(PROC_FILE_GW_MODE, proc_batman_dir); 
     
    758464        if (proc_gw_srv_list_file) 
    759465                remove_proc_entry(PROC_FILE_GW_SRV_LIST, proc_batman_dir); 
    760  
    761         if (proc_bond_file) 
    762                 remove_proc_entry(PROC_FILE_BOND, proc_batman_dir); 
    763  
    764466 
    765467        if (proc_batman_dir) 
     
    806508        } 
    807509 
    808         proc_originators_file = create_proc_entry(PROC_FILE_ORIGINATORS, 
    809                                                   S_IRUGO, proc_batman_dir); 
    810         if (proc_originators_file) { 
    811                 proc_originators_file->proc_fops = &proc_originators_fops; 
    812         } else { 
    813                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_ORIGINATORS); 
    814                 cleanup_procfs(); 
    815                 return -EFAULT; 
    816         } 
    817  
    818         proc_transt_local_file = create_proc_entry(PROC_FILE_TRANST_LOCAL, 
    819                                                    S_IRUGO, proc_batman_dir); 
    820         if (proc_transt_local_file) { 
    821                 proc_transt_local_file->proc_fops = &proc_transt_local_fops; 
    822         } else { 
    823                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_TRANST_LOCAL); 
    824                 cleanup_procfs(); 
    825                 return -EFAULT; 
    826         } 
    827  
    828         proc_transt_global_file = create_proc_entry(PROC_FILE_TRANST_GLOBAL, 
    829                                                     S_IRUGO, proc_batman_dir); 
    830         if (proc_transt_global_file) { 
    831                 proc_transt_global_file->proc_fops = &proc_transt_global_fops; 
    832         } else { 
    833                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_TRANST_GLOBAL); 
    834                 cleanup_procfs(); 
    835                 return -EFAULT; 
    836         } 
    837  
    838510        proc_vis_srv_file = create_proc_entry(PROC_FILE_VIS_SRV, 
    839511                                                S_IWUSR | S_IRUGO, 
     
    853525        } else { 
    854526                printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_VIS_DATA); 
    855                 cleanup_procfs(); 
    856                 return -EFAULT; 
    857         } 
    858  
    859         proc_aggr_file = create_proc_entry(PROC_FILE_AGGR, S_IWUSR | S_IRUGO, 
    860                                            proc_batman_dir); 
    861         if (proc_aggr_file) { 
    862                 proc_aggr_file->proc_fops = &proc_aggr_fops; 
    863         } else { 
    864                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_AGGR); 
    865527                cleanup_procfs(); 
    866528                return -EFAULT; 
     
    891553        } 
    892554 
    893         proc_bond_file = create_proc_entry(PROC_FILE_BOND, S_IWUSR | S_IRUGO, 
    894                                            proc_batman_dir); 
    895         if (proc_bond_file) { 
    896                 proc_bond_file->proc_fops = &proc_bond_fops; 
    897         } else { 
    898                 printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_BOND); 
    899                 cleanup_procfs(); 
    900                 return -EFAULT; 
    901         } 
    902  
    903         return 0; 
    904 } 
     555        return 0; 
     556} 
  • trunk/batman-adv-kernelland/proc.h

    r1551 r1594  
    2626#define PROC_FILE_INTERFACES "interfaces" 
    2727#define PROC_FILE_ORIG_INTERVAL "orig_interval" 
    28 #define PROC_FILE_ORIGINATORS "originators" 
    2928#define PROC_FILE_GATEWAYS "gateways" 
    3029#define PROC_FILE_LOG "log" 
    3130#define PROC_FILE_LOG_LEVEL "log_level" 
    32 #define PROC_FILE_TRANST_LOCAL "transtable_local" 
    33 #define PROC_FILE_TRANST_GLOBAL "transtable_global" 
    3431#define PROC_FILE_VIS_SRV "vis_server" 
    3532#define PROC_FILE_VIS_DATA "vis_data" 
    36 #define PROC_FILE_AGGR "aggregate_ogm" 
    37 #define PROC_FILE_BOND "bonding" 
    3833#define PROC_FILE_GW_MODE "gateway_mode" 
    3934#define PROC_FILE_GW_SRV_LIST "gateway_srv_list" 
  • trunk/batman-adv-kernelland/routing.c

    r1574 r1594  
    364364/* copy primary address for bonding */ 
    365365static void mark_bonding_address(struct orig_node *orig_node, 
    366                                 struct orig_node *orig_neigh_node, 
    367                                 struct batman_packet *batman_packet) 
     366                                 struct orig_node *orig_neigh_node, 
     367                                 struct batman_packet *batman_packet, 
     368                                 struct bat_priv *bat_priv) 
    368369 
    369370{ 
    370371        /* don't care if bonding is not enabled */ 
    371         if (!atomic_read(&bonding_enabled)) { 
     372        if (!atomic_read(&bat_priv->bonding_enabled)) { 
    372373                orig_node->bond.candidates = 0; 
    373374                return; 
     
    376377        if (batman_packet->flags & PRIMARIES_FIRST_HOP) 
    377378                memcpy(orig_neigh_node->primary_addr, 
    378                                                 orig_node->orig, ETH_ALEN); 
    379          else 
    380                 return; 
     379                       orig_node->orig, ETH_ALEN); 
     380 
     381        return; 
    381382} 
    382383 
    383384/* mark possible bonding candidates in the neighbor list */ 
    384 void update_bonding_candidates(struct orig_node *orig_node) 
     385void update_bonding_candidates(struct orig_node *orig_node, 
     386                               struct bat_priv *bat_priv) 
    385387{ 
    386388        int candidates; 
     
    388390        int best_tq; 
    389391        struct neigh_node *tmp_neigh_node, *tmp_neigh_node2; 
    390     struct neigh_node *first_candidate, *last_candidate; 
     392        struct neigh_node *first_candidate, *last_candidate; 
    391393 
    392394        /* don't care if bonding is not enabled */ 
    393         if (!atomic_read(&bonding_enabled)) { 
     395        if (!atomic_read(&bat_priv->bonding_enabled)) { 
    394396                orig_node->bond.candidates = 0; 
    395397                return; 
     
    478480                                struct batman_if *if_incoming) 
    479481{ 
     482        /* FIXME: each orig_node->batman_if will be attached to a softif */ 
     483        struct bat_priv *bat_priv = netdev_priv(soft_device); 
    480484        struct batman_if *batman_if; 
    481485        struct orig_node *orig_neigh_node, *orig_node; 
     
    639643                            if_incoming, hna_buff, hna_buff_len, is_duplicate); 
    640644 
    641         mark_bonding_address(orig_node, orig_neigh_node, batman_packet); 
    642         update_bonding_candidates(orig_node); 
     645        mark_bonding_address(orig_node, orig_neigh_node, 
     646                             batman_packet, bat_priv); 
     647        update_bonding_candidates(orig_node, bat_priv); 
    643648 
    644649        /* is single hop (direct) neighbor */ 
     
    929934struct neigh_node *find_router(struct orig_node *orig_node) 
    930935{ 
     936        /* FIXME: each orig_node->batman_if will be attached to a softif */ 
     937        struct bat_priv *bat_priv = netdev_priv(soft_device); 
    931938        struct orig_node *primary_orig_node; 
    932939        struct orig_node *router_orig; 
     
    941948 
    942949        /* don't care if bonding is not enabled */ 
    943         if (!atomic_read(&bonding_enabled)) 
     950        if (!atomic_read(&bat_priv->bonding_enabled)) 
    944951                return orig_node->router; 
    945952 
  • trunk/batman-adv-kernelland/routing.h

    r1555 r1594  
    3939                                struct batman_if *batman_if); 
    4040struct neigh_node *find_router(struct orig_node *orig_node); 
    41 void update_bonding_candidates(struct orig_node *orig_node); 
     41void update_bonding_candidates(struct orig_node *orig_node, 
     42                               struct bat_priv *bat_priv); 
  • trunk/batman-adv-kernelland/send.c

    r1557 r1594  
    4848 
    4949/* when do we schedule a forwarded packet to be sent */ 
    50 static unsigned long forward_send_time(void) 
     50static unsigned long forward_send_time(struct bat_priv *bat_priv) 
    5151{ 
    5252        unsigned long send_time = jiffies; /* Starting now plus... */ 
    5353 
    54         if (atomic_read(&aggregation_enabled)) 
     54        if (atomic_read(&bat_priv->aggregation_enabled)) 
    5555                send_time += (((MAX_AGGREGATION_MS - (JITTER/2) + 
    5656                                (random32() % JITTER)) * HZ) / 1000); 
     
    250250void schedule_own_packet(struct batman_if *batman_if) 
    251251{ 
     252        /* FIXME: each batman_if will be attached to a softif */ 
     253        struct bat_priv *bat_priv = netdev_priv(soft_device); 
    252254        unsigned long send_time; 
    253255        struct batman_packet *batman_packet; 
     
    290292        send_time = own_send_time(); 
    291293        add_bat_packet_to_list(batman_if->packet_buff, 
    292                                batman_if->packet_len, batman_if, 1, send_time); 
     294                               batman_if->packet_len, 
     295                               batman_if, 1, send_time, 
     296                               bat_priv); 
    293297} 
    294298 
     
    299303                             struct batman_if *if_incoming) 
    300304{ 
     305        /* FIXME: each batman_if will be attached to a softif */ 
     306        struct bat_priv *bat_priv = netdev_priv(soft_device); 
    301307        unsigned char in_tq, in_ttl, tq_avg = 0; 
    302308        unsigned long send_time; 
     
    344350                batman_packet->flags &= ~DIRECTLINK; 
    345351 
    346         send_time = forward_send_time(); 
     352        send_time = forward_send_time(bat_priv); 
    347353        add_bat_packet_to_list((unsigned char *)batman_packet, 
    348354                               sizeof(struct batman_packet) + hna_buff_len, 
    349                                if_incoming, 0, send_time); 
     355                               if_incoming, 0, send_time, 
     356                               bat_priv); 
    350357} 
    351358 
  • trunk/batman-adv-kernelland/translation-table.c

    r1526 r1594  
    158158} 
    159159 
    160 int hna_local_fill_buffer_text(unsigned char *buff, int buff_len) 
     160int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff, 
     161                               size_t count, loff_t off) 
    161162{ 
    162163        struct hna_local_entry *hna_local_entry; 
     
    164165        int bytes_written = 0; 
    165166        unsigned long flags; 
     167        size_t hdr_len; 
     168 
     169        hdr_len = sprintf(buff, 
     170                          "Locally retrieved addresses (from %s) announced via HNA:\n", 
     171                          net_dev->name); 
     172 
     173        if (off < hdr_len) 
     174                bytes_written = hdr_len; 
    166175 
    167176        spin_lock_irqsave(&hna_local_hash_lock, flags); 
    168177 
    169178        while (hash_iterate(hna_local_hash, &hashit)) { 
    170  
    171                 if (buff_len < bytes_written + ETH_STR_LEN + 4) 
     179                hdr_len += 21; 
     180 
     181                if (count < bytes_written + 22) 
    172182                        break; 
    173183 
     184                if (off >= hdr_len) 
     185                        continue; 
     186 
    174187                hna_local_entry = hashit.bucket->data; 
    175188 
    176                 bytes_written += snprintf(buff + bytes_written, ETH_STR_LEN + 4, 
     189                bytes_written += snprintf(buff + bytes_written, 22, 
    177190                                          " * %02x:%02x:%02x:%02x:%02x:%02x\n", 
    178191                                          hna_local_entry->addr[0], 
     
    185198 
    186199        spin_unlock_irqrestore(&hna_local_hash_lock, flags); 
    187  
    188200        return bytes_written; 
    189201} 
     
    350362} 
    351363 
    352 int hna_global_fill_buffer_text(unsigned char *buff, int buff_len) 
     364int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff, 
     365                                size_t count, loff_t off) 
    353366{ 
    354367        struct hna_global_entry *hna_global_entry; 
     
    356369        int bytes_written = 0; 
    357370        unsigned long flags; 
     371        size_t hdr_len; 
     372 
     373        hdr_len = sprintf(buff, 
     374                          "Globally announced HNAs received via the mesh %s (translation table):\n", 
     375                          net_dev->name); 
     376 
     377        if (off < hdr_len) 
     378                bytes_written = hdr_len; 
    358379 
    359380        spin_lock_irqsave(&hna_global_hash_lock, flags); 
    360381 
    361382        while (hash_iterate(hna_global_hash, &hashit)) { 
    362                 if (buff_len < bytes_written + (2 * ETH_STR_LEN) + 10) 
     383                hdr_len += 43; 
     384 
     385                if (count < bytes_written + 44) 
    363386                        break; 
    364387 
     388                if (off >= hdr_len) 
     389                        continue; 
     390 
    365391                hna_global_entry = hashit.bucket->data; 
    366392 
    367                 bytes_written += snprintf(buff + bytes_written, 
    368                                           (2 * ETH_STR_LEN) + 10, 
    369                                           " * %02x:%02x:%02x:%02x:%02x:%02x via %02x:%02x:%02x:%02x:%02x:%02x \n", 
     393                bytes_written += snprintf(buff + bytes_written, 44, 
     394                                          " * %02x:%02x:%02x:%02x:%02x:%02x via %02x:%02x:%02x:%02x:%02x:%02x\n", 
    370395                                          hna_global_entry->addr[0], 
    371396                                          hna_global_entry->addr[1], 
     
    383408 
    384409        spin_unlock_irqrestore(&hna_global_hash_lock, flags); 
    385  
    386410        return bytes_written; 
    387411} 
  • trunk/batman-adv-kernelland/translation-table.h

    r1518 r1594  
    2626void hna_local_remove(uint8_t *addr, char *message); 
    2727int hna_local_fill_buffer(unsigned char *buff, int buff_len); 
    28 int hna_local_fill_buffer_text(unsigned char *buff, int buff_len); 
     28int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff, 
     29                               size_t count, loff_t off); 
    2930void hna_local_purge(struct work_struct *work); 
    3031void hna_local_free(void); 
     
    3233void hna_global_add_orig(struct orig_node *orig_node, unsigned char *hna_buff, 
    3334                         int hna_buff_len); 
    34 int hna_global_fill_buffer_text(unsigned char *buff, int buff_len); 
     35int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff, 
     36                                size_t count, loff_t off); 
    3537void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, 
    3638                          char *orig_str); 
  • trunk/batman-adv-kernelland/types.h

    r1574 r1594  
    9595struct bat_priv { 
    9696        struct net_device_stats stats; 
     97        atomic_t aggregation_enabled; 
     98        atomic_t bonding_enabled; 
     99        struct kobject *mesh_obj; 
    97100}; 
    98101