Changeset 1594
- Timestamp:
- 03/11/10 20:18:53 (6 months ago)
- Location:
- trunk/batman-adv-kernelland
- Files:
-
- 1 added
- 15 modified
- 1 copied
-
Makefile.kbuild (modified) (1 diff)
-
aggregation.c (modified) (2 diffs)
-
aggregation.h (modified) (1 diff)
-
bat_sysfs.c (added)
-
bat_sysfs.h (copied) (copied from trunk/batman-adv-kernelland/originator.h) (2 diffs)
-
main.c (modified) (6 diffs)
-
main.h (modified) (1 diff)
-
originator.c (modified) (3 diffs)
-
originator.h (modified) (1 diff)
-
proc.c (modified) (12 diffs)
-
proc.h (modified) (1 diff)
-
routing.c (modified) (7 diffs)
-
routing.h (modified) (1 diff)
-
send.c (modified) (5 diffs)
-
translation-table.c (modified) (6 diffs)
-
translation-table.h (modified) (2 diffs)
-
types.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/batman-adv-kernelland/Makefile.kbuild
r1556 r1594 33 33 34 34 obj-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)35 batman-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 160 160 void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len, 161 161 struct batman_if *if_incoming, char own_packet, 162 unsigned long send_time) 162 unsigned long send_time, 163 struct bat_priv *bat_priv) 163 164 { 164 165 /** … … 176 177 spin_lock_irqsave(&forw_bat_list_lock, flags); 177 178 /* 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)) { 179 180 hlist_for_each_entry(forw_packet_pos, tmp_node, &forw_bat_list, 180 181 list) { -
trunk/batman-adv-kernelland/aggregation.h
r1462 r1594 33 33 void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len, 34 34 struct batman_if *if_outgoing, char own_packet, 35 unsigned long send_time); 35 unsigned long send_time, 36 struct bat_priv *bat_priv); 36 37 void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff, 37 38 int packet_len, struct batman_if *if_incoming); -
trunk/batman-adv-kernelland/bat_sysfs.h
r1494 r1594 1 1 /* 2 * Copyright (C) 20 07-2009B.A.T.M.A.N. contributors:2 * Copyright (C) 2010 B.A.T.M.A.N. contributors: 3 3 * 4 * Marek Lindner , Simon Wunderlich4 * Marek Lindner 5 5 * 6 6 * This program is free software; you can redistribute it and/or … … 20 20 */ 21 21 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 25 int sysfs_add_meshif(struct net_device *dev); 26 void sysfs_del_meshif(struct net_device *dev); -
trunk/batman-adv-kernelland/main.c
r1557 r1594 22 22 #include "main.h" 23 23 #include "proc.h" 24 #include "bat_sysfs.h" 24 25 #include "routing.h" 25 26 #include "send.h" … … 48 49 atomic_t vis_interval; 49 50 atomic_t vis_mode; 50 atomic_t aggregation_enabled;51 atomic_t bonding_enabled;52 51 int16_t num_hna; 53 52 int16_t num_ifs; … … 90 89 * for debugging now. */ 91 90 atomic_set(&vis_mode, VIS_TYPE_CLIENT_UPDATE); 92 atomic_set(&aggregation_enabled, 1);93 atomic_set(&bonding_enabled, 0);94 91 atomic_set(&gw_mode, GW_MODE_OFF); 95 92 atomic_set(&gw_srv_class, 0); … … 125 122 } 126 123 124 retval = sysfs_add_meshif(soft_device); 125 126 if (retval < 0) 127 goto unreg_soft_device; 128 127 129 register_netdevice_notifier(&hard_if_notifier); 128 130 dev_add_pack(&batman_adv_packet_type); … … 133 135 return 0; 134 136 137 unreg_soft_device: 138 unregister_netdevice(soft_device); 135 139 free_soft_device: 136 140 free_netdev(soft_device); … … 145 149 146 150 if (soft_device) { 151 sysfs_del_meshif(soft_device); 147 152 unregister_netdev(soft_device); 148 153 soft_device = NULL; -
trunk/batman-adv-kernelland/main.h
r1557 r1594 137 137 extern atomic_t vis_interval; 138 138 extern atomic_t vis_mode; 139 extern atomic_t aggregation_enabled;140 139 extern atomic_t bonding_enabled; 141 140 extern int16_t num_hna; -
trunk/batman-adv-kernelland/originator.c
r1551 r1594 211 211 static bool purge_orig_node(struct orig_node *orig_node) 212 212 { 213 /* FIXME: each batman_if will be attached to a softif */ 214 struct bat_priv *bat_priv = netdev_priv(soft_device); 213 215 struct neigh_node *best_neigh_node; 214 216 … … 228 230 /* update bonding candidates, we could have lost 229 231 * some candidates. */ 230 update_bonding_candidates(orig_node );232 update_bonding_candidates(orig_node, bat_priv); 231 233 } 232 234 } … … 259 261 start_purge_timer(); 260 262 } 263 264 ssize_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 29 29 create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, 30 30 uint8_t *neigh, struct batman_if *if_incoming); 31 ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off); -
trunk/batman-adv-kernelland/proc.c
r1589 r1594 33 33 34 34 static 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; 35 static struct proc_dir_entry *proc_orig_interval_file; 38 36 static struct proc_dir_entry *proc_vis_srv_file, *proc_vis_data_file; 39 static struct proc_dir_entry *proc_aggr_file, *proc_bond_file;40 37 static struct proc_dir_entry *proc_gw_mode_file, *proc_gw_srv_list_file; 41 38 … … 179 176 { 180 177 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);320 178 } 321 179 … … 434 292 } 435 293 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 483 294 static int proc_gw_mode_read(struct seq_file *seq, void *offset) 484 295 { … … 573 384 } 574 385 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 623 386 /* satisfying different prototypes ... */ 624 387 static ssize_t proc_dummy_write(struct file *file, const char __user *buffer, … … 646 409 }; 647 410 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 666 411 static const struct file_operations proc_vis_srv_fops = { 667 412 .owner = THIS_MODULE, … … 682 427 }; 683 428 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 711 429 static const struct file_operations proc_interfaces_fops = { 712 430 .owner = THIS_MODULE, … … 729 447 void cleanup_procfs(void) 730 448 { 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 740 449 if (proc_orig_interval_file) 741 450 remove_proc_entry(PROC_FILE_ORIG_INTERVAL, proc_batman_dir); … … 750 459 remove_proc_entry(PROC_FILE_VIS_SRV, proc_batman_dir); 751 460 752 if (proc_aggr_file)753 remove_proc_entry(PROC_FILE_AGGR, proc_batman_dir);754 755 461 if (proc_gw_mode_file) 756 462 remove_proc_entry(PROC_FILE_GW_MODE, proc_batman_dir); … … 758 464 if (proc_gw_srv_list_file) 759 465 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 764 466 765 467 if (proc_batman_dir) … … 806 508 } 807 509 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 838 510 proc_vis_srv_file = create_proc_entry(PROC_FILE_VIS_SRV, 839 511 S_IWUSR | S_IRUGO, … … 853 525 } else { 854 526 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);865 527 cleanup_procfs(); 866 528 return -EFAULT; … … 891 553 } 892 554 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 26 26 #define PROC_FILE_INTERFACES "interfaces" 27 27 #define PROC_FILE_ORIG_INTERVAL "orig_interval" 28 #define PROC_FILE_ORIGINATORS "originators"29 28 #define PROC_FILE_GATEWAYS "gateways" 30 29 #define PROC_FILE_LOG "log" 31 30 #define PROC_FILE_LOG_LEVEL "log_level" 32 #define PROC_FILE_TRANST_LOCAL "transtable_local"33 #define PROC_FILE_TRANST_GLOBAL "transtable_global"34 31 #define PROC_FILE_VIS_SRV "vis_server" 35 32 #define PROC_FILE_VIS_DATA "vis_data" 36 #define PROC_FILE_AGGR "aggregate_ogm"37 #define PROC_FILE_BOND "bonding"38 33 #define PROC_FILE_GW_MODE "gateway_mode" 39 34 #define PROC_FILE_GW_SRV_LIST "gateway_srv_list" -
trunk/batman-adv-kernelland/routing.c
r1574 r1594 364 364 /* copy primary address for bonding */ 365 365 static 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) 368 369 369 370 { 370 371 /* don't care if bonding is not enabled */ 371 if (!atomic_read(&b onding_enabled)) {372 if (!atomic_read(&bat_priv->bonding_enabled)) { 372 373 orig_node->bond.candidates = 0; 373 374 return; … … 376 377 if (batman_packet->flags & PRIMARIES_FIRST_HOP) 377 378 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; 381 382 } 382 383 383 384 /* mark possible bonding candidates in the neighbor list */ 384 void update_bonding_candidates(struct orig_node *orig_node) 385 void update_bonding_candidates(struct orig_node *orig_node, 386 struct bat_priv *bat_priv) 385 387 { 386 388 int candidates; … … 388 390 int best_tq; 389 391 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; 391 393 392 394 /* don't care if bonding is not enabled */ 393 if (!atomic_read(&b onding_enabled)) {395 if (!atomic_read(&bat_priv->bonding_enabled)) { 394 396 orig_node->bond.candidates = 0; 395 397 return; … … 478 480 struct batman_if *if_incoming) 479 481 { 482 /* FIXME: each orig_node->batman_if will be attached to a softif */ 483 struct bat_priv *bat_priv = netdev_priv(soft_device); 480 484 struct batman_if *batman_if; 481 485 struct orig_node *orig_neigh_node, *orig_node; … … 639 643 if_incoming, hna_buff, hna_buff_len, is_duplicate); 640 644 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); 643 648 644 649 /* is single hop (direct) neighbor */ … … 929 934 struct neigh_node *find_router(struct orig_node *orig_node) 930 935 { 936 /* FIXME: each orig_node->batman_if will be attached to a softif */ 937 struct bat_priv *bat_priv = netdev_priv(soft_device); 931 938 struct orig_node *primary_orig_node; 932 939 struct orig_node *router_orig; … … 941 948 942 949 /* don't care if bonding is not enabled */ 943 if (!atomic_read(&b onding_enabled))950 if (!atomic_read(&bat_priv->bonding_enabled)) 944 951 return orig_node->router; 945 952 -
trunk/batman-adv-kernelland/routing.h
r1555 r1594 39 39 struct batman_if *batman_if); 40 40 struct neigh_node *find_router(struct orig_node *orig_node); 41 void update_bonding_candidates(struct orig_node *orig_node); 41 void update_bonding_candidates(struct orig_node *orig_node, 42 struct bat_priv *bat_priv); -
trunk/batman-adv-kernelland/send.c
r1557 r1594 48 48 49 49 /* when do we schedule a forwarded packet to be sent */ 50 static unsigned long forward_send_time( void)50 static unsigned long forward_send_time(struct bat_priv *bat_priv) 51 51 { 52 52 unsigned long send_time = jiffies; /* Starting now plus... */ 53 53 54 if (atomic_read(& aggregation_enabled))54 if (atomic_read(&bat_priv->aggregation_enabled)) 55 55 send_time += (((MAX_AGGREGATION_MS - (JITTER/2) + 56 56 (random32() % JITTER)) * HZ) / 1000); … … 250 250 void schedule_own_packet(struct batman_if *batman_if) 251 251 { 252 /* FIXME: each batman_if will be attached to a softif */ 253 struct bat_priv *bat_priv = netdev_priv(soft_device); 252 254 unsigned long send_time; 253 255 struct batman_packet *batman_packet; … … 290 292 send_time = own_send_time(); 291 293 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); 293 297 } 294 298 … … 299 303 struct batman_if *if_incoming) 300 304 { 305 /* FIXME: each batman_if will be attached to a softif */ 306 struct bat_priv *bat_priv = netdev_priv(soft_device); 301 307 unsigned char in_tq, in_ttl, tq_avg = 0; 302 308 unsigned long send_time; … … 344 350 batman_packet->flags &= ~DIRECTLINK; 345 351 346 send_time = forward_send_time( );352 send_time = forward_send_time(bat_priv); 347 353 add_bat_packet_to_list((unsigned char *)batman_packet, 348 354 sizeof(struct batman_packet) + hna_buff_len, 349 if_incoming, 0, send_time); 355 if_incoming, 0, send_time, 356 bat_priv); 350 357 } 351 358 -
trunk/batman-adv-kernelland/translation-table.c
r1526 r1594 158 158 } 159 159 160 int hna_local_fill_buffer_text(unsigned char *buff, int buff_len) 160 int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff, 161 size_t count, loff_t off) 161 162 { 162 163 struct hna_local_entry *hna_local_entry; … … 164 165 int bytes_written = 0; 165 166 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; 166 175 167 176 spin_lock_irqsave(&hna_local_hash_lock, flags); 168 177 169 178 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) 172 182 break; 173 183 184 if (off >= hdr_len) 185 continue; 186 174 187 hna_local_entry = hashit.bucket->data; 175 188 176 bytes_written += snprintf(buff + bytes_written, ETH_STR_LEN + 4,189 bytes_written += snprintf(buff + bytes_written, 22, 177 190 " * %02x:%02x:%02x:%02x:%02x:%02x\n", 178 191 hna_local_entry->addr[0], … … 185 198 186 199 spin_unlock_irqrestore(&hna_local_hash_lock, flags); 187 188 200 return bytes_written; 189 201 } … … 350 362 } 351 363 352 int hna_global_fill_buffer_text(unsigned char *buff, int buff_len) 364 int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff, 365 size_t count, loff_t off) 353 366 { 354 367 struct hna_global_entry *hna_global_entry; … … 356 369 int bytes_written = 0; 357 370 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; 358 379 359 380 spin_lock_irqsave(&hna_global_hash_lock, flags); 360 381 361 382 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) 363 386 break; 364 387 388 if (off >= hdr_len) 389 continue; 390 365 391 hna_global_entry = hashit.bucket->data; 366 392 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", 370 395 hna_global_entry->addr[0], 371 396 hna_global_entry->addr[1], … … 383 408 384 409 spin_unlock_irqrestore(&hna_global_hash_lock, flags); 385 386 410 return bytes_written; 387 411 } -
trunk/batman-adv-kernelland/translation-table.h
r1518 r1594 26 26 void hna_local_remove(uint8_t *addr, char *message); 27 27 int hna_local_fill_buffer(unsigned char *buff, int buff_len); 28 int hna_local_fill_buffer_text(unsigned char *buff, int buff_len); 28 int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff, 29 size_t count, loff_t off); 29 30 void hna_local_purge(struct work_struct *work); 30 31 void hna_local_free(void); … … 32 33 void hna_global_add_orig(struct orig_node *orig_node, unsigned char *hna_buff, 33 34 int hna_buff_len); 34 int hna_global_fill_buffer_text(unsigned char *buff, int buff_len); 35 int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff, 36 size_t count, loff_t off); 35 37 void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, 36 38 char *orig_str); -
trunk/batman-adv-kernelland/types.h
r1574 r1594 95 95 struct bat_priv { 96 96 struct net_device_stats stats; 97 atomic_t aggregation_enabled; 98 atomic_t bonding_enabled; 99 struct kobject *mesh_obj; 97 100 }; 98 101
