The following commit has been merged in the linux branch: commit dde26910e49b944d9f310284b2238d7ae9536523 Merge: b0e4cc81db8213bfdca376557cc35dcda9298364 087625b70d2114b02cc0edb97c7d8edd9d2a9b71 Author: Andrew Lunn lunn@lunn.ch Date: Sun Nov 8 18:55:25 2009 +0100
Merge remote branch 'origin/master' into linux
diff --combined drivers/staging/batman-adv/CHANGELOG index 5404359,14a94f7..14a94f7 --- a/drivers/staging/batman-adv/CHANGELOG +++ b/drivers/staging/batman-adv/CHANGELOG @@@ -1,3 -1,18 +1,18 @@@ + batman-adv 0.2: + * support latest kernels (2.6.20 - 2.6.31) + * temporary routing loops / TTL code bug / ghost entries in originator table fixed + * internal packet queue for packet aggregation & transmission retry (ARQ) + for payload broadcasts added + * interface detection converted to event based handling to avoid timers + * major linux coding style adjustments applied + * all kernel version compatibility functions has been moved to compat.h + * use random ethernet address generator from the kernel + * /sys/module/batman_adv/version to export kernel module version + * vis: secondary interface export for dot draw format + JSON output format added + * many bugs (alignment issues, race conditions, deadlocks, etc) squashed + + -- Sat, 07 Nov 2009 15:44:31 +0100 + batman-adv 0.1:
* support latest kernels (2.6.20 - 2.6.28) diff --combined drivers/staging/batman-adv/Makefile index 700c017,0000000..02da871 mode 100644,000000..100644 --- a/drivers/staging/batman-adv/Makefile +++ b/drivers/staging/batman-adv/Makefile @@@ -1,20 -1,0 +1,22 @@@ +# - # Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: ++# Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: ++# +# Marek Lindner, Simon Wunderlich ++# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA +# + +obj-m += batman-adv.o +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 log.o diff --combined drivers/staging/batman-adv/Makefile.kbuild index 4210267,6be1223..6be1223 --- a/drivers/staging/batman-adv/Makefile.kbuild +++ b/drivers/staging/batman-adv/Makefile.kbuild @@@ -1,6 -1,8 +1,8 @@@ # - # Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + # Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + # # Marek Lindner, Simon Wunderlich + # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public # License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/README index b97a78b,d554a6c..d554a6c --- a/drivers/staging/batman-adv/README +++ b/drivers/staging/batman-adv/README @@@ -1,12 -1,21 +1,21 @@@ - [state: 17-11-2008] + [state: 07-11-2009]
BATMAN-ADV ----------
- The kernel implementation of batman-advanced. It does not depend on any network - driver, and can be used on wifi as well as ethernet, vpn, etc ... (anything - with ethernet-style layer 2). - It compiles against and should work with Linux 2.6.20 - 2.6.28. Supporting older + Batman-advanced is a new approach to wireless networking which does no longer + operate on the IP basis. Unlike B.A.T.M.A.N, which exchanges information + using UDP packets and sets routing tables, batman-advanced operates on ISO/OSI + Layer 2 only and uses and routes (or better: bridges) Ethernet Frames. It + emulates a virtual network switch of all nodes participating. Therefore all + nodes appear to be link local, thus all higher operating protocols won't be + affected by any changes within the network. You can run almost any protocol + above B.A.T.M.A.N. Advanced, prominent examples are: IPv4, IPv6, DHCP, IPX. + + This is batman-advanced implemented as Linux kernel driver. It does not depend + on any network (other) driver, and can be used on wifi as well as ethernet, + vpn, etc ... (anything with ethernet-style layer 2). + It compiles against and should work with Linux 2.6.20 - 2.6.31. Supporting older versions is not planned, but it's probably easy to backport it. If you work on a backport, feel free to contact us. :-)
@@@ -53,18 -62,54 +62,54 @@@ as VIS-server
# echo "server" > /proc/net/batman-adv/vis
+ Each node is either configured as "server" or as "client" (default: + "client"). Clients send their topology data to the server next to them, + and server synchronize with other servers. If there is no server + configured (default) within the mesh, no topology information will be + transmitted. With these "synchronizing servers", there can be 1 or + more vis servers sharing the same (or at least very similar) data. + When configured as server, you can get a topology snapshot of your mesh:
# cat /proc/net/batman-adv/vis
- This output can be processed with graphviz-tools like dot. + This output format is a graphviz formatted text file which can be + processed with graphviz-tools like dot. The labels are similar/compatible to the ETX metric, 1.0 means perfect connection (100%), 2.0 means 50%, 3.0 means 33% and so on.
+ Alternatively, a JSON output format is available. The format can be set + using by writing either "dot_draw" or "json" into the vis_format file. + "dot_draw" is selected by default. + + echo "json" > /proc/net/batman-adv/vis_format + + In very mobile scenarios, you might want to adjust the originator + interval to a lower value. This will make the mesh more responsive to + topology changes, but will also increase the overhead. Please make sure + that all nodes in your mesh use the same interval. The default value + is 1000 ms (1 second). + + # echo 1000 > /proc/net/batman-adv/orig_interval + To deactivate batman, do:
# echo "" > /proc/net/batman-adv/interfaces
+ BATCTL + ------ + + B.A.T.M.A.N. advanced operates on layer 2 and thus all hosts partici- + pating in the virtual switch are completely transparent for all proto- + cols above layer 2. Therefore the common diagnosis tools do not work as + expected. To overcome these problems batctl was created. At the moment + the batctl contains ping, traceroute, tcpdump and interfaces to the + kernel module settings. + + For more information, please see the manpage (man batctl). + + batctl is available on http://www.open-mesh.net/ + CONTACT -------
diff --combined drivers/staging/batman-adv/aggregation.c index 9b88b14,9c6e681..9c6e681 --- a/drivers/staging/batman-adv/aggregation.c +++ b/drivers/staging/batman-adv/aggregation.c @@@ -1,6 -1,8 +1,8 @@@ /* * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -86,7 -88,7 +88,7 @@@ static bool can_aggregate_with(struct b }
/* create a new aggregated packet and add this packet to it */ - void new_aggregated_packet(unsigned char *packet_buff, + static void new_aggregated_packet(unsigned char *packet_buff, int packet_len, unsigned long send_time, bool direct_link, diff --combined drivers/staging/batman-adv/aggregation.h index a0500b2,6da8df9..6da8df9 --- a/drivers/staging/batman-adv/aggregation.h +++ b/drivers/staging/batman-adv/aggregation.h @@@ -1,6 -1,8 +1,8 @@@ /* * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/bitarray.c index e4c4087,3c67f5f..3c67f5f --- a/drivers/staging/batman-adv/bitarray.c +++ b/drivers/staging/batman-adv/bitarray.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2006-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2009 B.A.T.M.A.N. contributors: + * * Simon Wunderlich, Marek Lindner + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -21,15 -23,6 +23,6 @@@ #include "bitarray.h" #include "log.h"
- /* clear the bits */ - void bit_init(TYPE_OF_WORD *seq_bits) - { - int i; - - for (i = 0; i < NUM_WORDS; i++) - seq_bits[i] = 0; - } - /* returns true if the corresponding bit in the given seq_bits indicates true * and curr_seqno is within range of last_seqno */ uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint16_t last_seqno, @@@ -53,24 -46,6 +46,6 @@@ } }
- /* print the packet array, for debugging purposes */ - static char bit_string[130]; - char *bit_print(TYPE_OF_WORD *seq_bits) - { - int i, j, k = 0, b = 0; - - for (i = 0; i < NUM_WORDS; i++) { - for (j = 0; j < WORD_BIT_SIZE; j++) { - bit_string[k++] = ((seq_bits[i]>>j)%2 ? '1' : '0'); - if (++b == TQ_LOCAL_WINDOW_SIZE) - bit_string[k++] = '|'; - } - bit_string[k++] = ' '; - } - bit_string[k++] = '\0'; - return bit_string; - } - /* turn corresponding bit on, so we can remember that we got the packet */ void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n) { diff --combined drivers/staging/batman-adv/bitarray.h index 9f1b36f,ec72dd7..ec72dd7 --- a/drivers/staging/batman-adv/bitarray.h +++ b/drivers/staging/batman-adv/bitarray.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2006-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2009 B.A.T.M.A.N. contributors: + * * Simon Wunderlich, Marek Lindner + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -22,9 -24,6 +24,6 @@@ #define TYPE_OF_WORD unsigned long #define WORD_BIT_SIZE (sizeof(TYPE_OF_WORD) * 8)
- /* clear the bits, ready for use */ - void bit_init(TYPE_OF_WORD *seq_bits); - /* returns true if the corresponding bit in the given seq_bits indicates true * and curr_seqno is within range of last_seqno */ uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint16_t last_seqno, @@@ -44,6 -43,3 +43,3 @@@ char bit_get_packet(TYPE_OF_WORD *seq_b
/* count the hamming weight, how many good packets did we receive? */ int bit_packet_count(TYPE_OF_WORD *seq_bits); - - /* print the packet array, for debugging purposes */ - char *bit_print(TYPE_OF_WORD *seq_bits); diff --combined drivers/staging/batman-adv/compat.h index 2f0877c,f4e0a45..f4e0a45 --- a/drivers/staging/batman-adv/compat.h +++ b/drivers/staging/batman-adv/compat.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -60,3 -62,14 +62,14 @@@ #define cancel_delayed_work_sync(wq) cancel_rearming_delayed_work(wq)
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) + #define strict_strtoul(cp, base, res) \ + ({ \ + int ret = 0; \ + char *endp; \ + *res = simple_strtoul(cp, &endp, base); \ + if (cp == endp) \ + ret = -EINVAL; \ + ret; \ + }) + #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) */ diff --combined drivers/staging/batman-adv/device.c index 6383839,1e7d1f8..1e7d1f8 --- a/drivers/staging/batman-adv/device.c +++ b/drivers/staging/batman-adv/device.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -79,8 -81,6 +81,6 @@@ int bat_device_setup(void
void bat_device_destroy(void) { - int result = 0; - if (!Major) return;
@@@ -88,14 -88,7 +88,7 @@@ class_destroy(batman_class);
/* Unregister the device */ - #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) - result = unregister_chrdev(Major, DRIVER_DEVICE); - #else unregister_chrdev(Major, DRIVER_DEVICE); - #endif - - if (result < 0) - debug_log(LOG_TYPE_WARN, "Unregistering the character device failed with %d\n", result);
Major = 0; } @@@ -266,8 -259,8 +259,8 @@@ ssize_t bat_device_write(struct file *f ETH_ALEN);
send_raw_packet((unsigned char *)&icmp_packet, - sizeof(struct icmp_packet), - batman_if, orig_node->router->addr); + sizeof(struct icmp_packet), + batman_if, orig_node->router->addr);
spin_unlock(&orig_hash_lock); goto out; @@@ -313,6 -306,7 +306,7 @@@ void bat_device_add_packet(struct devic /* while waiting for the lock the device_client could have been * deleted */ if (!device_client_hash[icmp_packet->uid]) { + spin_unlock(&device_client->lock); kfree(device_packet); return; } diff --combined drivers/staging/batman-adv/device.h index 5e53531,46c0f44..46c0f44 --- a/drivers/staging/batman-adv/device.h +++ b/drivers/staging/batman-adv/device.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/hard-interface.c index dd5e784,5ea35da..5ea35da --- a/drivers/staging/batman-adv/hard-interface.c +++ b/drivers/staging/batman-adv/hard-interface.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -70,6 -72,28 +72,28 @@@ int hardif_min_mtu(void return min_mtu; }
+ static void check_known_mac_addr(uint8_t *addr) + { + struct batman_if *batman_if; + char mac_string[ETH_STR_LEN]; + + rcu_read_lock(); + list_for_each_entry_rcu(batman_if, &if_list, list) { + if ((batman_if->if_active != IF_ACTIVE) && + (batman_if->if_active != IF_TO_BE_ACTIVATED)) + continue; + + if (!compare_orig(batman_if->net_dev->dev_addr, addr)) + continue; + + addr_to_string(mac_string, addr); + debug_log(LOG_TYPE_WARN, "The newly added mac address (%s) already exists on: %s\n", + mac_string, batman_if->dev); + debug_log(LOG_TYPE_WARN, "It is strongly recommended to keep mac addresses unique to avoid problems!\n"); + } + rcu_read_unlock(); + } + /* adjusts the MTU if a new interface with a smaller MTU appeared. */ void update_min_mtu(void) { @@@ -81,7 -105,7 +105,7 @@@ }
/* checks if the interface is up. (returns 1 if it is) */ - int hardif_is_interface_up(char *dev) + static int hardif_is_interface_up(char *dev) { struct net_device *net_dev;
@@@ -152,7 -176,7 +176,7 @@@ void hardif_deactivate_interface(struc }
/* (re)activate given interface. */ - void hardif_activate_interface(struct batman_if *batman_if) + static void hardif_activate_interface(struct batman_if *batman_if) { struct sockaddr_ll bind_addr; int retval; @@@ -191,6 -215,8 +215,8 @@@ goto bind_err; }
+ check_known_mac_addr(batman_if->net_dev->dev_addr); + batman_if->raw_sock->sk->sk_user_data = batman_if->raw_sock->sk->sk_data_ready; batman_if->raw_sock->sk->sk_data_ready = batman_data_ready; @@@ -374,6 -400,8 +400,8 @@@ int hardif_add_interface(char *dev, in return 1;
out: + if (batman_if->packet_buff) + kfree(batman_if->packet_buff); kfree(batman_if); kfree(dev); return -1; @@@ -401,6 -429,10 +429,10 @@@ static int hard_if_event(struct notifie break; case NETDEV_UP: hardif_activate_interface(batman_if); + if ((atomic_read(&module_state) == MODULE_INACTIVE) && + (hardif_get_active_if_num() > 0)) { + activate_module(); + } break; /* NETDEV_CHANGEADDR - mac address change - what are we doing here ? */ default: diff --combined drivers/staging/batman-adv/hard-interface.h index 29d010b,742358c..742358c --- a/drivers/staging/batman-adv/hard-interface.h +++ b/drivers/staging/batman-adv/hard-interface.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/hash.c index 576464d,61cb4a2..61cb4a2 --- a/drivers/staging/batman-adv/hash.c +++ b/drivers/staging/batman-adv/hash.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2006-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2009 B.A.T.M.A.N. contributors: + * * Simon Wunderlich, Marek Lindner + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/hash.h index c27687e,bb60f08..bb60f08 --- a/drivers/staging/batman-adv/hash.h +++ b/drivers/staging/batman-adv/hash.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2006-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2009 B.A.T.M.A.N. contributors: + * * Simon Wunderlich, Marek Lindner + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/log.c index 939bf0d,ae8370b..ae8370b --- a/drivers/staging/batman-adv/log.c +++ b/drivers/staging/batman-adv/log.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/log.h index 685f539,780e3ab..780e3ab --- a/drivers/staging/batman-adv/log.h +++ b/drivers/staging/batman-adv/log.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/main.c index 8fbefc2,bb89bfc..bb89bfc --- a/drivers/staging/batman-adv/main.c +++ b/drivers/staging/batman-adv/main.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -173,7 -175,7 +175,7 @@@ end /* shuts down the whole module.*/ void shutdown_module(void) { - atomic_set(&module_state, MODULE_INACTIVE); + atomic_set(&module_state, MODULE_DEACTIVATING);
purge_outstanding_packets(); flush_workqueue(bat_event_workqueue); @@@ -199,6 -201,7 +201,7 @@@
hardif_remove_interfaces(); synchronize_rcu(); + atomic_set(&module_state, MODULE_INACTIVE); }
void inc_module_count(void) diff --combined drivers/staging/batman-adv/main.h index 21d3919,85e50b7..85e50b7 --- a/drivers/staging/batman-adv/main.h +++ b/drivers/staging/batman-adv/main.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -24,7 -26,7 +26,7 @@@ #define DRIVER_DESC "B.A.T.M.A.N. advanced" #define DRIVER_DEVICE "batman-adv"
- #define SOURCE_VERSION "0.2-beta" + #define SOURCE_VERSION "0.2"
/* B.A.T.M.A.N. parameters */ @@@ -63,7 -65,7 +65,7 @@@
#define MODULE_INACTIVE 0 #define MODULE_ACTIVE 1 - /* #define MODULE_WAITING 2 -- not needed anymore */ + #define MODULE_DEACTIVATING 2
/* diff --combined drivers/staging/batman-adv/packet.h index 021bcec,5627ca3..5627ca3 --- a/drivers/staging/batman-adv/packet.h +++ b/drivers/staging/batman-adv/packet.h @@@ -1,6 -1,8 +1,8 @@@ /* * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/proc.c index 8718079,aac3df7..aac3df7 --- a/drivers/staging/batman-adv/proc.c +++ b/drivers/staging/batman-adv/proc.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -26,8 -28,9 +28,9 @@@ #include "types.h" #include "hash.h" #include "vis.h" + #include "compat.h"
- uint8_t vis_format = DOT_DRAW; + static uint8_t vis_format = DOT_DRAW;
static struct proc_dir_entry *proc_batman_dir, *proc_interface_file; static struct proc_dir_entry *proc_orig_interval_file, *proc_originators_file; @@@ -146,7 -149,7 +149,7 @@@ static ssize_t proc_orig_interval_write { char *interval_string; int not_copied = 0; - long originator_interval_tmp; + unsigned long originator_interval_tmp; int retval;
interval_string = kmalloc(count, GFP_KERNEL); @@@ -157,7 -160,7 +160,7 @@@ not_copied = copy_from_user(interval_string, buffer, count); interval_string[count - not_copied - 1] = 0;
- retval = strict_strtol(interval_string, 10, &originator_interval_tmp); + retval = strict_strtoul(interval_string, 10, &originator_interval_tmp); if (retval) { debug_log(LOG_TYPE_WARN, "New originator interval invalid\n"); goto end; @@@ -290,7 -293,7 +293,7 @@@ static ssize_t proc_log_level_write(str { char *log_level_string, *tokptr, *cp; int finished, not_copied = 0; - uint8_t log_level_tmp = 0; + unsigned long log_level_tmp = 0;
log_level_string = kmalloc(count, GFP_KERNEL);
@@@ -300,10 -303,8 +303,8 @@@ not_copied = copy_from_user(log_level_string, userbuffer, count); log_level_string[count - not_copied - 1] = 0;
- log_level_tmp = simple_strtol(log_level_string, &cp, 10); - - if (cp == log_level_string) { - /* was not (beginning with) a number, doing textual parsing */ + if (strict_strtoul(log_level_string, 10, &log_level_tmp) < 0) { + /* was not a number, doing textual parsing */ log_level_tmp = 0; tokptr = log_level_string;
@@@ -540,7 -541,7 +541,7 @@@ static int proc_vis_read(struct seq_fil if (current_format == DOT_DRAW) {
addr_to_string(tmp_addr_str, info->packet.vis_orig); - seq_printf(seq, "\tsubgraph "cluster_%s" {\n", tmp_addr_str); + seq_printf(seq, "\tsubgraph "cluster_%s" {\n", tmp_addr_str); while (if_entries != NULL) {
addr_to_string(tmp_addr_str, if_entries->addr); @@@ -663,7 -664,7 +664,7 @@@ static ssize_t proc_aggr_write(struct f { char *aggr_string; int not_copied = 0; - long aggregation_enabled_tmp; + unsigned long aggregation_enabled_tmp;
aggr_string = kmalloc(count, GFP_KERNEL);
@@@ -673,7 -674,7 +674,7 @@@ not_copied = copy_from_user(aggr_string, buffer, count); aggr_string[count - not_copied - 1] = 0;
- strict_strtol(aggr_string, 10, &aggregation_enabled_tmp); + strict_strtoul(aggr_string, 10, &aggregation_enabled_tmp);
if ((aggregation_enabled_tmp != 0) && (aggregation_enabled_tmp != 1)) { debug_log(LOG_TYPE_WARN, "Aggregation can only be enabled (1) or disabled (0), given value: %li\n", aggregation_enabled_tmp); diff --combined drivers/staging/batman-adv/proc.h index 23c4fe4,ebce50d..ebce50d --- a/drivers/staging/batman-adv/proc.h +++ b/drivers/staging/batman-adv/proc.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/ring_buffer.c index dee6fba,751c899..751c899 --- a/drivers/staging/batman-adv/ring_buffer.c +++ b/drivers/staging/batman-adv/ring_buffer.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/ring_buffer.h index 246f354,6839ba9..6839ba9 --- a/drivers/staging/batman-adv/ring_buffer.h +++ b/drivers/staging/batman-adv/ring_buffer.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/routing.c index 081140e,b33cef9..b33cef9 --- a/drivers/staging/batman-adv/routing.c +++ b/drivers/staging/batman-adv/routing.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -34,6 -36,7 +36,7 @@@ #include "ring_buffer.h" #include "vis.h" #include "aggregation.h" + #include "compat.h"
@@@ -43,7 -46,7 +46,7 @@@ static DECLARE_DELAYED_WORK(purge_orig_ static atomic_t data_ready_cond; atomic_t exit_cond;
- void start_purge_timer(void) + static void start_purge_timer(void) { queue_delayed_work(bat_event_workqueue, &purge_orig_wq, 1 * HZ); } @@@ -343,18 -346,28 +346,28 @@@ static void update_orig(struct orig_nod
tmp_hna_buff_len = (hna_buff_len > batman_packet->num_hna * ETH_ALEN ? batman_packet->num_hna * ETH_ALEN : hna_buff_len);
- /** - * if we got have a better tq value via this neighbour or - * same tq value but the link is more symetric change the next hop - * router - */ - if ((orig_node->router != neigh_node) && ((!orig_node->router) || - (neigh_node->tq_avg > orig_node->router->tq_avg) || - ((neigh_node->tq_avg == orig_node->router->tq_avg) && - (neigh_node->orig_node->bcast_own_sum[if_incoming->if_num] > orig_node->router->orig_node->bcast_own_sum[if_incoming->if_num])))) - update_routes(orig_node, neigh_node, hna_buff, tmp_hna_buff_len); - else - update_routes(orig_node, orig_node->router, hna_buff, tmp_hna_buff_len); + /* if this neighbor already is our next hop there is nothing to change */ + if (orig_node->router == neigh_node) + goto update_hna; + + /* if this neighbor does not offer a better TQ we won't consider it */ + if ((orig_node->router) && + (orig_node->router->tq_avg > neigh_node->tq_avg)) + goto update_hna; + + /* if the TQ is the same and the link not more symetric we won't consider it either */ + if ((orig_node->router) && + ((neigh_node->tq_avg == orig_node->router->tq_avg) && + (orig_node->router->orig_node->bcast_own_sum[if_incoming->if_num] > + neigh_node->orig_node->bcast_own_sum[if_incoming->if_num]))) + goto update_hna; + + update_routes(orig_node, neigh_node, hna_buff, tmp_hna_buff_len); + return; + + update_hna: + update_routes(orig_node, orig_node->router, hna_buff, tmp_hna_buff_len); + return; }
static char count_real_packets(struct ethhdr *ethhdr, struct batman_packet *batman_packet, struct batman_if *if_incoming) @@@ -399,6 -412,19 +412,19 @@@ void receive_bat_packet(struct ethhdr * char is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0, is_broadcast = 0, is_bidirectional, is_single_hop_neigh, is_duplicate; unsigned short if_incoming_seqno;
+ /* Silently drop when the batman packet is actually not a correct packet. + * + * This might happen if a packet is padded (e.g. Ethernet has a + * minimum frame length of 64 byte) and the aggregation interprets + * it as an additional length. + * + * TODO: A more sane solution would be to have a bit in the batman_packet + * to detect whether the packet is the last packet in an aggregation. + * Here we expect that the padding is always zero (or not 0x01) + */ + if (batman_packet->packet_type != BAT_PACKET) + return; + /* could be changed by schedule_own_packet() */ if_incoming_seqno = atomic_read(&if_incoming->seqno);
@@@ -477,6 -503,15 +503,15 @@@ if (orig_node == NULL) return;
+ /* avoid temporary routing loops */ + if ((orig_node->router) && (orig_node->router->orig_node->router) && + (compare_orig(orig_node->router->addr, batman_packet->prev_sender)) && + !(compare_orig(batman_packet->orig, batman_packet->prev_sender)) && + (compare_orig(orig_node->router->addr, orig_node->router->orig_node->router->addr))) { + debug_log(LOG_TYPE_BATMAN, "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %s) \n", neigh_str); + return; + } + /* if sender is a direct neighbor the sender mac equals originator mac */ orig_neigh_node = (is_single_hop_neigh ? orig_node : get_orig_node(ethhdr->h_source)); if (orig_neigh_node == NULL) @@@ -583,7 -618,7 +618,7 @@@ void purge_orig(struct work_struct *wor start_purge_timer(); }
- int receive_raw_packet(struct socket *raw_sock, unsigned char *packet_buff, int packet_buff_len) + static int receive_raw_packet(struct socket *raw_sock, unsigned char *packet_buff, int packet_buff_len) { struct kvec iov; struct msghdr msg; diff --combined drivers/staging/batman-adv/routing.h index 97db3f2,0123ea8..0123ea8 --- a/drivers/staging/batman-adv/routing.h +++ b/drivers/staging/batman-adv/routing.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/send.c index 73fe371,d724798..d724798 --- a/drivers/staging/batman-adv/send.c +++ b/drivers/staging/batman-adv/send.c @@@ -1,6 -1,8 +1,8 @@@ /* * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -399,7 -401,7 +401,7 @@@ void send_outstanding_bcast_packet(stru /* if we still have some more bcasts to send and we are not shutting * down */ if ((forw_packet->num_packets < 3) && - (atomic_read(&module_state) != MODULE_INACTIVE)) + (atomic_read(&module_state) != MODULE_DEACTIVATING)) _add_bcast_packet_to_list(forw_packet, ((5 * HZ) / 1000)); else forw_packet_free(forw_packet); @@@ -424,7 -426,7 +426,7 @@@ void send_outstanding_bat_packet(struc * shutting down */ if ((forw_packet->own) && - (atomic_read(&module_state) != MODULE_INACTIVE)) + (atomic_read(&module_state) != MODULE_DEACTIVATING)) schedule_own_packet(forw_packet->if_incoming);
forw_packet_free(forw_packet); diff --combined drivers/staging/batman-adv/send.h index ca7f3f0,59d5009..59d5009 --- a/drivers/staging/batman-adv/send.h +++ b/drivers/staging/batman-adv/send.h @@@ -1,6 -1,8 +1,8 @@@ /* * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/soft-interface.c index d916764,d543f50..d543f50 --- a/drivers/staging/batman-adv/soft-interface.c +++ b/drivers/staging/batman-adv/soft-interface.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -66,7 -68,7 +68,7 @@@ int main_if_was_up(void return (memcmp(mainIfAddr, mainIfAddr_default, ETH_ALEN) != 0 ? 1 : 0); }
- int my_skb_push(struct sk_buff *skb, unsigned int len) + static int my_skb_push(struct sk_buff *skb, unsigned int len) { int result = 0;
@@@ -83,7 -85,7 +85,7 @@@ return 0; }
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) + #ifdef HAVE_NET_DEVICE_OPS static const struct net_device_ops bat_netdev_ops = { .ndo_open = interface_open, .ndo_stop = interface_release, @@@ -93,7 -95,7 +95,7 @@@ .ndo_start_xmit = interface_tx, .ndo_validate_addr = eth_validate_addr }; - #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */ + #endif
void interface_setup(struct net_device *dev) { @@@ -102,16 -104,16 +104,16 @@@
ether_setup(dev);
- #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) + #ifdef HAVE_NET_DEVICE_OPS + dev->netdev_ops = &bat_netdev_ops; + #else dev->open = interface_open; dev->stop = interface_release; dev->get_stats = interface_stats; dev->set_mac_address = interface_set_mac_addr; dev->change_mtu = interface_change_mtu; dev->hard_start_xmit = interface_tx; - #else - dev->netdev_ops = &bat_netdev_ops; - #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */ + #endif dev->destructor = free_netdev;
dev->mtu = hardif_min_mtu(); @@@ -119,8 -121,7 +121,7 @@@ * skbuff for our header */
/* generate random address */ - *(u16 *)dev_addr = __constant_htons(0x00FF); - get_random_bytes(dev_addr + sizeof(u16), 4); + random_ether_addr(dev_addr); memcpy(dev->dev_addr, dev_addr, sizeof(dev->dev_addr));
SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); diff --combined drivers/staging/batman-adv/soft-interface.h index 32ed968,515e276..515e276 --- a/drivers/staging/batman-adv/soft-interface.h +++ b/drivers/staging/batman-adv/soft-interface.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/translation-table.c index 8d7ea6d,c2190e1..c2190e1 --- a/drivers/staging/batman-adv/translation-table.c +++ b/drivers/staging/batman-adv/translation-table.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -30,7 -32,7 +32,7 @@@ static struct hashtable_t *hna_global_h atomic_t hna_local_changed;
DEFINE_SPINLOCK(hna_local_hash_lock); - DEFINE_SPINLOCK(hna_global_hash_lock); + static DEFINE_SPINLOCK(hna_global_hash_lock);
static DECLARE_DELAYED_WORK(hna_local_purge_wq, hna_local_purge);
diff --combined drivers/staging/batman-adv/translation-table.h index 660fcd8,f7da811..f7da811 --- a/drivers/staging/batman-adv/translation-table.h +++ b/drivers/staging/batman-adv/translation-table.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/types.h index 0c31b4d,3a0ef0c..3a0ef0c --- a/drivers/staging/batman-adv/types.h +++ b/drivers/staging/batman-adv/types.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2007-2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * * Marek Lindner, Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. diff --combined drivers/staging/batman-adv/vis.c index 8c16ad4,f6c9acb..f6c9acb --- a/drivers/staging/batman-adv/vis.c +++ b/drivers/staging/batman-adv/vis.c @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2008-2009 B.A.T.M.A.N. contributors: + * * Simon Wunderlich + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. @@@ -367,7 -369,7 +369,7 @@@ static int generate_vis_packet(void return 0; }
- void purge_vis_packets(void) + static void purge_vis_packets(void) { struct hash_it_t *hashit = NULL; struct vis_info *info; diff --combined drivers/staging/batman-adv/vis.h index 6d5ddcf,276faba..276faba --- a/drivers/staging/batman-adv/vis.h +++ b/drivers/staging/batman-adv/vis.h @@@ -1,6 -1,8 +1,8 @@@ /* - * Copyright (C) 2008 B.A.T.M.A.N. contributors: + * Copyright (C) 2008-2009 B.A.T.M.A.N. contributors: + * * Simon Wunderlich, Marek Lindner + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation.