Commit f341dddf authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Staging: merge staging patches into Linus's main branch

There were a number of patches that went into Linus's
tree already that conflicted with other changes in the
staging branch.  This merge resolves those merge conflicts.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parents eaa5eec7 b02957d5
......@@ -71,8 +71,6 @@ source "drivers/staging/asus_oled/Kconfig"
source "drivers/staging/panel/Kconfig"
source "drivers/staging/altpciechdma/Kconfig"
source "drivers/staging/rtl8187se/Kconfig"
source "drivers/staging/rtl8192su/Kconfig"
......@@ -81,20 +79,14 @@ source "drivers/staging/rtl8192u/Kconfig"
source "drivers/staging/rtl8192e/Kconfig"
source "drivers/staging/mimio/Kconfig"
source "drivers/staging/frontier/Kconfig"
source "drivers/staging/dream/Kconfig"
source "drivers/staging/pohmelfs/Kconfig"
source "drivers/staging/b3dfg/Kconfig"
source "drivers/staging/phison/Kconfig"
source "drivers/staging/p9auth/Kconfig"
source "drivers/staging/line6/Kconfig"
source "drivers/gpu/drm/vmwgfx/Kconfig"
......@@ -117,7 +109,7 @@ source "drivers/staging/hv/Kconfig"
source "drivers/staging/vme/Kconfig"
source "drivers/staging/rar/Kconfig"
source "drivers/staging/rar_register/Kconfig"
source "drivers/staging/sep/Kconfig"
......@@ -143,5 +135,9 @@ source "drivers/staging/netwave/Kconfig"
source "drivers/staging/sm7xx/Kconfig"
source "drivers/staging/dt3155/Kconfig"
source "drivers/staging/crystalhd/Kconfig"
endif # !STAGING_EXCLUDE_BUILD
endif # STAGING
......@@ -18,18 +18,14 @@ obj-$(CONFIG_RT2870) += rt2870/
obj-$(CONFIG_COMEDI) += comedi/
obj-$(CONFIG_ASUS_OLED) += asus_oled/
obj-$(CONFIG_PANEL) += panel/
obj-$(CONFIG_ALTERA_PCIE_CHDMA) += altpciechdma/
obj-$(CONFIG_R8187SE) += rtl8187se/
obj-$(CONFIG_RTL8192SU) += rtl8192su/
obj-$(CONFIG_RTL8192U) += rtl8192u/
obj-$(CONFIG_RTL8192E) += rtl8192e/
obj-$(CONFIG_INPUT_MIMIO) += mimio/
obj-$(CONFIG_TRANZPORT) += frontier/
obj-$(CONFIG_DREAM) += dream/
obj-$(CONFIG_POHMELFS) += pohmelfs/
obj-$(CONFIG_B3DFG) += b3dfg/
obj-$(CONFIG_IDE_PHISON) += phison/
obj-$(CONFIG_PLAN9AUTH) += p9auth/
obj-$(CONFIG_LINE6_USB) += line6/
obj-$(CONFIG_USB_SERIAL_QUATECH2) += serqt_usb2/
obj-$(CONFIG_USB_SERIAL_QUATECH_USB2) += quatech_usb2/
......@@ -39,7 +35,7 @@ obj-$(CONFIG_VT6656) += vt6656/
obj-$(CONFIG_FB_UDL) += udlfb/
obj-$(CONFIG_HYPERV) += hv/
obj-$(CONFIG_VME_BUS) += vme/
obj-$(CONFIG_RAR_REGISTER) += rar/
obj-$(CONFIG_RAR_REGISTER) += rar_register/
obj-$(CONFIG_DX_SEP) += sep/
obj-$(CONFIG_IIO) += iio/
obj-$(CONFIG_RAMZSWAP) += ramzswap/
......@@ -53,3 +49,5 @@ obj-$(CONFIG_WAVELAN) += wavelan/
obj-$(CONFIG_PCMCIA_WAVELAN) += wavelan/
obj-$(CONFIG_PCMCIA_NETWAVE) += netwave/
obj-$(CONFIG_FB_SM7XX) += sm7xx/
obj-$(CONFIG_DT3155) += dt3155/
obj-$(CONFIG_CRYSTALHD) += crystalhd/
config ALTERA_PCIE_CHDMA
tristate "Altera PCI Express Chaining DMA driver"
depends on PCI
default N
---help---
A reference driver that exercises the Chaining DMA logic reference
design generated along the Altera FPGA PCI Express soft or hard core,
only if instantiated using the MegaWizard, not the SOPC builder, of
Quartus 8.1.
obj-$(CONFIG_ALTERA_PCIE_CHDMA) += altpciechdma.o
DONE:
- functionality similar to logic testbench
TODO:
- checkpatch.pl cleanups.
- keep state of DMA engines.
- keep data structure that keeps state of each transfer.
- interrupt handler should iterate over outstanding descriptor tables.
- complete userspace cdev to read/write using the DMA engines.
- split off the DMA support functions in a module, re-usable by custom
drivers.
Please coordinate work with, and send patches to
Leon Woestenberg <leon@sidebranch.com>
This diff is collapsed.
obj-$(CONFIG_ARLAN) += arlan.o
obj-$(CONFIG_ARLAN) += arlan.o
arlan-objs := arlan-main.o arlan-proc.o
This diff is collapsed.
......@@ -52,6 +52,10 @@
#define ASUS_OLED_DISP_HEIGHT 32
#define ASUS_OLED_PACKET_BUF_SIZE 256
#define USB_VENDOR_ID_ASUS 0x0b05
#define USB_DEVICE_ID_ASUS_LCM 0x1726
#define USB_DEVICE_ID_ASUS_LCM2 0x175b
MODULE_AUTHOR("Jakub Schmidtke, sjakub@gmail.com");
MODULE_DESCRIPTION("Asus OLED Driver v" ASUS_OLED_VERSION);
MODULE_LICENSE("GPL");
......@@ -83,18 +87,20 @@ struct oled_dev_desc_str {
};
/* table of devices that work with this driver */
static struct usb_device_id id_table[] = {
static const struct usb_device_id id_table[] = {
/* Asus G1/G2 (and variants)*/
{ USB_DEVICE(0x0b05, 0x1726) },
{ USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM) },
/* Asus G50V (and possibly others - G70? G71?)*/
{ USB_DEVICE(0x0b05, 0x175b) },
{ USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2) },
{ },
};
/* parameters of specific devices */
static struct oled_dev_desc_str oled_dev_desc_table[] = {
{ 0x0b05, 0x1726, 128, PACK_MODE_G1, "G1/G2" },
{ 0x0b05, 0x175b, 256, PACK_MODE_G50, "G50" },
{ USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM, 128, PACK_MODE_G1,
"G1/G2" },
{ USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2, 256, PACK_MODE_G50,
"G50" },
{ },
};
......@@ -424,6 +430,11 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev,
kfree(odev->buf);
odev->buf = kmalloc(odev->buf_size, GFP_KERNEL);
if (odev->buf == NULL) {
odev->buf_size = 0;
printk(ASUS_OLED_ERROR "Out of memory!\n");
return -ENOMEM;
}
memset(odev->buf, 0xff, odev->buf_size);
......
config B3DFG
tristate "Brontes 3d Frame Framegrabber"
depends on PCI
default n
---help---
This driver provides support for the Brontes 3d Framegrabber
PCI card.
To compile this driver as a module, choose M here. The module
will be called b3dfg.
obj-$(CONFIG_B3DFG) += b3dfg.o
- queue/wait buffer presents filltime results for each frame?
- counting of dropped frames
- review endianness
This diff is collapsed.
......@@ -4,7 +4,7 @@
config BATMAN_ADV
tristate "B.A.T.M.A.N. Advanced Meshing Protocol"
depends on PROC_FS && PACKET
depends on PROC_FS && NET
default n
---help---
......@@ -14,10 +14,10 @@ config BATMAN_ADV
http://www.open-mesh.org/ for more information and user space
tools.
config BATMAN_DEBUG
config BATMAN_ADV_DEBUG
bool "B.A.T.M.A.N. debugging"
depends on BATMAN_ADV != n
help
---help---
This is an option for use by developers; most people should
say N here. This enables compilation of support for
......
......@@ -19,4 +19,4 @@
#
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
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
[state: 07-11-2009]
[state: 06-01-2010]
BATMAN-ADV
----------
......@@ -15,19 +15,6 @@ 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. :-)
COMPILE
-------
To compile against your currently installed kernel, just type:
# make
if you want to compile against some other kernel, use:
# make KERNELPATH=/path/to/kernel
USAGE
-----
......@@ -73,16 +60,9 @@ When configured as server, you can get a topology snapshot of your mesh:
# cat /proc/net/batman-adv/vis
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
The output is in a generic raw format. Use the batctl tool (See below)
to convert this to other formats more suitable for graphing, eg
graphviz dot, or JSON data-interchange 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
......@@ -96,15 +76,59 @@ To deactivate batman, do:
# echo "" > /proc/net/batman-adv/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 commands: 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 sometimes
necessary to see more detail debug messages. This must be enabled when
compiling the batman-adv module. Use "make menuconfig" and enable the
option "B.A.T.M.A.N. debugging".
The additional debug output is by default disabled. It can be enabled
either at kernel module load time or during run time. To enable debug
output at module load time, add the module parameter debug=<value>.
<value> can take one of four values.
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
e.g.
modprobe batman-adv debug=2
will load the module and enable debug messages for when routes or HNAs
change.
The debug output can also be changed at runtime using the file
/sys/module/batman-adv/parameters/debug. e.g.
echo 2 > /sys/module/batman-adv/parameters/debug
enables debug messages for when routes or HNAs
The debug output is sent to the kernel logs. So try dmesg, logread etc
to see the debug messages.
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.
B.A.T.M.A.N. advanced operates on layer 2 and thus 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).
......
......@@ -17,30 +17,6 @@
-> transtable_global (read-only) [outputs the global translation table]
-> transtable_local (read-only) [outputs the local translation table]
=> vis "raw" data output
* the raw format shall replace dot draw / json to offer a neutral that can
* be converted
* the format (comma seperated entries):
-> "mac" -> mac address of an originator (each line begins with it)
-> "TQ mac value" -> src mac's link quality towards mac address
-> "HNA mac" -> HNA announced by source mac
-> "PRIMARY" -> this is a primary interface
-> "SEC mac" -> secondary mac address of source (requires preceeding
-> PRIMARY)
=> logging
* the log level LOG_TYPE_CRIT, LOG_TYPE_WARN & LOG_TYPE_NOTICE will be
* unified to use printk
* LOG_TYPE_BATMAN & LOG_TYPE_ROUTES will also use printk but only after the
* internal debug level has been raised
* the internal debug level can be modified using a module parameter (debug)
* or at run time via /sys/module/batman-adv/parameters/debug
* make use of printk %pM support instead of converting mac addresses
* manually
=> strip out all backward compatibility support to older kernels
(only found in compat.h)
=> fix checkpatch.pl errors
Please send all patches to:
......
......@@ -96,6 +96,7 @@ static void new_aggregated_packet(unsigned char *packet_buff,
int own_packet)
{
struct forw_packet *forw_packet_aggr;
unsigned long flags;
forw_packet_aggr = kmalloc(sizeof(struct forw_packet), GFP_ATOMIC);
if (!forw_packet_aggr)
......@@ -115,6 +116,7 @@ static void new_aggregated_packet(unsigned char *packet_buff,
packet_buff,
forw_packet_aggr->packet_len);
forw_packet_aggr->skb = NULL;
forw_packet_aggr->own = own_packet;
forw_packet_aggr->if_incoming = if_incoming;
forw_packet_aggr->num_packets = 0;
......@@ -126,9 +128,9 @@ static void new_aggregated_packet(unsigned char *packet_buff,
forw_packet_aggr->direct_link_flags |= 1;
/* add new packet to packet list */
spin_lock(&forw_bat_list_lock);
spin_lock_irqsave(&forw_bat_list_lock, flags);
hlist_add_head(&forw_packet_aggr->list, &forw_bat_list);
spin_unlock(&forw_bat_list_lock);
spin_unlock_irqrestore(&forw_bat_list_lock, flags);
/* start timer for this packet */
INIT_DELAYED_WORK(&forw_packet_aggr->delayed_work,
......@@ -168,9 +170,10 @@ void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,
struct batman_packet *batman_packet =
(struct batman_packet *)packet_buff;
bool direct_link = batman_packet->flags & DIRECTLINK ? 1 : 0;
unsigned long flags;
/* find position for the packet in the forward queue */
spin_lock(&forw_bat_list_lock);
spin_lock_irqsave(&forw_bat_list_lock, flags);
/* own packets are not to be aggregated */
if ((atomic_read(&aggregation_enabled)) && (!own_packet)) {
hlist_for_each_entry(forw_packet_pos, tmp_node, &forw_bat_list,
......@@ -191,7 +194,7 @@ void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,
* suitable aggregation packet found */
if (forw_packet_aggr == NULL) {
/* the following section can run without the lock */
spin_unlock(&forw_bat_list_lock);
spin_unlock_irqrestore(&forw_bat_list_lock, flags);
new_aggregated_packet(packet_buff, packet_len,
send_time, direct_link,
if_incoming, own_packet);
......@@ -199,7 +202,7 @@ void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,
aggregate(forw_packet_aggr,
packet_buff, packet_len,
direct_link);
spin_unlock(&forw_bat_list_lock);
spin_unlock_irqrestore(&forw_bat_list_lock, flags);
}
}
......
......@@ -21,7 +21,6 @@
#include "main.h"
#include "bitarray.h"
#include "log.h"
/* returns true if the corresponding bit in the given seq_bits indicates true
* and curr_seqno is within range of last_seqno */
......@@ -80,8 +79,8 @@ void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n)
* from.
*
* left is high, right is low: FEDC BA98 7654 3210
* ^^ ^^
* vvvv
* ^^ ^^
* vvvv
* ^^^^ = from, vvvvv =to, we'd have word_num==1 and
* word_offset==WORD_BIT_SIZE/2 ????? in this example.
* (=24 bits)
......@@ -133,13 +132,13 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff,
(seq_num_diff < -TQ_LOCAL_WINDOW_SIZE)) {
if (seq_num_diff > TQ_LOCAL_WINDOW_SIZE)
debug_log(LOG_TYPE_BATMAN,
"We missed a lot of packets (%i) !\n",
seq_num_diff-1);
bat_dbg(DBG_BATMAN,
"We missed a lot of packets (%i) !\n",
seq_num_diff-1);
if (-seq_num_diff > TQ_LOCAL_WINDOW_SIZE)
debug_log(LOG_TYPE_BATMAN,
"Other host probably restarted !\n");
bat_dbg(DBG_BATMAN,
"Other host probably restarted !\n");
for (i = 0; i < NUM_WORDS; i++)
seq_bits[i] = 0;
......
/*
* 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
*
*
* This file contains macros for maintaining compatibility with older versions
* of the Linux kernel.
*/
#include <linux/version.h> /* LINUX_VERSION_CODE */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
#define skb_set_network_header(_skb, _offset) \
do { (_skb)->nh.raw = (_skb)->data + (_offset); } while (0)
#define skb_reset_mac_header(_skb) \
do { (_skb)->mac.raw = (_skb)->data; } while (0)
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
#define device_create(_cls, _parent, _devt, _device, _fmt) \
class_device_create(_cls, _parent, _devt, _device, _fmt)
#define device_destroy(_cls, _device) \
class_device_destroy(_cls, _device)
#else
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
#define device_create(_cls, _parent, _devt, _device, _fmt) \
device_create_drvdata(_cls, _parent, _devt, _device, _fmt)
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) */
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
#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) */
......@@ -19,14 +19,13 @@
*
*/
#include <linux/device.h>
#include "main.h"
#include "device.h"
#include "log.h"
#include "send.h"
#include "types.h"
#include "hash.h"
#include "compat.h"
#include "hard-interface.h"
static struct class *batman_class;
......@@ -60,7 +59,7 @@ int bat_device_setup(void)
/* register our device - kernel assigns a free major number */
tmp_major = register_chrdev(0, DRIVER_DEVICE, &fops);
if (tmp_major < 0) {
debug_log(LOG_TYPE_WARN, "Registering the character device failed with %d\n",
printk(KERN_ERR "batman-adv:Registering the character device failed with %d\n",
tmp_major);
return 0;
}
......@@ -68,7 +67,7 @@ int bat_device_setup(void)
batman_class = class_create(THIS_MODULE, "batman-adv");
if (IS_ERR(batman_class)) {
debug_log(LOG_TYPE_WARN, "Could not register class 'batman-adv' \n");
printk(KERN_ERR "batman-adv:Could not register class 'batman-adv' \n");
return 0;
}
......@@ -111,7 +110,7 @@ int bat_device_open(struct inode *inode, struct file *file)
}
if (device_client_hash[i] != device_client) {
debug_log(LOG_TYPE_WARN, "Error - can't add another packet client: maximum number of clients reached \n");
printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached \n");
kfree(device_client);
return -EXFULL;
}
......@@ -119,7 +118,7 @@ int bat_device_open(struct inode *inode, struct file *file)
INIT_LIST_HEAD(&device_client->queue_list);
device_client->queue_len = 0;
device_client->index = i;
device_client->lock = __SPIN_LOCK_UNLOCKED(device_client->lock);
spin_lock_init(&device_client->lock);
init_waitqueue_head(&device_client->queue_wait);
file->private_data = device_client;
......@@ -134,8 +133,9 @@ int bat_device_release(struct inode *inode, struct file *file)
(struct device_client *)file->private_data;
struct device_packet *device_packet;
struct list_head *list_pos, *list_pos_tmp;
unsigned long flags;
spin_lock(&device_client->lock);
spin_lock_irqsave(&device_client->lock, flags);
/* for all packets in the queue ... */
list_for_each_safe(list_pos, list_pos_tmp, &device_client->queue_list) {
......@@ -147,7 +147,7 @@ int bat_device_release(struct inode *inode, struct file *file)
}
device_client_hash[device_client->index] = NULL;
spin_unlock(&device_client->lock);
spin_unlock_irqrestore(&device_client->lock, flags);
kfree(device_client);
dec_module_count();
......@@ -162,6 +162,7 @@ ssize_t bat_device_read(struct file *file, char __user *buf, size_t count,
(struct device_client *)file->private_data;
struct device_packet *device_packet;
int error;
unsigned long flags;
if ((file->f_flags & O_NONBLOCK) && (device_client->queue_len == 0))
return -EAGAIN;
......@@ -178,14 +179,14 @@ ssize_t bat_device_read(struct file *file, char __user *buf, size_t count,
if (error)
return error;
spin_lock(&device_client->lock);
spin_lock_irqsave(&device_client->lock, flags);
device_packet = list_first_entry(&device_client->queue_list,
struct device_packet, list);
list_del(&device_packet->list);
device_client->queue_len--;
spin_unlock(&device_client->lock);
spin_unlock_irqrestore(&device_client->lock, flags);
error = __copy_to_user(buf, &device_packet->icmp_packet,
sizeof(struct icmp_packet));
......@@ -206,9 +207,11 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
struct icmp_packet icmp_packet;
struct orig_node *orig_node;
struct batman_if *batman_if;
uint8_t dstaddr[ETH_ALEN];
unsigned long flags;
if (len < sizeof(struct icmp_packet)) {
debug_log(LOG_TYPE_NOTICE, "Error - can't send packet from char device: invalid packet size\n");
bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: invalid packet size\n");
return -EINVAL;
}
......@@ -219,12 +222,12 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
return -EFAULT;
if (icmp_packet.packet_type != BAT_ICMP) {
debug_log(LOG_TYPE_NOTICE, "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
return -EINVAL;
}
if (icmp_packet.msg_type != ECHO_REQUEST) {
debug_log(LOG_TYPE_NOTICE, "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
return -EINVAL;
}
......@@ -240,7 +243,7 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
if (atomic_read(&module_state) != MODULE_ACTIVE)
goto dst_unreach;
spin_lock(&orig_hash_lock);
spin_lock_irqsave(&orig_hash_lock, flags);
orig_node = ((struct orig_node *)hash_find(orig_hash, icmp_packet.dst));
if (!orig_node)
......@@ -250,9 +253,15 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
goto unlock;
batman_if = orig_node->batman_if;
memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
spin_unlock_irqrestore(&orig_hash_lock, flags);
if (!batman_if)
goto unlock;
goto dst_unreach;
if (batman_if->if_active != IF_ACTIVE)
goto dst_unreach;
memcpy(icmp_packet.orig,
batman_if->net_dev->dev_addr,
......@@ -260,13 +269,12 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
send_raw_packet((unsigned char *)&icmp_packet,
sizeof(struct icmp_packet),
batman_if, orig_node->router->addr);
batman_if, dstaddr);
spin_unlock(&orig_hash_lock);
goto out;
unlock:
spin_unlock(&orig_hash_lock);
spin_unlock_irqrestore(&orig_hash_lock, flags);
dst_unreach:
icmp_packet.msg_type = DESTINATION_UNREACHABLE;
bat_device_add_packet(device_client, &icmp_packet);
......@@ -291,6 +299,7 @@ void bat_device_add_packet(struct device_client *device_client,
struct icmp_packet *icmp_packet)
{
struct device_packet *device_packet;
unsigned long flags;
device_packet = kmalloc(sizeof(struct device_packet), GFP_KERNEL);
......@@ -301,12 +310,12 @@ void bat_device_add_packet(struct device_client *device_client,
memcpy(&device_packet->icmp_packet, icmp_packet,
sizeof(struct icmp_packet));
spin_lock(&device_client->lock);
spin_lock_irqsave(&device_client->lock, flags);
/* while waiting for the lock the device_client could have been
* deleted */
if (!device_client_hash[icmp_packet->uid]) {
spin_unlock(&device_client->lock);
spin_unlock_irqrestore(&device_client->lock, flags);
kfree(device_packet);
return;
}
......@@ -323,7 +332,7 @@ void bat_device_add_packet(struct device_client *device_client,
device_client->queue_len--;
}
spin_unlock(&device_client->lock);
spin_unlock_irqrestore(&device_client->lock, flags);
wake_up(&device_client->queue_wait);
}
......
This diff is collapsed.
......@@ -32,5 +32,9 @@ void hardif_deactivate_interface(struct batman_if *batman_if);
char hardif_get_active_if_num(void);
void hardif_check_interfaces_status(void);
void hardif_check_interfaces_status_wq(struct work_struct *work);
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(void);
void update_min_mtu(void);
......@@ -64,24 +64,18 @@ void hash_destroy(struct hashtable_t *hash)
kfree(hash);
}
/* iterate though the hash. first element is selected with iter_in NULL. use
* the returned iterator to access the elements until hash_it_t returns NULL. */
/* iterate though the hash. First element is selected if an iterator
* initialized with HASHIT() is supplied as iter. Use the returned
* (or supplied) iterator to access the elements until hash_iterate returns
* NULL. */
struct hash_it_t *hash_iterate(struct hashtable_t *hash,
struct hash_it_t *iter_in)
struct hash_it_t *iter)
{
struct hash_it_t *iter;
if (!hash)
return NULL;
if (iter_in == NULL) {
iter = kmalloc(sizeof(struct hash_it_t), GFP_ATOMIC);
iter->index = -1;
iter->bucket = NULL;
iter->prev_bucket = NULL;
} else {
iter = iter_in;
}
if (!iter)
return NULL;
/* sanity checks first (if our bucket got deleted in the last
* iteration): */
......@@ -139,7 +133,6 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash,
}
/* nothing to iterate over anymore */
kfree(iter);
return NULL;
}
......
......@@ -21,6 +21,11 @@
#ifndef _BATMAN_HASH_H
#define _BATMAN_HASH_H
#define HASHIT(name) struct hash_it_t name = { \
.index = -1, .bucket = NULL, \
.prev_bucket = NULL, \
.first_bucket = NULL }
typedef int (*hashdata_compare_cb)(void *, void *);
typedef int (*hashdata_choose_cb)(void *, int);
......
/*
* 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
*
*/
#include "main.h"
#include "log.h"
#define LOG_BUF_MASK (log_buf_len-1)
#define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK])
static char log_buf[LOG_BUF_LEN];
static int log_buf_len = LOG_BUF_LEN;
static unsigned long log_start;
static unsigned long log_end;
uint8_t log_level;
static DEFINE_SPINLOCK(logbuf_lock);
const struct file_operations proc_log_operations = {
.open = log_open,
.release = log_release,
.read = log_read,
.write = log_write,
.poll = log_poll,
};
static DECLARE_WAIT_QUEUE_HEAD(log_wait);
static void emit_log_char(char c)
{
LOG_BUF(log_end) = c;
log_end++;
if (log_end - log_start > log_buf_len)
log_start = log_end - log_buf_len;
}
static int fdebug_log(char *fmt, ...)
{
int printed_len;
char *p;
va_list args;
static char debug_log_buf[256];
unsigned long flags;
spin_lock_irqsave(&logbuf_lock, flags);
va_start(args, fmt);
printed_len = vscnprintf(debug_log_buf, sizeof(debug_log_buf), fmt,
args);
va_end(args);
for (p = debug_log_buf; *p != 0; p++)
emit_log_char(*p);
spin_unlock_irqrestore(&logbuf_lock, flags);
wake_up(&log_wait);
return 0;
}
int debug_log(int type, char *fmt, ...)
{
va_list args;
int retval = 0;
char tmp_log_buf[256];
/* only critical information get into the official kernel log */
if (type == LOG_TYPE_CRIT) {
va_start(args, fmt);
vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
printk(KERN_ERR "batman-adv: %s", tmp_log_buf);
va_end(args);
}
if ((type == LOG_TYPE_CRIT) || (log_level & type)) {
va_start(args, fmt);
vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
fdebug_log("[%10u] %s", (jiffies / HZ), tmp_log_buf);
va_end(args);
}
return retval;
}
int log_open(struct inode *inode, struct file *file)
{
inc_module_count();
return 0;
}
int log_release(struct inode *inode, struct file *file)
{
dec_module_count();
return 0;
}
ssize_t log_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos)
{
int error, i = 0;
char c;
unsigned long flags;
if ((file->f_flags & O_NONBLOCK) && !(log_end - log_start))
return -EAGAIN;
if ((!buf) || (count < 0))
return -EINVAL;
if (count == 0)
return 0;
if (!access_ok(VERIFY_WRITE, buf, count))
return -EFAULT;
error = wait_event_interruptible(log_wait, (log_start - log_end));
if (error)
return error;
spin_lock_irqsave(&logbuf_lock, flags);
while ((!error) && (log_start != log_end) && (i < count)) {
c = LOG_BUF(log_start);
log_start++;
spin_unlock_irqrestore(&logbuf_lock, flags);
error = __put_user(c, buf);
spin_lock_irqsave(&logbuf_lock, flags);
buf++;
i++;
}
spin_unlock_irqrestore(&logbuf_lock, flags);
if (!error)
return i;
return error;
}
ssize_t log_write(struct file *file, const char __user *buf, size_t count,
loff_t *ppos)
{
return count;
}
unsigned int log_poll(struct file *file, poll_table *wait)
{
poll_wait(file, &log_wait, wait);
if (log_end - log_start)
return POLLIN | POLLRDNORM;
return 0;
}
......@@ -21,9 +21,9 @@
#include "main.h"
#include "proc.h"
#include "log.h"
#include "routing.h"
#include "send.h"
#include "originator.h"
#include "soft-interface.h"
#include "device.h"
#include "translation-table.h"
......@@ -31,7 +31,6 @@
#include "types.h"
#include "vis.h"
#include "hash.h"
#include "compat.h"
struct list_head if_list;
struct hlist_head forw_bat_list;
......@@ -44,19 +43,34 @@ DEFINE_SPINLOCK(forw_bcast_list_lock);
atomic_t originator_interval;
atomic_t vis_interval;
atomic_t vis_mode;
atomic_t aggregation_enabled;
int16_t num_hna;
int16_t num_ifs;
struct net_device *soft_device;
static struct task_struct *kthread_task;
unsigned char broadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
atomic_t module_state;
static struct packet_type batman_adv_packet_type __read_mostly = {
.type = __constant_htons(ETH_P_BATMAN),
.func = batman_skb_recv,
};
struct workqueue_struct *bat_event_workqueue;
#ifdef CONFIG_BATMAN_ADV_DEBUG
int debug;
module_param(debug, int, 0644);
int bat_debug_type(int type)
{
return debug & type;
}
#endif
int init_module(void)
{
int retval;
......@@ -70,6 +84,7 @@ int init_module(void)
atomic_set(&originator_interval, 1000);
atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only
* for debugging now. */
atomic_set(&vis_mode, VIS_TYPE_CLIENT_UPDATE);
atomic_set(&aggregation_enabled, 1);
/* the name should not be longer than 10 chars - see
......@@ -90,21 +105,22 @@ int init_module(void)
interface_setup);
if (!soft_device) {
debug_log(LOG_TYPE_CRIT, "Unable to allocate the batman interface\n");
printk(KERN_ERR "batman-adv:Unable to allocate the batman interface\n");
goto end;
}
retval = register_netdev(soft_device);
if (retval < 0) {
debug_log(LOG_TYPE_CRIT, "Unable to register the batman interface: %i\n", retval);
printk(KERN_ERR "batman-adv:Unable to register the batman interface: %i\n", retval);
goto free_soft_device;
}
register_netdevice_notifier(&hard_if_notifier);
dev_add_pack(&batman_adv_packet_type);
debug_log(LOG_TYPE_CRIT, "B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded \n",
SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
printk(KERN_INFO "batman-adv:B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded \n",
SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
return 0;
......@@ -124,6 +140,8 @@ void cleanup_module(void)
soft_device = NULL;
}
dev_remove_pack(&batman_adv_packet_type);
unregister_netdevice_notifier(&hard_if_notifier);
cleanup_procfs();
......@@ -151,22 +169,12 @@ void activate_module(void)
if (vis_init() < 1)
goto err;
/* (re)start kernel thread for packet processing */
if (!kthread_task) {
kthread_task = kthread_run(packet_recv_thread, NULL, "batman-adv");
if (IS_ERR(kthread_task)) {
debug_log(LOG_TYPE_CRIT, "Unable to start packet receive thread\n");
kthread_task = NULL;
}
}
update_min_mtu();
atomic_set(&module_state, MODULE_ACTIVE);
goto end;
err:
debug_log(LOG_TYPE_CRIT, "Unable to allocate memory for mesh information structures: out of mem ?\n");
printk(KERN_ERR "batman-adv:Unable to allocate memory for mesh information structures: out of mem ?\n");
shutdown_module();
end:
return;
......@@ -182,14 +190,7 @@ void shutdown_module(void)
vis_quit();
/* deactivate kernel thread for packet processing (if running) */
if (kthread_task) {
atomic_set(&exit_cond, 1);
wake_up_interruptible(&thread_wait);
kthread_stop(kthread_task);
kthread_task = NULL;
}
/* TODO: unregister BATMAN pack */
originator_free();
......
......@@ -33,16 +33,16 @@
#define TQ_MAX_VALUE 255
#define JITTER 20
#define TTL 50 /* Time To Live of broadcast messages */
#define MAX_ADDR 16 /* number of interfaces which can be added to
#define TTL 50 /* Time To Live of broadcast messages */
#define MAX_ADDR 16 /* number of interfaces which can be added to
* batman. */
#define PURGE_TIMEOUT 200000 /* purge originators after time in ms if no
#define PURGE_TIMEOUT 200000 /* purge originators after time in ms if no
* valid packet comes in -> TODO: check
* influence on TQ_LOCAL_WINDOW_SIZE */
#define LOCAL_HNA_TIMEOUT 3600000
#define TQ_LOCAL_WINDOW_SIZE 64 /* sliding packet range of received originator
#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
......@@ -69,24 +69,27 @@
/*
* Logging
* Debug Messages
*/
#define LOG_TYPE_CRIT 0 /* highest priority for fatal errors such as
* blocked sockets / failed packet delivery /
* programming errors */
#define LOG_TYPE_WARN 1 /* warnings for small errors like wrong user
* input / damaged packets / etc */
#define LOG_TYPE_NOTICE 2 /* notice information for new interfaces /
* changed settings / new originators / etc */
#define LOG_TYPE_BATMAN 4 /* all messages related to routing / flooding /
* broadcasting / etc */
#define LOG_TYPE_ROUTES 8 /* route or hna added / changed / deleted */
#define LOG_TYPE_CRIT_NAME "critical"
#define LOG_TYPE_WARN_NAME "warnings"
#define LOG_TYPE_NOTICE_NAME "notices"
#define LOG_TYPE_BATMAN_NAME "batman"
#define LOG_TYPE_ROUTES_NAME "routes"
#define DBG_BATMAN 1 /* all messages related to routing / flooding /
* broadcasting / etc */
#define DBG_ROUTES 2 /* route or hna added / changed / deleted */
#ifdef CONFIG_BATMAN_ADV_DEBUG
extern int debug;
extern int bat_debug_type(int type);
#define bat_dbg(type, fmt, arg...) do { \
if (bat_debug_type(type)) \
printk(KERN_DEBUG "batman-adv:" fmt, ## arg); \
} \
while (0)
#else /* !CONFIG_BATMAN_ADV_DEBUG */
#define bat_dbg(type, fmt, arg...) do { \
} \
while (0)
#endif
/*
* Vis
......@@ -127,6 +130,7 @@ extern spinlock_t forw_bcast_list_lock;
extern atomic_t originator_interval;
extern atomic_t vis_interval;
extern atomic_t vis_mode;
extern atomic_t aggregation_enabled;
extern int16_t num_hna;
extern int16_t num_ifs;
......@@ -147,5 +151,3 @@ int choose_orig(void *data, int32_t size);
int is_my_mac(uint8_t *addr);
int is_bcast(uint8_t *addr);
int is_mcast(uint8_t *addr);
/*
* Copyright (C) 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
*
*/
/* increase the reference counter for this originator */
#include "main.h"
#include "originator.h"
#include "hash.h"
#include "translation-table.h"
#include "routing.h"
static DECLARE_DELAYED_WORK(purge_orig_wq, purge_orig);
static void start_purge_timer(void)
{
queue_delayed_work(bat_event_workqueue, &purge_orig_wq, 1 * HZ);
}
int originator_init(void)
{
unsigned long flags;
if (orig_hash)
return 1;
spin_lock_irqsave(&orig_hash_lock, flags);
orig_hash = hash_new(128, compare_orig, choose_orig);
if (!orig_hash)
goto err;
spin_unlock_irqrestore(&orig_hash_lock, flags);
start_purge_timer();
return 1;
err:
spin_unlock_irqrestore(&orig_hash_lock, flags);
return 0;
}
void originator_free(void)
{
unsigned long flags;
if (!orig_hash)
return;
cancel_delayed_work_sync(&purge_orig_wq);
spin_lock_irqsave(&orig_hash_lock, flags);
hash_delete(orig_hash, free_orig_node);
orig_hash = NULL;
spin_unlock_irqrestore(&orig_hash_lock, flags);
}
struct neigh_node *
create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
uint8_t *neigh, struct batman_if *if_incoming)
{
struct neigh_node *neigh_node;
bat_dbg(DBG_BATMAN, "Creating new last-hop neighbor of originator\n");
neigh_node = kzalloc(sizeof(struct neigh_node), GFP_ATOMIC);
if (!neigh_node)
return NULL;
INIT_LIST_HEAD(&neigh_node->list);
memcpy(neigh_node->addr, neigh, ETH_ALEN);
neigh_node->orig_node = orig_neigh_node;
neigh_node->if_incoming = if_incoming;
list_add_tail(&neigh_node->list, &orig_node->neigh_list);
return neigh_node;
}
void free_orig_node(void *data)
{
struct list_head *list_pos, *list_pos_tmp;
struct neigh_node *neigh_node;
struct orig_node *orig_node = (struct orig_node *)data;
/* for all neighbors towards this originator ... */
list_for_each_safe(list_pos, list_pos_tmp, &orig_node->neigh_list) {
neigh_node = list_entry(list_pos, struct neigh_node, list);
list_del(list_pos);
kfree(neigh_node);
}
hna_global_del_orig(orig_node, "originator timed out");
kfree(orig_node->bcast_own);
kfree(orig_node->bcast_own_sum);
kfree(orig_node);
}
/* this function finds or creates an originator entry for the given
* address if it does not exits */
struct orig_node *get_orig_node(uint8_t *addr)
{
struct orig_node *orig_node;
struct hashtable_t *swaphash;
int size;
orig_node = ((struct orig_node *)hash_find(orig_hash, addr));
if (orig_node != NULL)
return orig_node;
bat_dbg(DBG_BATMAN, "Creating new originator: %pM \n", addr);
orig_node = kzalloc(sizeof(struct orig_node), GFP_ATOMIC);
if (!orig_node)
return NULL;
INIT_LIST_HEAD(&orig_node->neigh_list);
memcpy(orig_node->orig, addr, ETH_ALEN);
orig_node->router = NULL;
orig_node->batman_if = NULL;
orig_node->hna_buff = NULL;
size = num_ifs * sizeof(TYPE_OF_WORD) * NUM_WORDS;
orig_node->bcast_own = kzalloc(size, GFP_ATOMIC);
if (!orig_node->bcast_own)
goto free_orig_node;
size = num_ifs * sizeof(uint8_t);
orig_node->bcast_own_sum = kzalloc(size, GFP_ATOMIC);
if (!orig_node->bcast_own_sum)
goto free_bcast_own;
if (hash_add(orig_hash, orig_node) < 0)
goto free_bcast_own_sum;
if (orig_hash->elements * 4 > orig_hash->size) {
swaphash = hash_resize(orig_hash, orig_hash->size * 2);
if (swaphash == NULL)
printk(KERN_ERR
"batman-adv:Couldn't resize orig hash table \n");
else
orig_hash = swaphash;
}
return orig_node;
free_bcast_own_sum:
kfree(orig_node->bcast_own_sum);
free_bcast_own:
kfree(orig_node->bcast_own);
free_orig_node:
kfree(orig_node);
return NULL;
}
static bool purge_orig_neighbors(struct orig_node *orig_node,
struct neigh_node **best_neigh_node)
{
struct list_head *list_pos, *list_pos_tmp;
struct neigh_node *neigh_node;
bool neigh_purged = false;
*best_neigh_node = NULL;
/* for all neighbors towards this originator ... */
list_for_each_safe(list_pos, list_pos_tmp, &orig_node->neigh_list) {
neigh_node = list_entry(list_pos, struct neigh_node, list);
if (time_after(jiffies,
(neigh_node->last_valid +
((PURGE_TIMEOUT * HZ) / 1000)))) {
bat_dbg(DBG_BATMAN, "neighbor timeout: originator %pM, neighbor: %pM, last_valid %lu\n", orig_node->orig, neigh_node->addr, (neigh_node->last_valid / HZ));
neigh_purged = true;
list_del(list_pos);
kfree(neigh_node);
} else {
if ((*best_neigh_node == NULL) ||
(neigh_node->tq_avg > (*best_neigh_node)->tq_avg))
*best_neigh_node = neigh_node;
}
}
return neigh_purged;
}
static bool purge_orig_node(struct orig_node *orig_node)
{
struct neigh_node *best_neigh_node;
if (time_after(jiffies,
(orig_node->last_valid +
((2 * PURGE_TIMEOUT * HZ) / 1000)))) {
bat_dbg(DBG_BATMAN,
"Originator timeout: originator %pM, last_valid %lu\n",
orig_node->orig, (orig_node->last_valid / HZ));
return true;
} else {
if (purge_orig_neighbors(orig_node, &best_neigh_node))
update_routes(orig_node, best_neigh_node,
orig_node->hna_buff,
orig_node->hna_buff_len);
}
return false;
}
void purge_orig(struct work_struct *work)
{
HASHIT(hashit);
struct orig_node *orig_node;
unsigned long flags;
spin_lock_irqsave(&orig_hash_lock, flags);
/* for all origins... */
while (hash_iterate(orig_hash, &hashit)) {
orig_node = hashit.bucket->data;
if (purge_orig_node(orig_node)) {
hash_remove_bucket(orig_hash, &hashit);
free_orig_node(orig_node);
}
}
spin_unlock_irqrestore(&orig_hash_lock, flags);
start_purge_timer();
}
......@@ -19,14 +19,13 @@
*
*/
extern const struct file_operations proc_log_operations;
extern uint8_t log_level;
int originator_init(void);
void free_orig_node(void *data);
void originator_free(void);
void purge_orig(struct work_struct *work);
struct orig_node *orig_find(char *mac);
struct orig_node *get_orig_node(uint8_t *addr);
struct neigh_node *
create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
uint8_t *neigh, struct batman_if *if_incoming);
int debug_log(int type, char *fmt, ...);
int log_open(struct inode *inode, struct file *file);
int log_release(struct inode *inode, struct file *file);
ssize_t log_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos);
ssize_t log_write(struct file *file, const char __user *buf, size_t count,
loff_t *ppos);
unsigned int log_poll(struct file *file, poll_table *wait);
......@@ -90,7 +90,7 @@ struct vis_packet {
uint8_t entries; /* number of entries behind this struct */
uint8_t ttl; /* TTL */
uint8_t vis_orig[6]; /* originator that informs about its
* neighbours */
* neighbors */
uint8_t target_orig[6]; /* who should receive this packet */
uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */
} __attribute__((packed));
This diff is collapsed.
......@@ -31,19 +31,10 @@
#define PROC_FILE_LOG_LEVEL "log_level"
#define PROC_FILE_TRANST_LOCAL "transtable_local"
#define PROC_FILE_TRANST_GLOBAL "transtable_global"
#define PROC_FILE_VIS "vis"
#define PROC_FILE_VIS_FORMAT "vis_format"
#define PROC_FILE_VIS_SRV "vis_server"
#define PROC_FILE_VIS_DATA "vis_data"
#define PROC_FILE_AGGR "aggregate_ogm"
void cleanup_procfs(void);
int setup_procfs(void);
/* While scanning for vis-entries of a particular vis-originator
* this list collects its interfaces to create a subgraph/cluster
* out of them later
*/
struct vis_if_list {
uint8_t addr[ETH_ALEN];
bool primary;
struct vis_if_list *next;
};
This diff is collapsed.
......@@ -22,13 +22,18 @@
#include "types.h"
extern wait_queue_head_t thread_wait;
extern atomic_t exit_cond;
int originator_init(void);
void free_orig_node(void *data);
void originator_free(void);
void slide_own_bcast_window(struct batman_if *batman_if);
void batman_data_ready(struct sock *sk, int len);
void purge_orig(struct work_struct *work);
int packet_recv_thread(void *data);
void receive_bat_packet(struct ethhdr *ethhdr, struct batman_packet *batman_packet, unsigned char *hna_buff, int hna_buff_len, struct batman_if *if_incoming);
void receive_bat_packet(struct ethhdr *ethhdr,
struct batman_packet *batman_packet,
unsigned char *hna_buff, int hna_buff_len,
struct batman_if *if_incoming);
void update_routes(struct orig_node *orig_node,
struct neigh_node *neigh_node,
unsigned char *hna_buff, int hna_buff_len);
int recv_icmp_packet(struct sk_buff *skb);
int recv_unicast_packet(struct sk_buff *skb);
int recv_bcast_packet(struct sk_buff *skb);
int recv_vis_packet(struct sk_buff *skb);
int recv_bat_packet(struct sk_buff *skb,
struct batman_if *batman_if);
This diff is collapsed.
......@@ -22,6 +22,9 @@
#include "types.h"
void send_own_packet_work(struct work_struct *work);
int send_skb_packet(struct sk_buff *skb,
struct batman_if *batman_if,
uint8_t *dst_addr);
void send_raw_packet(unsigned char *pack_buff, int pack_buff_len,
struct batman_if *batman_if, uint8_t *dst_addr);
void schedule_own_packet(struct batman_if *batman_if);
......@@ -30,7 +33,7 @@ void schedule_forward_packet(struct orig_node *orig_node,
struct batman_packet *batman_packet,
uint8_t directlink, int hna_buff_len,
struct batman_if *if_outgoing);
void add_bcast_packet_to_list(unsigned char *packet_buff, int packet_len);
void add_bcast_packet_to_list(struct sk_buff *skb);
void send_outstanding_bcast_packet(struct work_struct *work);
void send_outstanding_bat_packet(struct work_struct *work);
void purge_outstanding_packets(void);
......@@ -24,18 +24,15 @@
#include "hard-interface.h"
#include "send.h"
#include "translation-table.h"
#include "log.h"
#include "types.h"
#include "hash.h"
#include <linux/ethtool.h>
#include <linux/etherdevice.h>
#include "compat.h"
static uint16_t bcast_seqno = 1; /* give own bcast messages seq numbers to avoid
* broadcast storms */
static int32_t skb_packets;
static int32_t skb_bad_packets;
static int32_t lock_dropped;
unsigned char mainIfAddr[ETH_ALEN];
static unsigned char mainIfAddr_default[ETH_ALEN];
......@@ -68,12 +65,12 @@ int main_if_was_up(void)
return (memcmp(mainIfAddr, mainIfAddr_default, ETH_ALEN) != 0 ? 1 : 0);
}
static int my_skb_push(struct sk_buff *skb, unsigned int len)
int my_skb_push(struct sk_buff *skb, unsigned int len)
{
int result = 0;
skb_packets++;
if (skb->data - len < skb->head) {
if (skb_headroom(skb) < len) {
skb_bad_packets++;
result = pskb_expand_head(skb, len, 0, GFP_ATOMIC);
......@@ -122,7 +119,7 @@ void interface_setup(struct net_device *dev)
/* generate random address */
random_ether_addr(dev_addr);
memcpy(dev->dev_addr, dev_addr, sizeof(dev->dev_addr));
memcpy(dev->dev_addr, dev_addr, ETH_ALEN);
SET_ETHTOOL_OPS(dev, &bat_ethtool_ops);
......@@ -147,9 +144,18 @@ struct net_device_stats *interface_stats(struct net_device *dev)
return &priv->stats;
}
int interface_set_mac_addr(struct net_device *dev, void *addr)
int interface_set_mac_addr(struct net_device *dev, void *p)
{
return -EBUSY;
struct sockaddr *addr = p;
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
hna_local_remove(dev->dev_addr, "mac address changed");
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
hna_local_add(dev->dev_addr);
return 0;
}
int interface_change_mtu(struct net_device *dev, int new_mtu)
......@@ -170,7 +176,10 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
struct orig_node *orig_node;
struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct bat_priv *priv = netdev_priv(dev);
struct batman_if *batman_if;
uint8_t dstaddr[6];
int data_len = skb->len;
unsigned long flags;
if (atomic_read(&module_state) != MODULE_ACTIVE)
goto dropped;
......@@ -186,7 +195,6 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
goto dropped;
bcast_packet = (struct bcast_packet *)skb->data;
bcast_packet->version = COMPAT_VERSION;
/* batman packet type: broadcast */
......@@ -195,27 +203,21 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
/* hw address of first interface is the orig mac because only
* this mac is known throughout the mesh */
memcpy(bcast_packet->orig, mainIfAddr, ETH_ALEN);
/* set broadcast sequence number */
bcast_packet->seqno = htons(bcast_seqno);
bcast_seqno++;
/* broadcast packet */
add_bcast_packet_to_list(skb->data, skb->len);
add_bcast_packet_to_list(skb);
/* a copy is stored in the bcast list, therefore removing
* the original skb. */
kfree_skb(skb);
/* unicast packet */
} else {
/* simply spin_lock()ing can deadlock when the lock is already
* hold. */
/* TODO: defer the work in a working queue instead of
* dropping */
if (!spin_trylock(&orig_hash_lock)) {
lock_dropped++;
debug_log(LOG_TYPE_NOTICE, "%d packets dropped because lock was hold\n", lock_dropped);
goto dropped;
}
spin_lock_irqsave(&orig_hash_lock, flags);
/* get routing information */
orig_node = ((struct orig_node *)hash_find(orig_hash,
ethhdr->h_dest));
......@@ -244,14 +246,17 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
if (orig_node->batman_if->if_active != IF_ACTIVE)
goto unlock;
send_raw_packet(skb->data, skb->len,
orig_node->batman_if,
orig_node->router->addr);
/* don't lock while sending the packets ... we therefore
* copy the required data before sending */
batman_if = orig_node->batman_if;
memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
spin_unlock_irqrestore(&orig_hash_lock, flags);
send_skb_packet(skb, batman_if, dstaddr);
} else {
goto unlock;
}
spin_unlock(&orig_hash_lock);
}
priv->stats.tx_packets++;
......@@ -259,42 +264,44 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
goto end;
unlock:
spin_unlock(&orig_hash_lock);
spin_unlock_irqrestore(&orig_hash_lock, flags);
dropped:
priv->stats.tx_dropped++;
end:
kfree_skb(skb);
return 0;
return NETDEV_TX_OK;
}
void interface_rx(struct net_device *dev, void *packet, int packet_len)
void interface_rx(struct sk_buff *skb, int hdr_size)
{
struct sk_buff *skb;
struct net_device *dev = soft_device;
struct bat_priv *priv = netdev_priv(dev);
skb = dev_alloc_skb(packet_len);
if (!skb) {
priv->stats.rx_dropped++;
goto out;
/* check if enough space is available for pulling, and pull */
if (!pskb_may_pull(skb, hdr_size)) {
kfree_skb(skb);
return;
}
skb_pull_rcsum(skb, hdr_size);
/* skb_set_mac_header(skb, -sizeof(struct ethhdr));*/
memcpy(skb_put(skb, packet_len), packet, packet_len);
/* Write metadata, and then pass to the receive level */
skb->dev = dev;
skb->protocol = eth_type_trans(skb, dev);
skb->ip_summed = CHECKSUM_UNNECESSARY;
/* should not be neccesary anymore as we use skb_pull_rcsum()
* TODO: please verify this and remove this TODO
* -- Dec 21st 2009, Simon Wunderlich */
/* skb->ip_summed = CHECKSUM_UNNECESSARY;*/
/* TODO: set skb->pkt_type to PACKET_BROADCAST, PACKET_MULTICAST,
* PACKET_OTHERHOST or PACKET_HOST */
priv->stats.rx_packets++;
priv->stats.rx_bytes += packet_len;
priv->stats.rx_bytes += skb->len;
dev->last_rx = jiffies;
netif_rx(skb);
out:
return;
}
/* ethtool */
......@@ -330,7 +337,6 @@ static u32 bat_get_msglevel(struct net_device *dev)
static void bat_set_msglevel(struct net_device *dev, u32 value)
{
return;
}
static u32 bat_get_link(struct net_device *dev)
......
......@@ -28,6 +28,7 @@ struct net_device_stats *interface_stats(struct net_device *dev);
int interface_set_mac_addr(struct net_device *dev, void *addr);
int interface_change_mtu(struct net_device *dev, int new_mtu);
int interface_tx(struct sk_buff *skb, struct net_device *dev);
void interface_rx(struct net_device *dev, void *packet, int packet_len);
void interface_rx(struct sk_buff *skb, int hdr_size);
int my_skb_push(struct sk_buff *skb, unsigned int len);
extern unsigned char mainIfAddr[];
......@@ -23,6 +23,7 @@
int hna_local_init(void);
void hna_local_add(uint8_t *addr);
void hna_local_remove(uint8_t *addr, char *message);
int hna_local_fill_buffer(unsigned char *buff, int buff_len);
int hna_local_fill_buffer_text(unsigned char *buff, int buff_len);
void hna_local_purge(struct work_struct *work);
......
......@@ -39,7 +39,6 @@ struct batman_if {
char if_active;
char addr_str[ETH_STR_LEN];
struct net_device *net_dev;
struct socket *raw_sock;
atomic_t seqno;
unsigned char *packet_buff;
int packet_len;
......@@ -75,7 +74,7 @@ struct neigh_node {
uint8_t tq_index;
uint8_t tq_avg;
uint8_t last_ttl;
unsigned long last_valid; /* when last packet via this neighbour was received */
unsigned long last_valid; /* when last packet via this neighbor was received */
TYPE_OF_WORD real_bits[NUM_WORDS];
struct orig_node *orig_node;
struct batman_if *if_incoming;
......@@ -113,6 +112,7 @@ struct forw_packet { /* structure for forw_list maintaining packet
struct hlist_node list;
unsigned long send_time;
uint8_t own;
struct sk_buff *skb;
unsigned char *packet_buff;
uint16_t packet_len;
uint32_t direct_link_flags;
......@@ -121,4 +121,14 @@ struct forw_packet { /* structure for forw_list maintaining packet
struct batman_if *if_incoming;
};
/* While scanning for vis-entries of a particular vis-originator
* this list collects its interfaces to create a subgraph/cluster
* out of them later
*/
struct if_list_entry {
uint8_t addr[ETH_ALEN];
bool primary;
struct hlist_node list;
};
#endif
This diff is collapsed.
This diff is collapsed.
......@@ -26,7 +26,6 @@
#define __NO_VERSION__
#include "comedi.h"
#include <linux/smp_lock.h>
#include <linux/uaccess.h>
#include "comedi_compat32.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment