The following commit has been merged in the merge/master branch: commit 32fbdd29c0b8fd7236e734ae6ff72865fa5e14ec Merge: 9364ea649aa4e7405b2e769aceef8a6627e1bd9c 5caa4a307dcd05b05dee82a5c0b6c4574222873d Author: Sven Eckelmann sven@narfation.org Date: Sat Jan 29 22:07:45 2011 +0100
Merge remote branch 'origin/standalone/next' into merge/master
Conflicts: net/batman-adv/CHANGELOG net/batman-adv/Makefile.kbuild net/batman-adv/README net/batman-adv/compat.h
diff --combined Documentation/networking/batman-adv.txt index 77f0cdd,0000000..18afcd8 mode 100644,000000..100644 --- a/Documentation/networking/batman-adv.txt +++ b/Documentation/networking/batman-adv.txt @@@ -1,240 -1,0 +1,240 @@@ - [state: 21-11-2010] ++[state: 27-01-2011] + +BATMAN-ADV +---------- + +Batman advanced is a new approach to wireless networking which +does no longer operate on the IP basis. Unlike the batman daemon, +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 proto- +cols won't be affected by any changes within the network. You can +run almost any protocol above batman advanced, prominent examples +are: IPv4, IPv6, DHCP, IPX. + +Batman advanced was implemented as a Linux kernel driver to re- +duce the overhead to a minimum. It does not depend on any (other) +network driver, and can be used on wifi as well as ethernet lan, +vpn, etc ... (anything with ethernet-style layer 2). + +CONFIGURATION +------------- + +Load the batman-adv module into your kernel: + +# insmod batman-adv.ko + +The module is now waiting for activation. You must add some in- +terfaces on which batman can operate. After loading the module +batman advanced will scan your systems interfaces to search for +compatible interfaces. Once found, it will create subfolders in +the /sys directories of each supported interface, e.g. + +# ls /sys/class/net/eth0/batman_adv/ +# iface_status mesh_iface + +If an interface does not have the "batman_adv" subfolder it prob- +ably is not supported. Not supported interfaces are: loopback, +non-ethernet and batman's own interfaces. + +Note: After the module was loaded it will continuously watch for +new interfaces to verify the compatibility. There is no need to +reload the module if you plug your USB wifi adapter into your ma- +chine after batman advanced was initially loaded. + +To activate a given interface simply write "bat0" into its +"mesh_iface" file inside the batman_adv subfolder: + +# echo bat0 > /sys/class/net/eth0/batman_adv/mesh_iface + +Repeat this step for all interfaces you wish to add. Now batman +starts using/broadcasting on this/these interface(s). + +By reading the "iface_status" file you can check its status: + +# cat /sys/class/net/eth0/batman_adv/iface_status +# active + +To deactivate an interface you have to write "none" into its +"mesh_iface" file: + +# echo none > /sys/class/net/eth0/batman_adv/mesh_iface + + +All mesh wide settings can be found in batman's own interface +folder: + +# ls /sys/class/net/bat0/mesh/ - # aggregated_ogms bonding fragmentation orig_interval - # vis_mode ++# aggregated_ogms gw_bandwidth hop_penalty ++# bonding gw_mode orig_interval ++# fragmentation gw_sel_class vis_mode + + +There is a special folder for debugging informations: + +# ls /sys/kernel/debug/batman_adv/bat0/ - # originators socket transtable_global transtable_local - # vis_data ++# gateways socket transtable_global vis_data ++# originators softif_neigh transtable_local + + +Some of the files contain all sort of status information regard- +ing the mesh network. For example, you can view the table of +originators (mesh participants) with: + +# cat /sys/kernel/debug/batman_adv/bat0/originators + +Other files allow to change batman's behaviour to better fit your +requirements. For instance, you can check the current originator +interval (value in milliseconds which determines how often batman +sends its broadcast packets): + +# cat /sys/class/net/bat0/mesh/orig_interval +# 1000 + +and also change its value: + +# echo 3000 > /sys/class/net/bat0/mesh/orig_interval + +In very mobile scenarios, you might want to adjust the originator +interval to a lower value. This will make the mesh more respon- +sive to topology changes, but will also increase the overhead. + + +USAGE +----- + +To make use of your newly created mesh, batman advanced provides +a new interface "bat0" which you should use from this point on. +All interfaces added to batman advanced are not relevant any +longer because batman handles them for you. Basically, one "hands +over" the data by using the batman interface and batman will make +sure it reaches its destination. + +The "bat0" interface can be used like any other regular inter- +face. It needs an IP address which can be either statically con- +figured or dynamically (by using DHCP or similar services): + +# NodeA: ifconfig bat0 192.168.0.1 +# NodeB: ifconfig bat0 192.168.0.2 +# NodeB: ping 192.168.0.1 + +Note: In order to avoid problems remove all IP addresses previ- +ously assigned to interfaces now used by batman advanced, e.g. + +# ifconfig eth0 0.0.0.0 + + +VISUALIZATION +------------- + +If you want topology visualization, at least one mesh node must +be configured as VIS-server: + +# echo "server" > /sys/class/net/bat0/mesh/vis_mode + +Each node is either configured as "server" or as "client" (de- +fault: "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 /sys/kernel/debug/batman_adv/bat0/vis_data + +This raw output is intended to be easily parsable and convertable +with other tools. Have a look at the batctl README if you want a +vis output in dot or json format for instance and how those out- +puts could then be visualised in an image. + +The raw format consists of comma separated values per entry where +each entry is giving information about a certain source inter- +face. Each entry can/has to have the following values: +-> "mac" - mac address of an originator's source interface + (each line begins with it) +-> "TQ mac value" - src mac's link quality towards mac address + of a neighbor originator's interface which + is being used for routing +-> "HNA mac" - HNA announced by source mac +-> "PRIMARY" - this is a primary interface +-> "SEC mac" - secondary mac address of source + (requires preceding PRIMARY) + +The TQ value has a range from 4 to 255 with 255 being the best. +The HNA entries are showing which hosts are connected to the mesh +via bat0 or being bridged into the mesh network. The PRIMARY/SEC +values are only applied on primary interfaces + + +LOGGING/DEBUGGING +----------------- + +All error messages, warnings and information messages are sent to +the kernel log. Depending on your operating system distribution +this can be read in one of a number of ways. Try using the com- +mands: dmesg, logread, or looking in the files /var/log/kern.log +or /var/log/syslog. All batman-adv messages are prefixed with +"batman-adv:" So to see just these messages try + +# dmesg | grep batman-adv + +When investigating problems with your mesh network it is some- +times necessary to see more detail debug messages. This must be +enabled when compiling the batman-adv module. When building bat- +man-adv as part of kernel, use "make menuconfig" and enable the +option "B.A.T.M.A.N. debugging". + +Those additional debug messages can be accessed using a special +file in debugfs + +# cat /sys/kernel/debug/batman_adv/bat0/log + +The additional debug output is by default disabled. It can be en- +abled during run time. Following log_levels are defined: + +0 - All debug output disabled +1 - Enable messages related to routing / flooding / broadcasting +2 - Enable route or hna added / changed / deleted +3 - Enable all messages + +The debug output can be changed at runtime using the file +/sys/class/net/bat0/mesh/log_level. e.g. + +# echo 2 > /sys/class/net/bat0/mesh/log_level + +will enable debug messages for when routes or HNAs change. + + +BATCTL +------ + +As batman advanced operates on layer 2 all hosts participating in +the virtual switch are completely transparent for all protocols +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.org/ + + +CONTACT +------- + +Please send us comments, experiences, questions, anything :) + +IRC: #batman on irc.freenode.org - Mailing-list: b.a.t.m.a.n@b.a.t.m.a.n@lists.open-mesh.org - (optional subscription at - https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n) ++Mailing-list: b.a.t.m.a.n@open-mesh.org (optional subscription ++ at https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n) + +You can also contact the Authors: + +Marek Lindner lindner_marek@yahoo.de +Simon Wunderlich siwu@hrz.tu-chemnitz.de diff --combined net/batman-adv/Makefile index d936aec,0000000..2de93d0 mode 100644,000000..100644 --- a/net/batman-adv/Makefile +++ b/net/batman-adv/Makefile @@@ -1,39 -1,0 +1,39 @@@ +# - # Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: ++# Copyright (C) 2007-2011 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-$(CONFIG_BATMAN_ADV) += batman-adv.o +batman-adv-y += aggregation.o +batman-adv-y += bat_debugfs.o +batman-adv-y += bat_sysfs.o +batman-adv-y += bitarray.o +batman-adv-y += gateway_client.o +batman-adv-y += gateway_common.o +batman-adv-y += hard-interface.o +batman-adv-y += hash.o +batman-adv-y += icmp_socket.o +batman-adv-y += main.o +batman-adv-y += originator.o +batman-adv-y += ring_buffer.o +batman-adv-y += routing.o +batman-adv-y += send.o +batman-adv-y += soft-interface.o +batman-adv-y += translation-table.o +batman-adv-y += unicast.o +batman-adv-y += vis.o diff --combined net/batman-adv/aggregation.c index 3850a3e,1997725..1997725 --- a/net/batman-adv/aggregation.c +++ b/net/batman-adv/aggregation.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --combined net/batman-adv/aggregation.h index 71a91b3,6ce305b..6ce305b --- a/net/batman-adv/aggregation.h +++ b/net/batman-adv/aggregation.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --combined net/batman-adv/bat_debugfs.c index 0ae81d0,0e9d435..0e9d435 --- a/net/batman-adv/bat_debugfs.c +++ b/net/batman-adv/bat_debugfs.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * @@@ -52,7 -52,6 +52,6 @@@ static void emit_log_char(struct debug_
static int fdebug_log(struct debug_log *debug_log, char *fmt, ...) { - int printed_len; va_list args; static char debug_log_buf[256]; char *p; @@@ -62,8 -61,7 +61,7 @@@
spin_lock_bh(&debug_log->lock); va_start(args, fmt); - printed_len = vscnprintf(debug_log_buf, sizeof(debug_log_buf), - fmt, args); + vscnprintf(debug_log_buf, sizeof(debug_log_buf), fmt, args); va_end(args);
for (p = debug_log_buf; *p != 0; p++) diff --combined net/batman-adv/bat_debugfs.h index 72df532,bc9cda3..bc9cda3 --- a/net/batman-adv/bat_debugfs.h +++ b/net/batman-adv/bat_debugfs.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/bat_sysfs.c index cd7bb51,f7b93a0..f7b93a0 --- a/net/batman-adv/bat_sysfs.c +++ b/net/batman-adv/bat_sysfs.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/bat_sysfs.h index 7f186c0,02f1fa7..02f1fa7 --- a/net/batman-adv/bat_sysfs.h +++ b/net/batman-adv/bat_sysfs.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/bitarray.c index bbcd8f7,ad2ca92..ad2ca92 --- a/net/batman-adv/bitarray.c +++ b/net/batman-adv/bitarray.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2006-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2011 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * diff --combined net/batman-adv/bitarray.h index ac54017,769c246..769c246 --- a/net/batman-adv/bitarray.h +++ b/net/batman-adv/bitarray.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2006-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2011 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * diff --combined net/batman-adv/gateway_client.c index 0065ffb,429a013..429a013 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2009-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/gateway_client.h index 4585e65,2aa4391..2aa4391 --- a/net/batman-adv/gateway_client.h +++ b/net/batman-adv/gateway_client.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2009-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/gateway_common.c index b962982,50d3a59..50d3a59 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2009-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/gateway_common.h index 5e728d0,55e527a..55e527a --- a/net/batman-adv/gateway_common.h +++ b/net/batman-adv/gateway_common.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2009-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/hard-interface.c index 4f95777,f2131f4..f2131f4 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * @@@ -34,6 -34,12 +34,12 @@@ /* protect update critical side of if_list - but not the content */ static DEFINE_SPINLOCK(if_list_lock);
+ + static int batman_skb_recv(struct sk_buff *skb, + struct net_device *dev, + struct packet_type *ptype, + struct net_device *orig_dev); + static void hardif_free_rcu(struct rcu_head *rcu) { struct batman_if *batman_if; @@@ -549,8 -555,9 +555,9 @@@ out
/* receive a packet with the batman ethertype coming on a hard * interface */ - int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev) + static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *ptype, + struct net_device *orig_dev) { struct bat_priv *bat_priv; struct batman_packet *batman_packet; diff --combined net/batman-adv/hard-interface.h index 30ec3b8,ad19543..ad19543 --- a/net/batman-adv/hard-interface.h +++ b/net/batman-adv/hard-interface.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * @@@ -35,10 -35,6 +35,6 @@@ struct batman_if *get_batman_if_by_netd int hardif_enable_interface(struct batman_if *batman_if, char *iface_name); void hardif_disable_interface(struct batman_if *batman_if); void hardif_remove_interfaces(void); - int batman_skb_recv(struct sk_buff *skb, - struct net_device *dev, - struct packet_type *ptype, - struct net_device *orig_dev); int hardif_min_mtu(struct net_device *soft_iface); void update_min_mtu(struct net_device *soft_iface);
diff --combined net/batman-adv/hash.c index 26e623e,fa26939..fa26939 --- a/net/batman-adv/hash.c +++ b/net/batman-adv/hash.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2006-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2011 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * diff --combined net/batman-adv/hash.h index 09216ad,eae2440..eae2440 --- a/net/batman-adv/hash.h +++ b/net/batman-adv/hash.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2006-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2011 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * @@@ -49,11 -49,6 +49,6 @@@ struct hashtable_t /* allocates and clears the hash */ struct hashtable_t *hash_new(int size);
- /* remove element if you already found the element you want to delete and don't - * need the overhead to find it again with hash_remove(). But usually, you - * don't want to use this function, as it fiddles with hash-internals. */ - void *hash_remove_element(struct hashtable_t *hash, struct element_t *elem); - /* free only the hashtable and the hash itself. */ void hash_destroy(struct hashtable_t *hash);
diff --combined net/batman-adv/icmp_socket.c index ecf6d7f,5e86d6f..5e86d6f --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/icmp_socket.h index bf9b348,08b1859..08b1859 --- a/net/batman-adv/icmp_socket.h +++ b/net/batman-adv/icmp_socket.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/main.c index b827f6a,dc9248d..dc9248d --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --combined net/batman-adv/main.h index 65106fb,0000000..e235d7b mode 100644,000000..100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@@ -1,183 -1,0 +1,168 @@@ +/* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: ++ * Copyright (C) 2007-2011 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 + * + */ + +#ifndef _NET_BATMAN_ADV_MAIN_H_ +#define _NET_BATMAN_ADV_MAIN_H_ + - /* Kernel Programming */ - #define LINUX - +#define DRIVER_AUTHOR "Marek Lindner lindner_marek@yahoo.de, " \ + "Simon Wunderlich siwu@hrz.tu-chemnitz.de" +#define DRIVER_DESC "B.A.T.M.A.N. advanced" +#define DRIVER_DEVICE "batman-adv" + +#define SOURCE_VERSION "next" + + +/* B.A.T.M.A.N. parameters */ + +#define TQ_MAX_VALUE 255 +#define JITTER 20 +#define TTL 50 /* Time To Live of broadcast messages */ + +#define PURGE_TIMEOUT 200 /* purge originators after time in seconds if no + * valid packet comes in -> TODO: check + * influence on TQ_LOCAL_WINDOW_SIZE */ +#define LOCAL_HNA_TIMEOUT 3600 /* in seconds */ + +#define TQ_LOCAL_WINDOW_SIZE 64 /* sliding packet range of received originator + * messages in squence numbers (should be a + * multiple of our word size) */ +#define TQ_GLOBAL_WINDOW_SIZE 5 +#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 +#define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1 +#define TQ_TOTAL_BIDRECT_LIMIT 1 + +#define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE) + - #define PACKBUFF_SIZE 2000 +#define LOG_BUF_LEN 8192 /* has to be a power of 2 */ + +#define VIS_INTERVAL 5000 /* 5 seconds */ + +/* how much worse secondary interfaces may be to + * to be considered as bonding candidates */ + +#define BONDING_TQ_THRESHOLD 50 + +#define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or + * change the size of + * forw_packet->direct_link_flags */ +#define MAX_AGGREGATION_MS 100 + +#define SOFTIF_NEIGH_TIMEOUT 180000 /* 3 minutes */ + +#define RESET_PROTECTION_MS 30000 +#define EXPECTED_SEQNO_RANGE 65536 +/* don't reset again within 30 seconds */ + +#define MESH_INACTIVE 0 +#define MESH_ACTIVE 1 +#define MESH_DEACTIVATING 2 + +#define BCAST_QUEUE_LEN 256 +#define BATMAN_QUEUE_LEN 256 + +/* + * Debug Messages + */ +#ifdef pr_fmt +#undef pr_fmt +#endif +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* Append 'batman-adv: ' before + * kernel messages */ + +#define DBG_BATMAN 1 /* all messages related to routing / flooding / + * broadcasting / etc */ +#define DBG_ROUTES 2 /* route or hna added / changed / deleted */ +#define DBG_ALL 3 + - #define LOG_BUF_LEN 8192 /* has to be a power of 2 */ - + +/* + * Vis + */ + - /* #define VIS_SUBCLUSTERS_DISABLED */ - +/* + * Kernel headers + */ + +#include <linux/mutex.h> /* mutex */ +#include <linux/module.h> /* needed by all modules */ +#include <linux/netdevice.h> /* netdevice */ +#include <linux/etherdevice.h> /* ethernet address classifaction */ +#include <linux/if_ether.h> /* ethernet header */ +#include <linux/poll.h> /* poll_table */ +#include <linux/kthread.h> /* kernel threads */ +#include <linux/pkt_sched.h> /* schedule types */ +#include <linux/workqueue.h> /* workqueue */ +#include <linux/slab.h> +#include <net/sock.h> /* struct sock */ +#include <linux/jiffies.h> +#include <linux/seq_file.h> +#include "types.h" + +#ifndef REVISION_VERSION +#define REVISION_VERSION_STR "" +#else +#define REVISION_VERSION_STR " "REVISION_VERSION +#endif + +extern struct list_head if_list; + +extern unsigned char broadcast_addr[]; +extern struct workqueue_struct *bat_event_workqueue; + +int mesh_init(struct net_device *soft_iface); +void mesh_free(struct net_device *soft_iface); +void inc_module_count(void); +void dec_module_count(void); +int is_my_mac(uint8_t *addr); + +#ifdef CONFIG_BATMAN_ADV_DEBUG +int debug_log(struct bat_priv *bat_priv, char *fmt, ...); + +#define bat_dbg(type, bat_priv, fmt, arg...) \ + do { \ + if (atomic_read(&bat_priv->log_level) & type) \ + debug_log(bat_priv, fmt, ## arg); \ + } \ + while (0) +#else /* !CONFIG_BATMAN_ADV_DEBUG */ +static inline void bat_dbg(char type __always_unused, + struct bat_priv *bat_priv __always_unused, + char *fmt __always_unused, ...) +{ +} +#endif + - #define bat_warning(net_dev, fmt, arg...) \ - do { \ - struct net_device *_netdev = (net_dev); \ - struct bat_priv *_batpriv = netdev_priv(_netdev); \ - bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ - pr_warning("%s: " fmt, _netdev->name, ## arg); \ - } while (0) +#define bat_info(net_dev, fmt, arg...) \ + do { \ + struct net_device *_netdev = (net_dev); \ + struct bat_priv *_batpriv = netdev_priv(_netdev); \ + bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ + pr_info("%s: " fmt, _netdev->name, ## arg); \ + } while (0) +#define bat_err(net_dev, fmt, arg...) \ + do { \ + struct net_device *_netdev = (net_dev); \ + struct bat_priv *_batpriv = netdev_priv(_netdev); \ + bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ + pr_err("%s: " fmt, _netdev->name, ## arg); \ + } while (0) + +#endif /* _NET_BATMAN_ADV_MAIN_H_ */ diff --combined net/batman-adv/originator.c index 6b7fb6b,54863c9..54863c9 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2009-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * @@@ -247,7 -247,7 +247,7 @@@ static bool purge_orig_node(struct bat_ orig_node->hna_buff_len); /* update bonding candidates, we could have lost * some candidates. */ - update_bonding_candidates(bat_priv, orig_node); + update_bonding_candidates(orig_node); } }
diff --combined net/batman-adv/originator.h index d474ceb,8019fbd..8019fbd --- a/net/batman-adv/originator.h +++ b/net/batman-adv/originator.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --combined net/batman-adv/packet.h index 03ce0d3,e757187..e757187 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --combined net/batman-adv/ring_buffer.c index defd37c,5bb6a61..5bb6a61 --- a/net/batman-adv/ring_buffer.c +++ b/net/batman-adv/ring_buffer.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/ring_buffer.h index 6b0cb9a,0395b27..0395b27 --- a/net/batman-adv/ring_buffer.h +++ b/net/batman-adv/ring_buffer.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/routing.c index a8cd389,028f739..028f739 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * @@@ -433,8 -433,7 +433,7 @@@ static char count_real_packets(struct e }
/* copy primary address for bonding */ - static void mark_bonding_address(struct bat_priv *bat_priv, - struct orig_node *orig_node, + static void mark_bonding_address(struct orig_node *orig_node, struct orig_node *orig_neigh_node, struct batman_packet *batman_packet)
@@@ -447,8 -446,7 +446,7 @@@ }
/* mark possible bond.candidates in the neighbor list */ - void update_bonding_candidates(struct bat_priv *bat_priv, - struct orig_node *orig_node) + void update_bonding_candidates(struct orig_node *orig_node) { int candidates; int interference_candidate; @@@ -730,9 -728,8 +728,8 @@@ void receive_bat_packet(struct ethhdr * update_orig(bat_priv, orig_node, ethhdr, batman_packet, if_incoming, hna_buff, hna_buff_len, is_duplicate);
- mark_bonding_address(bat_priv, orig_node, - orig_neigh_node, batman_packet); - update_bonding_candidates(bat_priv, orig_node); + mark_bonding_address(orig_node, orig_neigh_node, batman_packet); + update_bonding_candidates(orig_node);
/* is single hop (direct) neighbor */ if (is_single_hop_neigh) { @@@ -810,13 -807,11 +807,11 @@@ static int recv_my_icmp_packet(struct b { struct orig_node *orig_node; struct icmp_packet_rr *icmp_packet; - struct ethhdr *ethhdr; struct batman_if *batman_if; int ret; uint8_t dstaddr[ETH_ALEN];
icmp_packet = (struct icmp_packet_rr *)skb->data; - ethhdr = (struct ethhdr *)skb_mac_header(skb);
/* add data to device queue */ if (icmp_packet->msg_type != ECHO_REQUEST) { @@@ -848,7 -843,6 +843,6 @@@ return NET_RX_DROP;
icmp_packet = (struct icmp_packet_rr *)skb->data; - ethhdr = (struct ethhdr *)skb_mac_header(skb);
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->orig, @@@ -866,17 -860,15 +860,15 @@@ }
static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, - struct sk_buff *skb, size_t icmp_len) + struct sk_buff *skb) { struct orig_node *orig_node; struct icmp_packet *icmp_packet; - struct ethhdr *ethhdr; struct batman_if *batman_if; int ret; uint8_t dstaddr[ETH_ALEN];
icmp_packet = (struct icmp_packet *)skb->data; - ethhdr = (struct ethhdr *)skb_mac_header(skb);
/* send TTL exceeded if packet is an echo request (traceroute) */ if (icmp_packet->msg_type != ECHO_REQUEST) { @@@ -909,7 -901,6 +901,6 @@@ return NET_RX_DROP;
icmp_packet = (struct icmp_packet *) skb->data; - ethhdr = (struct ethhdr *)skb_mac_header(skb);
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->orig, @@@ -978,7 -969,7 +969,7 @@@ int recv_icmp_packet(struct sk_buff *sk
/* TTL exceeded */ if (icmp_packet->ttl < 2) - return recv_icmp_ttl_exceeded(bat_priv, skb, hdr_size); + return recv_icmp_ttl_exceeded(bat_priv, skb);
ret = NET_RX_DROP;
@@@ -1001,7 -992,6 +992,6 @@@ return NET_RX_DROP;
icmp_packet = (struct icmp_packet_rr *)skb->data; - ethhdr = (struct ethhdr *)skb_mac_header(skb);
/* decrement ttl */ icmp_packet->ttl--; diff --combined net/batman-adv/routing.h index f108f23,ceeca6f..ceeca6f --- a/net/batman-adv/routing.h +++ b/net/batman-adv/routing.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * @@@ -42,7 -42,6 +42,6 @@@ int recv_vis_packet(struct sk_buff *skb int recv_bat_packet(struct sk_buff *skb, struct batman_if *recv_if); struct neigh_node *find_router(struct bat_priv *bat_priv, struct orig_node *orig_node, struct batman_if *recv_if); - void update_bonding_candidates(struct bat_priv *bat_priv, - struct orig_node *orig_node); + void update_bonding_candidates(struct orig_node *orig_node);
#endif /* _NET_BATMAN_ADV_ROUTING_H_ */ diff --combined net/batman-adv/send.c index b89b9f7,7cc620e..7cc620e --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * @@@ -49,7 -49,7 +49,7 @@@ static unsigned long own_send_time(stru }
/* when do we schedule a forwarded packet to be sent */ - static unsigned long forward_send_time(struct bat_priv *bat_priv) + static unsigned long forward_send_time(void) { return jiffies + msecs_to_jiffies(random32() % (JITTER/2)); } @@@ -356,7 -356,7 +356,7 @@@ void schedule_forward_packet(struct ori else batman_packet->flags &= ~DIRECTLINK;
- send_time = forward_send_time(bat_priv); + send_time = forward_send_time(); add_bat_packet_to_list(bat_priv, (unsigned char *)batman_packet, sizeof(struct batman_packet) + hna_buff_len, diff --combined net/batman-adv/send.h index c4cefa8,bc53ade..bc53ade --- a/net/batman-adv/send.h +++ b/net/batman-adv/send.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --combined net/batman-adv/soft-interface.c index e89ede1,145e0f7..145e0f7 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --combined net/batman-adv/soft-interface.h index 02b7733,e7b0e1a..e7b0e1a --- a/net/batman-adv/soft-interface.h +++ b/net/batman-adv/soft-interface.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --combined net/batman-adv/translation-table.c index a633b5a4,f6917dd..f6917dd --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --combined net/batman-adv/translation-table.h index 10c4c5c,a4f3a37..a4f3a37 --- a/net/batman-adv/translation-table.h +++ b/net/batman-adv/translation-table.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --combined net/batman-adv/types.h index bf3f6f5,7270405..7270405 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --combined net/batman-adv/unicast.c index fc77079,cbf022c..cbf022c --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: * * Andreas Langer * diff --combined net/batman-adv/unicast.h index e7211c2,8897308..8897308 --- a/net/batman-adv/unicast.h +++ b/net/batman-adv/unicast.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: * * Andreas Langer * diff --combined net/batman-adv/vis.c index f69a374,7db9ad8..7db9ad8 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2008-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2008-2011 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@@ -64,6 -64,7 +64,7 @@@ static void free_info(struct kref *ref
spin_unlock_bh(&bat_priv->vis_list_lock); kfree_skb(info->skb_packet); + kfree(info); }
/* Compare two vis packets, used by the hashing algorithm */ @@@ -444,7 -445,7 +445,7 @@@ static struct vis_info *add_packet(stru info); if (hash_added < 0) { /* did not work (for some reason) */ - kref_put(&old_info->refcount, free_info); + kref_put(&info->refcount, free_info); info = NULL; }
@@@ -815,7 -816,7 +816,7 @@@ static void send_vis_packets(struct wor container_of(work, struct delayed_work, work); struct bat_priv *bat_priv = container_of(delayed_work, struct bat_priv, vis_work); - struct vis_info *info, *temp; + struct vis_info *info;
spin_lock_bh(&bat_priv->vis_hash_lock); purge_vis_packets(bat_priv); @@@ -825,8 -826,9 +826,9 @@@ send_list_add(bat_priv, bat_priv->my_vis_info); }
- list_for_each_entry_safe(info, temp, &bat_priv->vis_send_list, - send_list) { + while (!list_empty(&bat_priv->vis_send_list)) { + info = list_first_entry(&bat_priv->vis_send_list, + typeof(*info), send_list);
kref_get(&info->refcount); spin_unlock_bh(&bat_priv->vis_hash_lock); diff --combined net/batman-adv/vis.h index 2c3b330,31b820d..31b820d --- a/net/batman-adv/vis.h +++ b/net/batman-adv/vis.h @@@ -1,5 -1,5 +1,5 @@@ /* - * Copyright (C) 2008-2010 B.A.T.M.A.N. contributors: + * Copyright (C) 2008-2011 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner *