提交 cc41f5ce 编写于 作者: L Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6: (524 commits)
  Staging: wlan-ng: Update prism2_set_tx_power() to use mBm
  Staging: ti-st: update TODO
  Staging: wlags49_h2: use common PCI_VENDOR/DEVICE_ID name format
  Staging: comedi : fix brace coding style issue in wwrap.c
  Staging: quatech_usb2: remove unused qt2_box_flush function
  Staging: slicoss: Remove net_device_stats from the driver's private
  staging: rtl8192su: check whether requests succeeded
  staging: panel: fix error path
  staging: otus: check kmalloc() return value
  staging: octeon: check request_irq() return value
  Staging: wlan-ng: remove typedef in p80211hdr.h
  Staging: wlan-ng: fix checkpatch issues in headers.
  Staging: wlan-ng: remove typedef in p80211ioctl.h
  Staging: wlan-ng: fix style issues in p80211conv.h
  Staging: wlan-ng: fix style issues for p80211hdr.h
  staging: vt6656: removed NTSTATUS definition
  staging: vt6656: simplified tests involving both multi/broad-casts
  Staging: vt6655: replace BOOL with in kernel bool
  Staging: vt6655: replace FALSE with in kernel false
  Staging: vt6655: replace TRUE with in kernel true
  ...
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <asm/mshyperv.h> #include <asm/mshyperv.h>
struct ms_hyperv_info ms_hyperv; struct ms_hyperv_info ms_hyperv;
EXPORT_SYMBOL_GPL(ms_hyperv);
static bool __init ms_hyperv_platform(void) static bool __init ms_hyperv_platform(void)
{ {
......
...@@ -97,6 +97,8 @@ source "drivers/staging/octeon/Kconfig" ...@@ -97,6 +97,8 @@ source "drivers/staging/octeon/Kconfig"
source "drivers/staging/serqt_usb2/Kconfig" source "drivers/staging/serqt_usb2/Kconfig"
source "drivers/staging/spectra/Kconfig"
source "drivers/staging/quatech_usb2/Kconfig" source "drivers/staging/quatech_usb2/Kconfig"
source "drivers/staging/vt6655/Kconfig" source "drivers/staging/vt6655/Kconfig"
...@@ -115,7 +117,7 @@ source "drivers/staging/sep/Kconfig" ...@@ -115,7 +117,7 @@ source "drivers/staging/sep/Kconfig"
source "drivers/staging/iio/Kconfig" source "drivers/staging/iio/Kconfig"
source "drivers/staging/ramzswap/Kconfig" source "drivers/staging/zram/Kconfig"
source "drivers/staging/wlags49_h2/Kconfig" source "drivers/staging/wlags49_h2/Kconfig"
...@@ -127,8 +129,6 @@ source "drivers/staging/samsung-laptop/Kconfig" ...@@ -127,8 +129,6 @@ source "drivers/staging/samsung-laptop/Kconfig"
source "drivers/staging/sm7xx/Kconfig" source "drivers/staging/sm7xx/Kconfig"
source "drivers/staging/dt3155/Kconfig"
source "drivers/staging/dt3155v4l/Kconfig" source "drivers/staging/dt3155v4l/Kconfig"
source "drivers/staging/crystalhd/Kconfig" source "drivers/staging/crystalhd/Kconfig"
...@@ -147,5 +147,13 @@ source "drivers/staging/msm/Kconfig" ...@@ -147,5 +147,13 @@ source "drivers/staging/msm/Kconfig"
source "drivers/staging/lirc/Kconfig" source "drivers/staging/lirc/Kconfig"
source "drivers/staging/easycap/Kconfig"
source "drivers/staging/solo6x10/Kconfig"
source "drivers/staging/tidspbridge/Kconfig"
source "drivers/staging/quickstart/Kconfig"
endif # !STAGING_EXCLUDE_BUILD endif # !STAGING_EXCLUDE_BUILD
endif # STAGING endif # STAGING
...@@ -23,6 +23,7 @@ obj-$(CONFIG_R8187SE) += rtl8187se/ ...@@ -23,6 +23,7 @@ obj-$(CONFIG_R8187SE) += rtl8187se/
obj-$(CONFIG_RTL8192SU) += rtl8192su/ obj-$(CONFIG_RTL8192SU) += rtl8192su/
obj-$(CONFIG_RTL8192U) += rtl8192u/ obj-$(CONFIG_RTL8192U) += rtl8192u/
obj-$(CONFIG_RTL8192E) += rtl8192e/ obj-$(CONFIG_RTL8192E) += rtl8192e/
obj-$(CONFIG_SPECTRA) += spectra/
obj-$(CONFIG_TRANZPORT) += frontier/ obj-$(CONFIG_TRANZPORT) += frontier/
obj-$(CONFIG_DREAM) += dream/ obj-$(CONFIG_DREAM) += dream/
obj-$(CONFIG_POHMELFS) += pohmelfs/ obj-$(CONFIG_POHMELFS) += pohmelfs/
...@@ -39,13 +40,12 @@ obj-$(CONFIG_VME_BUS) += vme/ ...@@ -39,13 +40,12 @@ obj-$(CONFIG_VME_BUS) += vme/
obj-$(CONFIG_MRST_RAR_HANDLER) += memrar/ obj-$(CONFIG_MRST_RAR_HANDLER) += memrar/
obj-$(CONFIG_DX_SEP) += sep/ obj-$(CONFIG_DX_SEP) += sep/
obj-$(CONFIG_IIO) += iio/ obj-$(CONFIG_IIO) += iio/
obj-$(CONFIG_RAMZSWAP) += ramzswap/ obj-$(CONFIG_ZRAM) += zram/
obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/ obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/
obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/ obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/
obj-$(CONFIG_BATMAN_ADV) += batman-adv/ obj-$(CONFIG_BATMAN_ADV) += batman-adv/
obj-$(CONFIG_SAMSUNG_LAPTOP) += samsung-laptop/ obj-$(CONFIG_SAMSUNG_LAPTOP) += samsung-laptop/
obj-$(CONFIG_FB_SM7XX) += sm7xx/ obj-$(CONFIG_FB_SM7XX) += sm7xx/
obj-$(CONFIG_DT3155) += dt3155/
obj-$(CONFIG_VIDEO_DT3155) += dt3155v4l/ obj-$(CONFIG_VIDEO_DT3155) += dt3155v4l/
obj-$(CONFIG_CRYSTALHD) += crystalhd/ obj-$(CONFIG_CRYSTALHD) += crystalhd/
obj-$(CONFIG_CXT1E1) += cxt1e1/ obj-$(CONFIG_CXT1E1) += cxt1e1/
...@@ -54,3 +54,7 @@ obj-$(CONFIG_ADIS16255) += adis16255/ ...@@ -54,3 +54,7 @@ obj-$(CONFIG_ADIS16255) += adis16255/
obj-$(CONFIG_FB_XGI) += xgifb/ obj-$(CONFIG_FB_XGI) += xgifb/
obj-$(CONFIG_TOUCHSCREEN_MRSTOUCH) += mrst-touchscreen/ obj-$(CONFIG_TOUCHSCREEN_MRSTOUCH) += mrst-touchscreen/
obj-$(CONFIG_MSM_STAGING) += msm/ obj-$(CONFIG_MSM_STAGING) += msm/
obj-$(CONFIG_EASYCAP) += easycap/
obj-$(CONFIG_SOLO6X10) += solo6x10/
obj-$(CONFIG_TIDSPBRIDGE) += tidspbridge/
obj-$(CONFIG_ACPI_QUICKSTART) += quickstart/
...@@ -303,7 +303,7 @@ static int spi_adis16255_bringup(struct spi_adis16255_data *spiadis) ...@@ -303,7 +303,7 @@ static int spi_adis16255_bringup(struct spi_adis16255_data *spiadis)
if (status != 0) if (status != 0)
goto err; goto err;
if (value != 0x0800) { if (value != 0x0800) {
dev_warn(&spiadis->spi->dev, "Scale factor is none default" dev_warn(&spiadis->spi->dev, "Scale factor is none default "
"value (%.4x)\n", value); "value (%.4x)\n", value);
} }
...@@ -338,7 +338,7 @@ static int spi_adis16255_bringup(struct spi_adis16255_data *spiadis) ...@@ -338,7 +338,7 @@ static int spi_adis16255_bringup(struct spi_adis16255_data *spiadis)
status = -ENODEV; status = -ENODEV;
goto err; goto err;
} else if (value & 0x3) { } else if (value & 0x3) {
dev_warn(&spiadis->spi->dev, "Sensor voltage" dev_warn(&spiadis->spi->dev, "Sensor voltage "
"out of range.\n"); "out of range.\n");
status = -ENODEV; status = -ENODEV;
goto err; goto err;
......
batman-adv 2010.0.0:
* support latest kernels (2.6.21 - 2.6.35)
* further code refactoring and cleaning for coding style
* move from procfs based configuration to sysfs
* reorganized sequence number handling
* limit queue lengths for batman and broadcast packets
* many bugs (endless loop and rogue packets on shutdown, wrong tcpdump output,
missing frees in error situations, sleeps in atomic contexts) squashed
-- Fri, 18 Jun 2010 21:34:26 +0200
batman-adv 0.2.1: batman-adv 0.2.1:
* support latest kernels (2.6.20 - 2.6.33) * support latest kernels (2.6.20 - 2.6.33)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
config BATMAN_ADV config BATMAN_ADV
tristate "B.A.T.M.A.N. Advanced Meshing Protocol" tristate "B.A.T.M.A.N. Advanced Meshing Protocol"
depends on PROC_FS && NET depends on NET
default n default n
---help--- ---help---
......
...@@ -18,5 +18,5 @@ ...@@ -18,5 +18,5 @@
# 02110-1301, USA # 02110-1301, USA
# #
obj-m += batman-adv.o obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
batman-adv-objs := main.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 bat_sysfs.o batman-adv-objs := main.o bat_debugfs.o bat_sysfs.o send.o routing.o soft-interface.o icmp_socket.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o
[state: 03-05-2010] [state: 12-06-2010]
BATMAN-ADV BATMAN-ADV
---------- ----------
......
Request a review. * Use hweight* for hamming weight calculation
Process the comments from the review. * Save/cache packets direktly as skb instead of using a normal memory region
Move into mainline proper. and copying it in a skb using send_raw_packet and similar functions
* Request a new review
* Process the comments from the review
* Move into mainline proper
Please send all patches to: Please send all patches to:
Marek Lindner <lindner_marek@yahoo.de> Marek Lindner <lindner_marek@yahoo.de>
......
...@@ -106,11 +106,14 @@ static void new_aggregated_packet(unsigned char *packet_buff, ...@@ -106,11 +106,14 @@ static void new_aggregated_packet(unsigned char *packet_buff,
{ {
struct forw_packet *forw_packet_aggr; struct forw_packet *forw_packet_aggr;
unsigned long flags; unsigned long flags;
/* FIXME: each batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
/* own packet should always be scheduled */ /* own packet should always be scheduled */
if (!own_packet) { if (!own_packet) {
if (!atomic_dec_not_zero(&batman_queue_left)) { if (!atomic_dec_not_zero(&batman_queue_left)) {
bat_dbg(DBG_BATMAN, "batman packet queue full\n"); bat_dbg(DBG_BATMAN, bat_priv,
"batman packet queue full\n");
return; return;
} }
} }
...@@ -252,9 +255,9 @@ void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff, ...@@ -252,9 +255,9 @@ void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
while (aggregated_packet(buff_pos, packet_len, while (aggregated_packet(buff_pos, packet_len,
batman_packet->num_hna)) { batman_packet->num_hna)) {
/* network to host order for our 16bit seqno, and the /* network to host order for our 32bit seqno, and the
orig_interval. */ orig_interval. */
batman_packet->seqno = ntohs(batman_packet->seqno); batman_packet->seqno = ntohl(batman_packet->seqno);
hna_buff = packet_buff + buff_pos + BAT_PACKET_LEN; hna_buff = packet_buff + buff_pos + BAT_PACKET_LEN;
receive_bat_packet(ethhdr, batman_packet, receive_bat_packet(ethhdr, batman_packet,
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_AGGREGATION_H_
#define _NET_BATMAN_ADV_AGGREGATION_H_
#include "main.h" #include "main.h"
/* is there another aggregated packet here? */ /* is there another aggregated packet here? */
...@@ -36,3 +39,5 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv, ...@@ -36,3 +39,5 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
unsigned long send_time); unsigned long send_time);
void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff, void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
int packet_len, struct batman_if *if_incoming); int packet_len, struct batman_if *if_incoming);
#endif /* _NET_BATMAN_ADV_AGGREGATION_H_ */
/*
* Copyright (C) 2010 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* 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 <linux/debugfs.h>
#include "bat_debugfs.h"
#include "translation-table.h"
#include "originator.h"
#include "hard-interface.h"
#include "vis.h"
#include "icmp_socket.h"
static struct dentry *bat_debugfs;
#ifdef CONFIG_BATMAN_ADV_DEBUG
#define LOG_BUFF_MASK (log_buff_len-1)
#define LOG_BUFF(idx) (debug_log->log_buff[(idx) & LOG_BUFF_MASK])
static int log_buff_len = LOG_BUF_LEN;
static void emit_log_char(struct debug_log *debug_log, char c)
{
LOG_BUFF(debug_log->log_end) = c;
debug_log->log_end++;
if (debug_log->log_end - debug_log->log_start > log_buff_len)
debug_log->log_start = debug_log->log_end - log_buff_len;
}
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;
unsigned long flags;
if (!debug_log)
return 0;
spin_lock_irqsave(&debug_log->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(debug_log, *p);
spin_unlock_irqrestore(&debug_log->lock, flags);
wake_up(&debug_log->queue_wait);
return 0;
}
int debug_log(struct bat_priv *bat_priv, char *fmt, ...)
{
va_list args;
char tmp_log_buf[256];
va_start(args, fmt);
vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
fdebug_log(bat_priv->debug_log, "[%10u] %s",
(jiffies / HZ), tmp_log_buf);
va_end(args);
return 0;
}
static int log_open(struct inode *inode, struct file *file)
{
file->private_data = inode->i_private;
inc_module_count();
return 0;
}
static int log_release(struct inode *inode, struct file *file)
{
dec_module_count();
return 0;
}
static ssize_t log_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct bat_priv *bat_priv = file->private_data;
struct debug_log *debug_log = bat_priv->debug_log;
int error, i = 0;
char c;
unsigned long flags;
if ((file->f_flags & O_NONBLOCK) &&
!(debug_log->log_end - debug_log->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(debug_log->queue_wait,
(debug_log->log_start - debug_log->log_end));
if (error)
return error;
spin_lock_irqsave(&debug_log->lock, flags);
while ((!error) && (i < count) &&
(debug_log->log_start != debug_log->log_end)) {
c = LOG_BUFF(debug_log->log_start);
debug_log->log_start++;
spin_unlock_irqrestore(&debug_log->lock, flags);
error = __put_user(c, buf);
spin_lock_irqsave(&debug_log->lock, flags);
buf++;
i++;
}
spin_unlock_irqrestore(&debug_log->lock, flags);
if (!error)
return i;
return error;
}
static unsigned int log_poll(struct file *file, poll_table *wait)
{
struct bat_priv *bat_priv = file->private_data;
struct debug_log *debug_log = bat_priv->debug_log;
poll_wait(file, &debug_log->queue_wait, wait);
if (debug_log->log_end - debug_log->log_start)
return POLLIN | POLLRDNORM;
return 0;
}
static const struct file_operations log_fops = {
.open = log_open,
.release = log_release,
.read = log_read,
.poll = log_poll,
};
static int debug_log_setup(struct bat_priv *bat_priv)
{
struct dentry *d;
if (!bat_priv->debug_dir)
goto err;
bat_priv->debug_log = kzalloc(sizeof(struct debug_log), GFP_ATOMIC);
if (!bat_priv->debug_log)
goto err;
spin_lock_init(&bat_priv->debug_log->lock);
init_waitqueue_head(&bat_priv->debug_log->queue_wait);
d = debugfs_create_file("log", S_IFREG | S_IRUSR,
bat_priv->debug_dir, bat_priv, &log_fops);
if (d)
goto err;
return 0;
err:
return 1;
}
static void debug_log_cleanup(struct bat_priv *bat_priv)
{
kfree(bat_priv->debug_log);
bat_priv->debug_log = NULL;
}
#else /* CONFIG_BATMAN_ADV_DEBUG */
static int debug_log_setup(struct bat_priv *bat_priv)
{
bat_priv->debug_log = NULL;
return 0;
}
static void debug_log_cleanup(struct bat_priv *bat_priv)
{
return;
}
#endif
static int originators_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, orig_seq_print_text, net_dev);
}
static int transtable_global_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, hna_global_seq_print_text, net_dev);
}
static int transtable_local_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, hna_local_seq_print_text, net_dev);
}
static int vis_data_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, vis_seq_print_text, net_dev);
}
struct bat_debuginfo {
struct attribute attr;
const struct file_operations fops;
};
#define BAT_DEBUGINFO(_name, _mode, _open) \
struct bat_debuginfo bat_debuginfo_##_name = { \
.attr = { .name = __stringify(_name), \
.mode = _mode, }, \
.fops = { .owner = THIS_MODULE, \
.open = _open, \
.read = seq_read, \
.llseek = seq_lseek, \
.release = single_release, \
} \
};
static BAT_DEBUGINFO(originators, S_IRUGO, originators_open);
static BAT_DEBUGINFO(transtable_global, S_IRUGO, transtable_global_open);
static BAT_DEBUGINFO(transtable_local, S_IRUGO, transtable_local_open);
static BAT_DEBUGINFO(vis_data, S_IRUGO, vis_data_open);
static struct bat_debuginfo *mesh_debuginfos[] = {
&bat_debuginfo_originators,
&bat_debuginfo_transtable_global,
&bat_debuginfo_transtable_local,
&bat_debuginfo_vis_data,
NULL,
};
void debugfs_init(void)
{
bat_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL);
if (bat_debugfs == ERR_PTR(-ENODEV))
bat_debugfs = NULL;
}
void debugfs_destroy(void)
{
if (bat_debugfs) {
debugfs_remove_recursive(bat_debugfs);
bat_debugfs = NULL;
}
}
int debugfs_add_meshif(struct net_device *dev)
{
struct bat_priv *bat_priv = netdev_priv(dev);
struct bat_debuginfo **bat_debug;
struct dentry *file;
if (!bat_debugfs)
goto out;
bat_priv->debug_dir = debugfs_create_dir(dev->name, bat_debugfs);
if (!bat_priv->debug_dir)
goto out;
bat_socket_setup(bat_priv);
debug_log_setup(bat_priv);
for (bat_debug = mesh_debuginfos; *bat_debug; ++bat_debug) {
file = debugfs_create_file(((*bat_debug)->attr).name,
S_IFREG | ((*bat_debug)->attr).mode,
bat_priv->debug_dir,
dev, &(*bat_debug)->fops);
if (!file) {
bat_err(dev, "Can't add debugfs file: %s/%s\n",
dev->name, ((*bat_debug)->attr).name);
goto rem_attr;
}
}
return 0;
rem_attr:
debugfs_remove_recursive(bat_priv->debug_dir);
bat_priv->debug_dir = NULL;
out:
#ifdef CONFIG_DEBUG_FS
return -ENOMEM;
#else
return 0;
#endif /* CONFIG_DEBUG_FS */
}
void debugfs_del_meshif(struct net_device *dev)
{
struct bat_priv *bat_priv = netdev_priv(dev);
debug_log_cleanup(bat_priv);
if (bat_debugfs) {
debugfs_remove_recursive(bat_priv->debug_dir);
bat_priv->debug_dir = NULL;
}
}
/*
* Copyright (C) 2010 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* 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_DEBUGFS_H_
#define _NET_BATMAN_ADV_DEBUGFS_H_
#define DEBUGFS_BAT_SUBDIR "batman_adv"
void debugfs_init(void);
void debugfs_destroy(void);
int debugfs_add_meshif(struct net_device *dev);
void debugfs_del_meshif(struct net_device *dev);
#endif /* _NET_BATMAN_ADV_DEBUGFS_H_ */
...@@ -28,22 +28,6 @@ ...@@ -28,22 +28,6 @@
#define to_dev(obj) container_of(obj, struct device, kobj) #define to_dev(obj) container_of(obj, struct device, kobj)
struct bat_attribute {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
char *buf);
ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
char *buf, size_t count);
};
struct hardif_attribute {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
char *buf);
ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
char *buf, size_t count);
};
#define BAT_ATTR(_name, _mode, _show, _store) \ #define BAT_ATTR(_name, _mode, _show, _store) \
struct bat_attribute bat_attr_##_name = { \ struct bat_attribute bat_attr_##_name = { \
.attr = {.name = __stringify(_name), \ .attr = {.name = __stringify(_name), \
...@@ -52,34 +36,18 @@ struct bat_attribute bat_attr_##_name = { \ ...@@ -52,34 +36,18 @@ struct bat_attribute bat_attr_##_name = { \
.store = _store, \ .store = _store, \
}; };
#define BAT_BIN_ATTR(_name, _mode, _read, _write) \ static ssize_t show_aggr_ogms(struct kobject *kobj, struct attribute *attr,
struct bin_attribute bat_attr_##_name = { \
.attr = { .name = __stringify(_name), \
.mode = _mode, }, \
.read = _read, \
.write = _write, \
};
#define HARDIF_ATTR(_name, _mode, _show, _store) \
struct hardif_attribute hardif_attr_##_name = { \
.attr = {.name = __stringify(_name), \
.mode = _mode }, \
.show = _show, \
.store = _store, \
};
static ssize_t show_aggr_ogm(struct kobject *kobj, struct attribute *attr,
char *buff) char *buff)
{ {
struct device *dev = to_dev(kobj->parent); struct device *dev = to_dev(kobj->parent);
struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
int aggr_status = atomic_read(&bat_priv->aggregation_enabled); int aggr_status = atomic_read(&bat_priv->aggregation_enabled);
return sprintf(buff, "status: %s\ncommands: enable, disable, 0, 1\n", return sprintf(buff, "%s\n",
aggr_status == 0 ? "disabled" : "enabled"); aggr_status == 0 ? "disabled" : "enabled");
} }
static ssize_t store_aggr_ogm(struct kobject *kobj, struct attribute *attr, static ssize_t store_aggr_ogms(struct kobject *kobj, struct attribute *attr,
char *buff, size_t count) char *buff, size_t count)
{ {
struct device *dev = to_dev(kobj->parent); struct device *dev = to_dev(kobj->parent);
...@@ -99,23 +67,73 @@ static ssize_t store_aggr_ogm(struct kobject *kobj, struct attribute *attr, ...@@ -99,23 +67,73 @@ static ssize_t store_aggr_ogm(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n') if (buff[count - 1] == '\n')
buff[count - 1] = '\0'; buff[count - 1] = '\0';
printk(KERN_INFO "batman-adv:Invalid parameter for 'aggregate OGM' setting on mesh %s received: %s\n", bat_info(net_dev,
net_dev->name, buff); "Invalid parameter for 'aggregate OGM' setting"
"received: %s\n", buff);
return -EINVAL; return -EINVAL;
} }
if (atomic_read(&bat_priv->aggregation_enabled) == aggr_tmp) if (atomic_read(&bat_priv->aggregation_enabled) == aggr_tmp)
return count; return count;
printk(KERN_INFO "batman-adv:Changing aggregation from: %s to: %s on mesh: %s\n", bat_info(net_dev, "Changing aggregation from: %s to: %s\n",
atomic_read(&bat_priv->aggregation_enabled) == 1 ? atomic_read(&bat_priv->aggregation_enabled) == 1 ?
"enabled" : "disabled", aggr_tmp == 1 ? "enabled" : "disabled", "enabled" : "disabled", aggr_tmp == 1 ? "enabled" :
net_dev->name); "disabled");
atomic_set(&bat_priv->aggregation_enabled, (unsigned)aggr_tmp); atomic_set(&bat_priv->aggregation_enabled, (unsigned)aggr_tmp);
return count; return count;
} }
static ssize_t show_bond(struct kobject *kobj, struct attribute *attr,
char *buff)
{
struct device *dev = to_dev(kobj->parent);
struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
int bond_status = atomic_read(&bat_priv->bonding_enabled);
return sprintf(buff, "%s\n",
bond_status == 0 ? "disabled" : "enabled");
}
static ssize_t store_bond(struct kobject *kobj, struct attribute *attr,
char *buff, size_t count)
{
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);
struct bat_priv *bat_priv = netdev_priv(net_dev);
int bonding_enabled_tmp = -1;
if (((count == 2) && (buff[0] == '1')) ||
(strncmp(buff, "enable", 6) == 0))
bonding_enabled_tmp = 1;
if (((count == 2) && (buff[0] == '0')) ||
(strncmp(buff, "disable", 7) == 0))
bonding_enabled_tmp = 0;
if (bonding_enabled_tmp < 0) {
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
bat_err(net_dev,
"Invalid parameter for 'bonding' setting received: "
"%s\n", buff);
return -EINVAL;
}
if (atomic_read(&bat_priv->bonding_enabled) == bonding_enabled_tmp)
return count;
bat_info(net_dev, "Changing bonding from: %s to: %s\n",
atomic_read(&bat_priv->bonding_enabled) == 1 ?
"enabled" : "disabled",
bonding_enabled_tmp == 1 ? "enabled" : "disabled");
atomic_set(&bat_priv->bonding_enabled, (unsigned)bonding_enabled_tmp);
return count;
}
static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr, static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr,
char *buff) char *buff)
{ {
...@@ -123,10 +141,9 @@ static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr, ...@@ -123,10 +141,9 @@ static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr,
struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
int vis_mode = atomic_read(&bat_priv->vis_mode); int vis_mode = atomic_read(&bat_priv->vis_mode);
return sprintf(buff, "status: %s\ncommands: client, server, %d, %d\n", return sprintf(buff, "%s\n",
vis_mode == VIS_TYPE_CLIENT_UPDATE ? vis_mode == VIS_TYPE_CLIENT_UPDATE ?
"client" : "server", "client" : "server");
VIS_TYPE_SERVER_SYNC, VIS_TYPE_CLIENT_UPDATE);
} }
static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
...@@ -141,7 +158,8 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, ...@@ -141,7 +158,8 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
ret = strict_strtoul(buff, 10, &val); ret = strict_strtoul(buff, 10, &val);
if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) || if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) ||
(strncmp(buff, "client", 6) == 0)) (strncmp(buff, "client", 6) == 0) ||
(strncmp(buff, "off", 3) == 0))
vis_mode_tmp = VIS_TYPE_CLIENT_UPDATE; vis_mode_tmp = VIS_TYPE_CLIENT_UPDATE;
if (((count == 2) && (!ret) && (val == VIS_TYPE_SERVER_SYNC)) || if (((count == 2) && (!ret) && (val == VIS_TYPE_SERVER_SYNC)) ||
...@@ -152,18 +170,19 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, ...@@ -152,18 +170,19 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n') if (buff[count - 1] == '\n')
buff[count - 1] = '\0'; buff[count - 1] = '\0';
printk(KERN_INFO "batman-adv:Invalid parameter for 'vis mode' setting on mesh %s received: %s\n", bat_info(net_dev,
net_dev->name, buff); "Invalid parameter for 'vis mode' setting received: "
"%s\n", buff);
return -EINVAL; return -EINVAL;
} }
if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp) if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
return count; return count;
printk(KERN_INFO "batman-adv:Changing vis mode from: %s to: %s on mesh: %s\n", bat_info(net_dev, "Changing vis mode from: %s to: %s\n",
atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ? atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
"client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ? "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ?
"client" : "server", net_dev->name); "client" : "server");
atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp); atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp);
return count; return count;
...@@ -175,7 +194,7 @@ static ssize_t show_orig_interval(struct kobject *kobj, struct attribute *attr, ...@@ -175,7 +194,7 @@ static ssize_t show_orig_interval(struct kobject *kobj, struct attribute *attr,
struct device *dev = to_dev(kobj->parent); struct device *dev = to_dev(kobj->parent);
struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
return sprintf(buff, "status: %i\n", return sprintf(buff, "%i\n",
atomic_read(&bat_priv->orig_interval)); atomic_read(&bat_priv->orig_interval));
} }
...@@ -190,91 +209,87 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr, ...@@ -190,91 +209,87 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr,
ret = strict_strtoul(buff, 10, &orig_interval_tmp); ret = strict_strtoul(buff, 10, &orig_interval_tmp);
if (ret) { if (ret) {
printk(KERN_INFO "batman-adv:Invalid parameter for 'orig_interval' setting on mesh %s received: %s\n", bat_info(net_dev, "Invalid parameter for 'orig_interval' "
net_dev->name, buff); "setting received: %s\n", buff);
return -EINVAL; return -EINVAL;
} }
if (orig_interval_tmp <= JITTER * 2) { if (orig_interval_tmp < JITTER * 2) {
printk(KERN_INFO "batman-adv:New originator interval too small: %li (min: %i)\n", bat_info(net_dev, "New originator interval too small: %li "
orig_interval_tmp, JITTER * 2); "(min: %i)\n", orig_interval_tmp, JITTER * 2);
return -EINVAL; return -EINVAL;
} }
if (atomic_read(&bat_priv->orig_interval) == orig_interval_tmp) if (atomic_read(&bat_priv->orig_interval) == orig_interval_tmp)
return count; return count;
printk(KERN_INFO "batman-adv:Changing originator interval from: %i to: %li on mesh: %s\n", bat_info(net_dev, "Changing originator interval from: %i to: %li\n",
atomic_read(&bat_priv->orig_interval), atomic_read(&bat_priv->orig_interval),
orig_interval_tmp, net_dev->name); orig_interval_tmp);
atomic_set(&bat_priv->orig_interval, orig_interval_tmp); atomic_set(&bat_priv->orig_interval, orig_interval_tmp);
return count; return count;
} }
static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR, #ifdef CONFIG_BATMAN_ADV_DEBUG
show_aggr_ogm, store_aggr_ogm); static ssize_t show_log_level(struct kobject *kobj, struct attribute *attr,
static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); char *buff)
static BAT_ATTR(orig_interval, S_IRUGO | S_IWUSR,
show_orig_interval, store_orig_interval);
static struct bat_attribute *mesh_attrs[] = {
&bat_attr_aggregate_ogm,
&bat_attr_vis_mode,
&bat_attr_orig_interval,
NULL,
};
static ssize_t transtable_local_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buff, loff_t off, size_t count)
{ {
struct device *dev = to_dev(kobj->parent); struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev); struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
int log_level = atomic_read(&bat_priv->log_level);
return hna_local_fill_buffer_text(net_dev, buff, count, off); return sprintf(buff, "%d\n", log_level);
} }
static ssize_t transtable_global_read(struct file *filp, struct kobject *kobj, static ssize_t store_log_level(struct kobject *kobj, struct attribute *attr,
struct bin_attribute *bin_attr, char *buff, size_t count)
char *buff, loff_t off, size_t count)
{ {
struct device *dev = to_dev(kobj->parent); struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev); struct net_device *net_dev = to_net_dev(dev);
struct bat_priv *bat_priv = netdev_priv(net_dev);
unsigned long log_level_tmp;
int ret;
return hna_global_fill_buffer_text(net_dev, buff, count, off); ret = strict_strtoul(buff, 10, &log_level_tmp);
} if (ret) {
bat_info(net_dev, "Invalid parameter for 'log_level' "
static ssize_t originators_read(struct file *filp, struct kobject *kobj, "setting received: %s\n", buff);
struct bin_attribute *bin_attr, return -EINVAL;
char *buff, loff_t off, size_t count) }
{
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);
return orig_fill_buffer_text(net_dev, buff, count, off); if (log_level_tmp > 3) {
} bat_info(net_dev, "New log level too big: %li "
"(max: %i)\n", log_level_tmp, 3);
return -EINVAL;
}
static ssize_t vis_data_read(struct file *filp, struct kobject *kobj, if (atomic_read(&bat_priv->log_level) == log_level_tmp)
struct bin_attribute *bin_attr, return count;
char *buff, loff_t off, size_t count)
{
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);
return vis_fill_buffer_text(net_dev, buff, count, off); atomic_set(&bat_priv->log_level, (unsigned)log_level_tmp);
return count;
} }
#endif
static BAT_BIN_ATTR(transtable_local, S_IRUGO, transtable_local_read, NULL); static BAT_ATTR(aggregated_ogms, S_IRUGO | S_IWUSR,
static BAT_BIN_ATTR(transtable_global, S_IRUGO, transtable_global_read, NULL); show_aggr_ogms, store_aggr_ogms);
static BAT_BIN_ATTR(originators, S_IRUGO, originators_read, NULL); static BAT_ATTR(bonding, S_IRUGO | S_IWUSR, show_bond, store_bond);
static BAT_BIN_ATTR(vis_data, S_IRUGO, vis_data_read, NULL); static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
static BAT_ATTR(orig_interval, S_IRUGO | S_IWUSR,
show_orig_interval, store_orig_interval);
#ifdef CONFIG_BATMAN_ADV_DEBUG
static BAT_ATTR(log_level, S_IRUGO | S_IWUSR, show_log_level, store_log_level);
#endif
static struct bin_attribute *mesh_bin_attrs[] = { static struct bat_attribute *mesh_attrs[] = {
&bat_attr_transtable_local, &bat_attr_aggregated_ogms,
&bat_attr_transtable_global, &bat_attr_bonding,
&bat_attr_originators, &bat_attr_vis_mode,
&bat_attr_vis_data, &bat_attr_orig_interval,
#ifdef CONFIG_BATMAN_ADV_DEBUG
&bat_attr_log_level,
#endif
NULL, NULL,
}; };
...@@ -283,22 +298,24 @@ int sysfs_add_meshif(struct net_device *dev) ...@@ -283,22 +298,24 @@ int sysfs_add_meshif(struct net_device *dev)
struct kobject *batif_kobject = &dev->dev.kobj; struct kobject *batif_kobject = &dev->dev.kobj;
struct bat_priv *bat_priv = netdev_priv(dev); struct bat_priv *bat_priv = netdev_priv(dev);
struct bat_attribute **bat_attr; struct bat_attribute **bat_attr;
struct bin_attribute **bin_attr;
int err; int err;
/* FIXME: should be done in the general mesh setup /* FIXME: should be done in the general mesh setup
routine as soon as we have it */ routine as soon as we have it */
atomic_set(&bat_priv->aggregation_enabled, 1); atomic_set(&bat_priv->aggregation_enabled, 1);
atomic_set(&bat_priv->bonding_enabled, 0);
atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE); atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE);
atomic_set(&bat_priv->orig_interval, 1000); atomic_set(&bat_priv->orig_interval, 1000);
atomic_set(&bat_priv->log_level, 0);
bat_priv->primary_if = NULL; bat_priv->primary_if = NULL;
bat_priv->num_ifaces = 0; bat_priv->num_ifaces = 0;
bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR, bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR,
batif_kobject); batif_kobject);
if (!bat_priv->mesh_obj) { if (!bat_priv->mesh_obj) {
printk(KERN_ERR "batman-adv:Can't add sysfs directory: %s/%s\n", bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
dev->name, SYSFS_IF_MESH_SUBDIR); SYSFS_IF_MESH_SUBDIR);
goto out; goto out;
} }
...@@ -306,28 +323,15 @@ int sysfs_add_meshif(struct net_device *dev) ...@@ -306,28 +323,15 @@ int sysfs_add_meshif(struct net_device *dev)
err = sysfs_create_file(bat_priv->mesh_obj, err = sysfs_create_file(bat_priv->mesh_obj,
&((*bat_attr)->attr)); &((*bat_attr)->attr));
if (err) { if (err) {
printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n", bat_err(dev, "Can't add sysfs file: %s/%s/%s\n",
dev->name, SYSFS_IF_MESH_SUBDIR, dev->name, SYSFS_IF_MESH_SUBDIR,
((*bat_attr)->attr).name); ((*bat_attr)->attr).name);
goto rem_attr; goto rem_attr;
} }
} }
for (bin_attr = mesh_bin_attrs; *bin_attr; ++bin_attr) {
err = sysfs_create_bin_file(bat_priv->mesh_obj, (*bin_attr));
if (err) {
printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n",
dev->name, SYSFS_IF_MESH_SUBDIR,
((*bin_attr)->attr).name);
goto rem_bin_attr;
}
}
return 0; return 0;
rem_bin_attr:
for (bin_attr = mesh_bin_attrs; *bin_attr; ++bin_attr)
sysfs_remove_bin_file(bat_priv->mesh_obj, (*bin_attr));
rem_attr: rem_attr:
for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr) for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr)
sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr));
...@@ -342,10 +346,6 @@ void sysfs_del_meshif(struct net_device *dev) ...@@ -342,10 +346,6 @@ void sysfs_del_meshif(struct net_device *dev)
{ {
struct bat_priv *bat_priv = netdev_priv(dev); struct bat_priv *bat_priv = netdev_priv(dev);
struct bat_attribute **bat_attr; struct bat_attribute **bat_attr;
struct bin_attribute **bin_attr;
for (bin_attr = mesh_bin_attrs; *bin_attr; ++bin_attr)
sysfs_remove_bin_file(bat_priv->mesh_obj, (*bin_attr));
for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr) for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr)
sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr));
...@@ -364,7 +364,7 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr, ...@@ -364,7 +364,7 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr,
if (!batman_if) if (!batman_if)
return 0; return 0;
return sprintf(buff, "status: %s\ncommands: none, bat0\n", return sprintf(buff, "%s\n",
batman_if->if_status == IF_NOT_IN_USE ? batman_if->if_status == IF_NOT_IN_USE ?
"none" : "bat0"); "none" : "bat0");
} }
...@@ -390,8 +390,8 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr, ...@@ -390,8 +390,8 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n') if (buff[count - 1] == '\n')
buff[count - 1] = '\0'; buff[count - 1] = '\0';
printk(KERN_ERR "batman-adv:Invalid parameter for 'mesh_iface' setting received: %s\n", pr_err("Invalid parameter for 'mesh_iface' setting received: "
buff); "%s\n", buff);
return -EINVAL; return -EINVAL;
} }
...@@ -433,37 +433,37 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr, ...@@ -433,37 +433,37 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr,
} }
} }
static HARDIF_ATTR(mesh_iface, S_IRUGO | S_IWUSR, static BAT_ATTR(mesh_iface, S_IRUGO | S_IWUSR,
show_mesh_iface, store_mesh_iface); show_mesh_iface, store_mesh_iface);
static HARDIF_ATTR(iface_status, S_IRUGO, show_iface_status, NULL); static BAT_ATTR(iface_status, S_IRUGO, show_iface_status, NULL);
static struct hardif_attribute *batman_attrs[] = { static struct bat_attribute *batman_attrs[] = {
&hardif_attr_mesh_iface, &bat_attr_mesh_iface,
&hardif_attr_iface_status, &bat_attr_iface_status,
NULL, NULL,
}; };
int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
{ {
struct kobject *hardif_kobject = &dev->dev.kobj; struct kobject *hardif_kobject = &dev->dev.kobj;
struct hardif_attribute **hardif_attr; struct bat_attribute **bat_attr;
int err; int err;
*hardif_obj = kobject_create_and_add(SYSFS_IF_BAT_SUBDIR, *hardif_obj = kobject_create_and_add(SYSFS_IF_BAT_SUBDIR,
hardif_kobject); hardif_kobject);
if (!*hardif_obj) { if (!*hardif_obj) {
printk(KERN_ERR "batman-adv:Can't add sysfs directory: %s/%s\n", bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
dev->name, SYSFS_IF_BAT_SUBDIR); SYSFS_IF_BAT_SUBDIR);
goto out; goto out;
} }
for (hardif_attr = batman_attrs; *hardif_attr; ++hardif_attr) { for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) {
err = sysfs_create_file(*hardif_obj, &((*hardif_attr)->attr)); err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr));
if (err) { if (err) {
printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n", bat_err(dev, "Can't add sysfs file: %s/%s/%s\n",
dev->name, SYSFS_IF_BAT_SUBDIR, dev->name, SYSFS_IF_BAT_SUBDIR,
((*hardif_attr)->attr).name); ((*bat_attr)->attr).name);
goto rem_attr; goto rem_attr;
} }
} }
...@@ -471,8 +471,8 @@ int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) ...@@ -471,8 +471,8 @@ int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
return 0; return 0;
rem_attr: rem_attr:
for (hardif_attr = batman_attrs; *hardif_attr; ++hardif_attr) for (bat_attr = batman_attrs; *bat_attr; ++bat_attr)
sysfs_remove_file(*hardif_obj, &((*hardif_attr)->attr)); sysfs_remove_file(*hardif_obj, &((*bat_attr)->attr));
out: out:
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -20,10 +20,23 @@ ...@@ -20,10 +20,23 @@
*/ */
#ifndef _NET_BATMAN_ADV_SYSFS_H_
#define _NET_BATMAN_ADV_SYSFS_H_
#define SYSFS_IF_MESH_SUBDIR "mesh" #define SYSFS_IF_MESH_SUBDIR "mesh"
#define SYSFS_IF_BAT_SUBDIR "batman_adv" #define SYSFS_IF_BAT_SUBDIR "batman_adv"
struct bat_attribute {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
char *buf);
ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
char *buf, size_t count);
};
int sysfs_add_meshif(struct net_device *dev); int sysfs_add_meshif(struct net_device *dev);
void sysfs_del_meshif(struct net_device *dev); void sysfs_del_meshif(struct net_device *dev);
int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev); int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev);
void sysfs_del_hardif(struct kobject **hardif_obj); void sysfs_del_hardif(struct kobject **hardif_obj);
#endif /* _NET_BATMAN_ADV_SYSFS_H_ */
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
/* returns true if the corresponding bit in the given seq_bits indicates true /* returns true if the corresponding bit in the given seq_bits indicates true
* and curr_seqno is within range of last_seqno */ * and curr_seqno is within range of last_seqno */
uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint16_t last_seqno, uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno,
uint16_t curr_seqno) uint32_t curr_seqno)
{ {
int16_t diff, word_offset, word_num; int32_t diff, word_offset, word_num;
diff = last_seqno - curr_seqno; diff = last_seqno - curr_seqno;
if (diff < 0 || diff >= TQ_LOCAL_WINDOW_SIZE) { if (diff < 0 || diff >= TQ_LOCAL_WINDOW_SIZE) {
...@@ -63,7 +63,7 @@ void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n) ...@@ -63,7 +63,7 @@ void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n)
} }
/* shift the packet array by n places. */ /* shift the packet array by n places. */
void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n) static void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n)
{ {
int32_t word_offset, word_num; int32_t word_offset, word_num;
int32_t i; int32_t i;
...@@ -125,9 +125,12 @@ static void bit_reset_window(TYPE_OF_WORD *seq_bits) ...@@ -125,9 +125,12 @@ static void bit_reset_window(TYPE_OF_WORD *seq_bits)
* 1 if the window was moved (either new or very old) * 1 if the window was moved (either new or very old)
* 0 if the window was not moved/shifted. * 0 if the window was not moved/shifted.
*/ */
char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff, char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff,
int8_t set_mark) int8_t set_mark)
{ {
/* FIXME: each orig_node->batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
/* sequence number is slightly older. We already got a sequence number /* sequence number is slightly older. We already got a sequence number
* higher than this one, so we just mark it. */ * higher than this one, so we just mark it. */
...@@ -152,7 +155,7 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff, ...@@ -152,7 +155,7 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff,
if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE)
|| (seq_num_diff < EXPECTED_SEQNO_RANGE)) { || (seq_num_diff < EXPECTED_SEQNO_RANGE)) {
bat_dbg(DBG_BATMAN, bat_dbg(DBG_BATMAN, bat_priv,
"We missed a lot of packets (%i) !\n", "We missed a lot of packets (%i) !\n",
seq_num_diff - 1); seq_num_diff - 1);
bit_reset_window(seq_bits); bit_reset_window(seq_bits);
...@@ -169,7 +172,7 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff, ...@@ -169,7 +172,7 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff,
if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE)
|| (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { || (seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
bat_dbg(DBG_BATMAN, bat_dbg(DBG_BATMAN, bat_priv,
"Other host probably restarted!\n"); "Other host probably restarted!\n");
bit_reset_window(seq_bits); bit_reset_window(seq_bits);
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_BITARRAY_H_
#define _NET_BATMAN_ADV_BITARRAY_H_
/* you should choose something big, if you don't want to waste cpu */ /* you should choose something big, if you don't want to waste cpu */
#define TYPE_OF_WORD unsigned long #define TYPE_OF_WORD unsigned long
...@@ -26,20 +28,19 @@ ...@@ -26,20 +28,19 @@
/* returns true if the corresponding bit in the given seq_bits indicates true /* returns true if the corresponding bit in the given seq_bits indicates true
* and curr_seqno is within range of last_seqno */ * and curr_seqno is within range of last_seqno */
uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint16_t last_seqno, uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno,
uint16_t curr_seqno); uint32_t curr_seqno);
/* turn corresponding bit on, so we can remember that we got the packet */ /* turn corresponding bit on, so we can remember that we got the packet */
void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n); void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n);
/* shift the packet array by n places. */
void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n);
/* receive and process one packet, returns 1 if received seq_num is considered /* receive and process one packet, returns 1 if received seq_num is considered
* new, 0 if old */ * new, 0 if old */
char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff, char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff,
int8_t set_mark); int8_t set_mark);
/* count the hamming weight, how many good packets did we receive? */ /* count the hamming weight, how many good packets did we receive? */
int bit_packet_count(TYPE_OF_WORD *seq_bits); int bit_packet_count(TYPE_OF_WORD *seq_bits);
#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "hash.h" #include "hash.h"
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/netfilter_bridge.h>
#define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y))
...@@ -108,7 +109,7 @@ static void set_primary_if(struct bat_priv *bat_priv, ...@@ -108,7 +109,7 @@ static void set_primary_if(struct bat_priv *bat_priv,
set_main_if_addr(batman_if->net_dev->dev_addr); set_main_if_addr(batman_if->net_dev->dev_addr);
batman_packet = (struct batman_packet *)(batman_if->packet_buff); batman_packet = (struct batman_packet *)(batman_if->packet_buff);
batman_packet->flags = 0; batman_packet->flags = PRIMARIES_FIRST_HOP;
batman_packet->ttl = TTL; batman_packet->ttl = TTL;
/*** /***
...@@ -149,12 +150,10 @@ static void check_known_mac_addr(uint8_t *addr) ...@@ -149,12 +150,10 @@ static void check_known_mac_addr(uint8_t *addr)
if (!compare_orig(batman_if->net_dev->dev_addr, addr)) if (!compare_orig(batman_if->net_dev->dev_addr, addr))
continue; continue;
printk(KERN_WARNING "batman-adv:" pr_warning("The newly added mac address (%pM) already exists "
"The newly added mac address (%pM) already exists on: %s\n", "on: %s\n", addr, batman_if->dev);
addr, batman_if->dev); pr_warning("It is strongly recommended to keep mac addresses "
printk(KERN_WARNING "batman-adv:" "unique to avoid problems!\n");
"It is strongly recommended to keep mac addresses unique"
"to avoid problems!\n");
} }
rcu_read_unlock(); rcu_read_unlock();
} }
...@@ -188,7 +187,8 @@ void update_min_mtu(void) ...@@ -188,7 +187,8 @@ void update_min_mtu(void)
soft_device->mtu = min_mtu; soft_device->mtu = min_mtu;
} }
static void hardif_activate_interface(struct bat_priv *bat_priv, static void hardif_activate_interface(struct net_device *net_dev,
struct bat_priv *bat_priv,
struct batman_if *batman_if) struct batman_if *batman_if)
{ {
if (batman_if->if_status != IF_INACTIVE) if (batman_if->if_status != IF_INACTIVE)
...@@ -206,8 +206,7 @@ static void hardif_activate_interface(struct bat_priv *bat_priv, ...@@ -206,8 +206,7 @@ static void hardif_activate_interface(struct bat_priv *bat_priv,
if (!bat_priv->primary_if) if (!bat_priv->primary_if)
set_primary_if(bat_priv, batman_if); set_primary_if(bat_priv, batman_if);
printk(KERN_INFO "batman-adv:Interface activated: %s\n", bat_info(net_dev, "Interface activated: %s\n", batman_if->dev);
batman_if->dev);
if (atomic_read(&module_state) == MODULE_INACTIVE) if (atomic_read(&module_state) == MODULE_INACTIVE)
activate_module(); activate_module();
...@@ -216,7 +215,8 @@ static void hardif_activate_interface(struct bat_priv *bat_priv, ...@@ -216,7 +215,8 @@ static void hardif_activate_interface(struct bat_priv *bat_priv,
return; return;
} }
static void hardif_deactivate_interface(struct batman_if *batman_if) static void hardif_deactivate_interface(struct net_device *net_dev,
struct batman_if *batman_if)
{ {
if ((batman_if->if_status != IF_ACTIVE) && if ((batman_if->if_status != IF_ACTIVE) &&
(batman_if->if_status != IF_TO_BE_ACTIVATED)) (batman_if->if_status != IF_TO_BE_ACTIVATED))
...@@ -226,8 +226,7 @@ static void hardif_deactivate_interface(struct batman_if *batman_if) ...@@ -226,8 +226,7 @@ static void hardif_deactivate_interface(struct batman_if *batman_if)
batman_if->if_status = IF_INACTIVE; batman_if->if_status = IF_INACTIVE;
printk(KERN_INFO "batman-adv:Interface deactivated: %s\n", bat_info(net_dev, "Interface deactivated: %s\n", batman_if->dev);
batman_if->dev);
update_min_mtu(); update_min_mtu();
} }
...@@ -245,9 +244,8 @@ int hardif_enable_interface(struct batman_if *batman_if) ...@@ -245,9 +244,8 @@ int hardif_enable_interface(struct batman_if *batman_if)
batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC); batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);
if (!batman_if->packet_buff) { if (!batman_if->packet_buff) {
printk(KERN_ERR "batman-adv:" bat_err(soft_device, "Can't add interface packet (%s): "
"Can't add interface packet (%s): out of memory\n", "out of memory\n", batman_if->dev);
batman_if->dev);
goto err; goto err;
} }
...@@ -265,15 +263,14 @@ int hardif_enable_interface(struct batman_if *batman_if) ...@@ -265,15 +263,14 @@ int hardif_enable_interface(struct batman_if *batman_if)
orig_hash_add_if(batman_if, bat_priv->num_ifaces); orig_hash_add_if(batman_if, bat_priv->num_ifaces);
atomic_set(&batman_if->seqno, 1); atomic_set(&batman_if->seqno, 1);
printk(KERN_INFO "batman-adv:Adding interface: %s\n", batman_if->dev); bat_info(soft_device, "Adding interface: %s\n", batman_if->dev);
if (hardif_is_iface_up(batman_if)) if (hardif_is_iface_up(batman_if))
hardif_activate_interface(bat_priv, batman_if); hardif_activate_interface(soft_device, bat_priv, batman_if);
else else
printk(KERN_ERR "batman-adv:" bat_err(soft_device, "Not using interface %s "
"Not using interface %s " "(retrying later): interface not active\n",
"(retrying later): interface not active\n", batman_if->dev);
batman_if->dev);
/* begin scheduling originator messages on that interface */ /* begin scheduling originator messages on that interface */
schedule_own_packet(batman_if); schedule_own_packet(batman_if);
...@@ -291,12 +288,12 @@ void hardif_disable_interface(struct batman_if *batman_if) ...@@ -291,12 +288,12 @@ void hardif_disable_interface(struct batman_if *batman_if)
struct bat_priv *bat_priv = netdev_priv(soft_device); struct bat_priv *bat_priv = netdev_priv(soft_device);
if (batman_if->if_status == IF_ACTIVE) if (batman_if->if_status == IF_ACTIVE)
hardif_deactivate_interface(batman_if); hardif_deactivate_interface(soft_device, batman_if);
if (batman_if->if_status != IF_INACTIVE) if (batman_if->if_status != IF_INACTIVE)
return; return;
printk(KERN_INFO "batman-adv:Removing interface: %s\n", batman_if->dev); bat_info(soft_device, "Removing interface: %s\n", batman_if->dev);
bat_priv->num_ifaces--; bat_priv->num_ifaces--;
orig_hash_del_if(batman_if, bat_priv->num_ifaces); orig_hash_del_if(batman_if, bat_priv->num_ifaces);
...@@ -323,8 +320,7 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev) ...@@ -323,8 +320,7 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC); batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
if (!batman_if) { if (!batman_if) {
printk(KERN_ERR "batman-adv:" pr_err("Can't add interface (%s): out of memory\n",
"Can't add interface (%s): out of memory\n",
net_dev->name); net_dev->name);
goto out; goto out;
} }
...@@ -407,11 +403,11 @@ static int hard_if_event(struct notifier_block *this, ...@@ -407,11 +403,11 @@ static int hard_if_event(struct notifier_block *this,
case NETDEV_REGISTER: case NETDEV_REGISTER:
break; break;
case NETDEV_UP: case NETDEV_UP:
hardif_activate_interface(bat_priv, batman_if); hardif_activate_interface(soft_device, bat_priv, batman_if);
break; break;
case NETDEV_GOING_DOWN: case NETDEV_GOING_DOWN:
case NETDEV_DOWN: case NETDEV_DOWN:
hardif_deactivate_interface(batman_if); hardif_deactivate_interface(soft_device, batman_if);
break; break;
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
hardif_remove_interface(batman_if); hardif_remove_interface(batman_if);
...@@ -432,11 +428,18 @@ static int hard_if_event(struct notifier_block *this, ...@@ -432,11 +428,18 @@ static int hard_if_event(struct notifier_block *this,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
static int batman_skb_recv_finish(struct sk_buff *skb)
{
return NF_ACCEPT;
}
/* receive a packet with the batman ethertype coming on a hard /* receive a packet with the batman ethertype coming on a hard
* interface */ * interface */
int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct net_device *orig_dev) struct packet_type *ptype, struct net_device *orig_dev)
{ {
/* FIXME: each orig_node->batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct batman_packet *batman_packet; struct batman_packet *batman_packet;
struct batman_if *batman_if; struct batman_if *batman_if;
struct net_device_stats *stats; struct net_device_stats *stats;
...@@ -452,6 +455,13 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -452,6 +455,13 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
if (atomic_read(&module_state) != MODULE_ACTIVE) if (atomic_read(&module_state) != MODULE_ACTIVE)
goto err_free; goto err_free;
/* if netfilter/ebtables wants to block incoming batman
* packets then give them a chance to do so here */
ret = NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_IN, skb, dev, NULL,
batman_skb_recv_finish);
if (ret != 1)
goto err_out;
/* packet should hold at least type and version */ /* packet should hold at least type and version */
if (unlikely(skb_headlen(skb) < 2)) if (unlikely(skb_headlen(skb) < 2))
goto err_free; goto err_free;
...@@ -478,7 +488,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -478,7 +488,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
batman_packet = (struct batman_packet *)skb->data; batman_packet = (struct batman_packet *)skb->data;
if (batman_packet->version != COMPAT_VERSION) { if (batman_packet->version != COMPAT_VERSION) {
bat_dbg(DBG_BATMAN, bat_dbg(DBG_BATMAN, bat_priv,
"Drop packet: incompatible batman version (%i)\n", "Drop packet: incompatible batman version (%i)\n",
batman_packet->version); batman_packet->version);
goto err_free; goto err_free;
...@@ -500,7 +510,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -500,7 +510,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
/* unicast packet */ /* unicast packet */
case BAT_UNICAST: case BAT_UNICAST:
ret = recv_unicast_packet(skb); ret = recv_unicast_packet(skb, batman_if);
break; break;
/* broadcast packet */ /* broadcast packet */
...@@ -531,7 +541,6 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -531,7 +541,6 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
return NET_RX_DROP; return NET_RX_DROP;
} }
struct notifier_block hard_if_notifier = { struct notifier_block hard_if_notifier = {
.notifier_call = hard_if_event, .notifier_call = hard_if_event,
}; };
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
#define _NET_BATMAN_ADV_HARD_INTERFACE_H_
#define IF_NOT_IN_USE 0 #define IF_NOT_IN_USE 0
#define IF_TO_BE_REMOVED 1 #define IF_TO_BE_REMOVED 1
#define IF_INACTIVE 2 #define IF_INACTIVE 2
...@@ -38,3 +41,5 @@ int batman_skb_recv(struct sk_buff *skb, ...@@ -38,3 +41,5 @@ int batman_skb_recv(struct sk_buff *skb,
struct net_device *orig_dev); struct net_device *orig_dev);
int hardif_min_mtu(void); int hardif_min_mtu(void);
void update_min_mtu(void); void update_min_mtu(void);
#endif /* _NET_BATMAN_ADV_HARD_INTERFACE_H_ */
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "hash.h" #include "hash.h"
/* clears the hash */ /* clears the hash */
void hash_init(struct hashtable_t *hash) static void hash_init(struct hashtable_t *hash)
{ {
int i; int i;
......
...@@ -19,8 +19,9 @@ ...@@ -19,8 +19,9 @@
* *
*/ */
#ifndef _BATMAN_HASH_H #ifndef _NET_BATMAN_ADV_HASH_H_
#define _BATMAN_HASH_H #define _NET_BATMAN_ADV_HASH_H_
#define HASHIT(name) struct hash_it_t name = { \ #define HASHIT(name) struct hash_it_t name = { \
.index = -1, .bucket = NULL, \ .index = -1, .bucket = NULL, \
.prev_bucket = NULL, \ .prev_bucket = NULL, \
...@@ -56,9 +57,6 @@ struct hashtable_t { ...@@ -56,9 +57,6 @@ struct hashtable_t {
* argument and the size the second */ * argument and the size the second */
}; };
/* clears the hash */
void hash_init(struct hashtable_t *hash);
/* allocates and clears the hash */ /* allocates and clears the hash */
struct hashtable_t *hash_new(int size, hashdata_compare_cb compare, struct hashtable_t *hash_new(int size, hashdata_compare_cb compare,
hashdata_choose_cb choose); hashdata_choose_cb choose);
...@@ -99,6 +97,4 @@ struct hashtable_t *hash_resize(struct hashtable_t *hash, int size); ...@@ -99,6 +97,4 @@ struct hashtable_t *hash_resize(struct hashtable_t *hash, int size);
struct hash_it_t *hash_iterate(struct hashtable_t *hash, struct hash_it_t *hash_iterate(struct hashtable_t *hash,
struct hash_it_t *iter_in); struct hash_it_t *iter_in);
/* print the hash table for debugging */ #endif /* _NET_BATMAN_ADV_HASH_H_ */
void hash_debug(struct hashtable_t *hash);
#endif
...@@ -19,154 +19,100 @@ ...@@ -19,154 +19,100 @@
* *
*/ */
#include <linux/device.h>
#include <linux/slab.h>
#include "main.h" #include "main.h"
#include "device.h" #include <linux/debugfs.h>
#include <linux/slab.h>
#include "icmp_socket.h"
#include "send.h" #include "send.h"
#include "types.h" #include "types.h"
#include "hash.h" #include "hash.h"
#include "hard-interface.h" #include "hard-interface.h"
static struct class *batman_class;
static int Major; /* Major number assigned to our device driver */
static const struct file_operations fops = {
.open = bat_device_open,
.release = bat_device_release,
.read = bat_device_read,
.write = bat_device_write,
.poll = bat_device_poll,
};
static struct device_client *device_client_hash[256];
void bat_device_init(void)
{
memset(device_client_hash, 0, sizeof(device_client_hash));
}
int bat_device_setup(void)
{
int tmp_major;
if (Major)
return 1;
/* register our device - kernel assigns a free major number */
tmp_major = register_chrdev(0, DRIVER_DEVICE, &fops);
if (tmp_major < 0) {
printk(KERN_ERR "batman-adv:"
"Registering the character device failed with %d\n",
tmp_major);
return 0;
}
batman_class = class_create(THIS_MODULE, "batman-adv"); static struct socket_client *socket_client_hash[256];
if (IS_ERR(batman_class)) { static void bat_socket_add_packet(struct socket_client *socket_client,
printk(KERN_ERR "batman-adv:" struct icmp_packet_rr *icmp_packet,
"Could not register class 'batman-adv'\n"); size_t icmp_len);
return 0;
}
device_create(batman_class, NULL, MKDEV(tmp_major, 0), NULL,
"batman-adv");
Major = tmp_major;
return 1;
}
void bat_device_destroy(void) void bat_socket_init(void)
{ {
if (!Major) memset(socket_client_hash, 0, sizeof(socket_client_hash));
return;
device_destroy(batman_class, MKDEV(Major, 0));
class_destroy(batman_class);
/* Unregister the device */
unregister_chrdev(Major, DRIVER_DEVICE);
Major = 0;
} }
int bat_device_open(struct inode *inode, struct file *file) static int bat_socket_open(struct inode *inode, struct file *file)
{ {
unsigned int i; unsigned int i;
struct device_client *device_client; struct socket_client *socket_client;
device_client = kmalloc(sizeof(struct device_client), GFP_KERNEL); socket_client = kmalloc(sizeof(struct socket_client), GFP_KERNEL);
if (!device_client) if (!socket_client)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < ARRAY_SIZE(device_client_hash); i++) { for (i = 0; i < ARRAY_SIZE(socket_client_hash); i++) {
if (!device_client_hash[i]) { if (!socket_client_hash[i]) {
device_client_hash[i] = device_client; socket_client_hash[i] = socket_client;
break; break;
} }
} }
if (i == ARRAY_SIZE(device_client_hash)) { if (i == ARRAY_SIZE(socket_client_hash)) {
printk(KERN_ERR "batman-adv:" pr_err("Error - can't add another packet client: "
"Error - can't add another packet client: "
"maximum number of clients reached\n"); "maximum number of clients reached\n");
kfree(device_client); kfree(socket_client);
return -EXFULL; return -EXFULL;
} }
INIT_LIST_HEAD(&device_client->queue_list); INIT_LIST_HEAD(&socket_client->queue_list);
device_client->queue_len = 0; socket_client->queue_len = 0;
device_client->index = i; socket_client->index = i;
spin_lock_init(&device_client->lock); spin_lock_init(&socket_client->lock);
init_waitqueue_head(&device_client->queue_wait); init_waitqueue_head(&socket_client->queue_wait);
file->private_data = device_client; file->private_data = socket_client;
inc_module_count(); inc_module_count();
return 0; return 0;
} }
int bat_device_release(struct inode *inode, struct file *file) static int bat_socket_release(struct inode *inode, struct file *file)
{ {
struct device_client *device_client = struct socket_client *socket_client = file->private_data;
(struct device_client *)file->private_data; struct socket_packet *socket_packet;
struct device_packet *device_packet;
struct list_head *list_pos, *list_pos_tmp; struct list_head *list_pos, *list_pos_tmp;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&device_client->lock, flags); spin_lock_irqsave(&socket_client->lock, flags);
/* for all packets in the queue ... */ /* for all packets in the queue ... */
list_for_each_safe(list_pos, list_pos_tmp, &device_client->queue_list) { list_for_each_safe(list_pos, list_pos_tmp, &socket_client->queue_list) {
device_packet = list_entry(list_pos, socket_packet = list_entry(list_pos,
struct device_packet, list); struct socket_packet, list);
list_del(list_pos); list_del(list_pos);
kfree(device_packet); kfree(socket_packet);
} }
device_client_hash[device_client->index] = NULL; socket_client_hash[socket_client->index] = NULL;
spin_unlock_irqrestore(&device_client->lock, flags); spin_unlock_irqrestore(&socket_client->lock, flags);
kfree(device_client); kfree(socket_client);
dec_module_count(); dec_module_count();
return 0; return 0;
} }
ssize_t bat_device_read(struct file *file, char __user *buf, size_t count, static ssize_t bat_socket_read(struct file *file, char __user *buf,
loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct device_client *device_client = struct socket_client *socket_client = file->private_data;
(struct device_client *)file->private_data; struct socket_packet *socket_packet;
struct device_packet *device_packet; size_t packet_len;
int error; int error;
unsigned long flags; unsigned long flags;
if ((file->f_flags & O_NONBLOCK) && (device_client->queue_len == 0)) if ((file->f_flags & O_NONBLOCK) && (socket_client->queue_len == 0))
return -EAGAIN; return -EAGAIN;
if ((!buf) || (count < sizeof(struct icmp_packet))) if ((!buf) || (count < sizeof(struct icmp_packet)))
...@@ -175,76 +121,82 @@ ssize_t bat_device_read(struct file *file, char __user *buf, size_t count, ...@@ -175,76 +121,82 @@ ssize_t bat_device_read(struct file *file, char __user *buf, size_t count,
if (!access_ok(VERIFY_WRITE, buf, count)) if (!access_ok(VERIFY_WRITE, buf, count))
return -EFAULT; return -EFAULT;
error = wait_event_interruptible(device_client->queue_wait, error = wait_event_interruptible(socket_client->queue_wait,
device_client->queue_len); socket_client->queue_len);
if (error) if (error)
return error; return error;
spin_lock_irqsave(&device_client->lock, flags); spin_lock_irqsave(&socket_client->lock, flags);
device_packet = list_first_entry(&device_client->queue_list, socket_packet = list_first_entry(&socket_client->queue_list,
struct device_packet, list); struct socket_packet, list);
list_del(&device_packet->list); list_del(&socket_packet->list);
device_client->queue_len--; socket_client->queue_len--;
spin_unlock_irqrestore(&device_client->lock, flags); spin_unlock_irqrestore(&socket_client->lock, flags);
error = __copy_to_user(buf, &device_packet->icmp_packet, error = __copy_to_user(buf, &socket_packet->icmp_packet,
sizeof(struct icmp_packet)); socket_packet->icmp_len);
kfree(device_packet); packet_len = socket_packet->icmp_len;
kfree(socket_packet);
if (error) if (error)
return -EFAULT; return -EFAULT;
return sizeof(struct icmp_packet); return packet_len;
} }
ssize_t bat_device_write(struct file *file, const char __user *buff, static ssize_t bat_socket_write(struct file *file, const char __user *buff,
size_t len, loff_t *off) size_t len, loff_t *off)
{ {
struct device_client *device_client = /* FIXME: each orig_node->batman_if will be attached to a softif */
(struct device_client *)file->private_data; struct bat_priv *bat_priv = netdev_priv(soft_device);
struct icmp_packet icmp_packet; struct socket_client *socket_client = file->private_data;
struct icmp_packet_rr icmp_packet;
struct orig_node *orig_node; struct orig_node *orig_node;
struct batman_if *batman_if; struct batman_if *batman_if;
size_t packet_len = sizeof(struct icmp_packet);
uint8_t dstaddr[ETH_ALEN]; uint8_t dstaddr[ETH_ALEN];
unsigned long flags; unsigned long flags;
if (len < sizeof(struct icmp_packet)) { if (len < sizeof(struct icmp_packet)) {
bat_dbg(DBG_BATMAN, "batman-adv:" bat_dbg(DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: " "Error - can't send packet from char device: "
"invalid packet size\n"); "invalid packet size\n");
return -EINVAL; return -EINVAL;
} }
if (!access_ok(VERIFY_READ, buff, sizeof(struct icmp_packet))) if (len >= sizeof(struct icmp_packet_rr))
packet_len = sizeof(struct icmp_packet_rr);
if (!access_ok(VERIFY_READ, buff, packet_len))
return -EFAULT; return -EFAULT;
if (__copy_from_user(&icmp_packet, buff, sizeof(icmp_packet))) if (__copy_from_user(&icmp_packet, buff, packet_len))
return -EFAULT; return -EFAULT;
if (icmp_packet.packet_type != BAT_ICMP) { if (icmp_packet.packet_type != BAT_ICMP) {
bat_dbg(DBG_BATMAN, "batman-adv:" bat_dbg(DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: " "Error - can't send packet from char device: "
"got bogus packet type (expected: BAT_ICMP)\n"); "got bogus packet type (expected: BAT_ICMP)\n");
return -EINVAL; return -EINVAL;
} }
if (icmp_packet.msg_type != ECHO_REQUEST) { if (icmp_packet.msg_type != ECHO_REQUEST) {
bat_dbg(DBG_BATMAN, "batman-adv:" bat_dbg(DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: " "Error - can't send packet from char device: "
"got bogus message type (expected: ECHO_REQUEST)\n"); "got bogus message type (expected: ECHO_REQUEST)\n");
return -EINVAL; return -EINVAL;
} }
icmp_packet.uid = device_client->index; icmp_packet.uid = socket_client->index;
if (icmp_packet.version != COMPAT_VERSION) { if (icmp_packet.version != COMPAT_VERSION) {
icmp_packet.msg_type = PARAMETER_PROBLEM; icmp_packet.msg_type = PARAMETER_PROBLEM;
icmp_packet.ttl = COMPAT_VERSION; icmp_packet.ttl = COMPAT_VERSION;
bat_device_add_packet(device_client, &icmp_packet); bat_socket_add_packet(socket_client, &icmp_packet, packet_len);
goto out; goto out;
} }
...@@ -271,13 +223,13 @@ ssize_t bat_device_write(struct file *file, const char __user *buff, ...@@ -271,13 +223,13 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
if (batman_if->if_status != IF_ACTIVE) if (batman_if->if_status != IF_ACTIVE)
goto dst_unreach; goto dst_unreach;
memcpy(icmp_packet.orig, memcpy(icmp_packet.orig, batman_if->net_dev->dev_addr, ETH_ALEN);
batman_if->net_dev->dev_addr,
ETH_ALEN); if (packet_len == sizeof(struct icmp_packet_rr))
memcpy(icmp_packet.rr, batman_if->net_dev->dev_addr, ETH_ALEN);
send_raw_packet((unsigned char *)&icmp_packet, send_raw_packet((unsigned char *)&icmp_packet,
sizeof(struct icmp_packet), packet_len, batman_if, dstaddr);
batman_if, dstaddr);
goto out; goto out;
...@@ -285,70 +237,98 @@ ssize_t bat_device_write(struct file *file, const char __user *buff, ...@@ -285,70 +237,98 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
spin_unlock_irqrestore(&orig_hash_lock, flags); spin_unlock_irqrestore(&orig_hash_lock, flags);
dst_unreach: dst_unreach:
icmp_packet.msg_type = DESTINATION_UNREACHABLE; icmp_packet.msg_type = DESTINATION_UNREACHABLE;
bat_device_add_packet(device_client, &icmp_packet); bat_socket_add_packet(socket_client, &icmp_packet, packet_len);
out: out:
return len; return len;
} }
unsigned int bat_device_poll(struct file *file, poll_table *wait) static unsigned int bat_socket_poll(struct file *file, poll_table *wait)
{ {
struct device_client *device_client = struct socket_client *socket_client = file->private_data;
(struct device_client *)file->private_data;
poll_wait(file, &device_client->queue_wait, wait); poll_wait(file, &socket_client->queue_wait, wait);
if (device_client->queue_len > 0) if (socket_client->queue_len > 0)
return POLLIN | POLLRDNORM; return POLLIN | POLLRDNORM;
return 0; return 0;
} }
void bat_device_add_packet(struct device_client *device_client, static const struct file_operations fops = {
struct icmp_packet *icmp_packet) .owner = THIS_MODULE,
.open = bat_socket_open,
.release = bat_socket_release,
.read = bat_socket_read,
.write = bat_socket_write,
.poll = bat_socket_poll,
};
int bat_socket_setup(struct bat_priv *bat_priv)
{
struct dentry *d;
if (!bat_priv->debug_dir)
goto err;
d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR,
bat_priv->debug_dir, NULL, &fops);
if (d)
goto err;
return 0;
err:
return 1;
}
static void bat_socket_add_packet(struct socket_client *socket_client,
struct icmp_packet_rr *icmp_packet,
size_t icmp_len)
{ {
struct device_packet *device_packet; struct socket_packet *socket_packet;
unsigned long flags; unsigned long flags;
device_packet = kmalloc(sizeof(struct device_packet), GFP_ATOMIC); socket_packet = kmalloc(sizeof(struct socket_packet), GFP_ATOMIC);
if (!device_packet) if (!socket_packet)
return; return;
INIT_LIST_HEAD(&device_packet->list); INIT_LIST_HEAD(&socket_packet->list);
memcpy(&device_packet->icmp_packet, icmp_packet, memcpy(&socket_packet->icmp_packet, icmp_packet, icmp_len);
sizeof(struct icmp_packet)); socket_packet->icmp_len = icmp_len;
spin_lock_irqsave(&device_client->lock, flags); spin_lock_irqsave(&socket_client->lock, flags);
/* while waiting for the lock the device_client could have been /* while waiting for the lock the socket_client could have been
* deleted */ * deleted */
if (!device_client_hash[icmp_packet->uid]) { if (!socket_client_hash[icmp_packet->uid]) {
spin_unlock_irqrestore(&device_client->lock, flags); spin_unlock_irqrestore(&socket_client->lock, flags);
kfree(device_packet); kfree(socket_packet);
return; return;
} }
list_add_tail(&device_packet->list, &device_client->queue_list); list_add_tail(&socket_packet->list, &socket_client->queue_list);
device_client->queue_len++; socket_client->queue_len++;
if (device_client->queue_len > 100) { if (socket_client->queue_len > 100) {
device_packet = list_first_entry(&device_client->queue_list, socket_packet = list_first_entry(&socket_client->queue_list,
struct device_packet, list); struct socket_packet, list);
list_del(&device_packet->list); list_del(&socket_packet->list);
kfree(device_packet); kfree(socket_packet);
device_client->queue_len--; socket_client->queue_len--;
} }
spin_unlock_irqrestore(&device_client->lock, flags); spin_unlock_irqrestore(&socket_client->lock, flags);
wake_up(&device_client->queue_wait); wake_up(&socket_client->queue_wait);
} }
void bat_device_receive_packet(struct icmp_packet *icmp_packet) void bat_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
size_t icmp_len)
{ {
struct device_client *hash = device_client_hash[icmp_packet->uid]; struct socket_client *hash = socket_client_hash[icmp_packet->uid];
if (hash) if (hash)
bat_device_add_packet(hash, icmp_packet); bat_socket_add_packet(hash, icmp_packet, icmp_len);
} }
...@@ -19,18 +19,16 @@ ...@@ -19,18 +19,16 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_
#define _NET_BATMAN_ADV_ICMP_SOCKET_H_
#include "types.h" #include "types.h"
void bat_device_init(void); #define ICMP_SOCKET "socket"
int bat_device_setup(void);
void bat_device_destroy(void); void bat_socket_init(void);
int bat_device_open(struct inode *inode, struct file *file); int bat_socket_setup(struct bat_priv *bat_priv);
int bat_device_release(struct inode *inode, struct file *file); void bat_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
ssize_t bat_device_read(struct file *file, char __user *buf, size_t count, size_t icmp_len);
loff_t *ppos);
ssize_t bat_device_write(struct file *file, const char __user *buff, #endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */
size_t len, loff_t *off);
unsigned int bat_device_poll(struct file *file, poll_table *wait);
void bat_device_add_packet(struct device_client *device_client,
struct icmp_packet *icmp_packet);
void bat_device_receive_packet(struct icmp_packet *icmp_packet);
...@@ -21,11 +21,12 @@ ...@@ -21,11 +21,12 @@
#include "main.h" #include "main.h"
#include "bat_sysfs.h" #include "bat_sysfs.h"
#include "bat_debugfs.h"
#include "routing.h" #include "routing.h"
#include "send.h" #include "send.h"
#include "originator.h" #include "originator.h"
#include "soft-interface.h" #include "soft-interface.h"
#include "device.h" #include "icmp_socket.h"
#include "translation-table.h" #include "translation-table.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "types.h" #include "types.h"
...@@ -41,7 +42,6 @@ DEFINE_SPINLOCK(orig_hash_lock); ...@@ -41,7 +42,6 @@ DEFINE_SPINLOCK(orig_hash_lock);
DEFINE_SPINLOCK(forw_bat_list_lock); DEFINE_SPINLOCK(forw_bat_list_lock);
DEFINE_SPINLOCK(forw_bcast_list_lock); DEFINE_SPINLOCK(forw_bcast_list_lock);
atomic_t vis_interval;
atomic_t bcast_queue_left; atomic_t bcast_queue_left;
atomic_t batman_queue_left; atomic_t batman_queue_left;
...@@ -49,7 +49,7 @@ int16_t num_hna; ...@@ -49,7 +49,7 @@ int16_t num_hna;
struct net_device *soft_device; struct net_device *soft_device;
unsigned char broadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
atomic_t module_state; atomic_t module_state;
static struct packet_type batman_adv_packet_type __read_mostly = { static struct packet_type batman_adv_packet_type __read_mostly = {
...@@ -59,18 +59,7 @@ static struct packet_type batman_adv_packet_type __read_mostly = { ...@@ -59,18 +59,7 @@ static struct packet_type batman_adv_packet_type __read_mostly = {
struct workqueue_struct *bat_event_workqueue; struct workqueue_struct *bat_event_workqueue;
#ifdef CONFIG_BATMAN_ADV_DEBUG static int __init batman_init(void)
int debug;
module_param(debug, int, 0644);
int bat_debug_type(int type)
{
return debug & type;
}
#endif
int init_module(void)
{ {
int retval; int retval;
...@@ -80,8 +69,6 @@ int init_module(void) ...@@ -80,8 +69,6 @@ int init_module(void)
atomic_set(&module_state, MODULE_INACTIVE); atomic_set(&module_state, MODULE_INACTIVE);
atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only
* for debugging now. */
atomic_set(&bcast_queue_left, BCAST_QUEUE_LEN); atomic_set(&bcast_queue_left, BCAST_QUEUE_LEN);
atomic_set(&batman_queue_left, BATMAN_QUEUE_LEN); atomic_set(&batman_queue_left, BATMAN_QUEUE_LEN);
...@@ -92,23 +79,22 @@ int init_module(void) ...@@ -92,23 +79,22 @@ int init_module(void)
if (!bat_event_workqueue) if (!bat_event_workqueue)
return -ENOMEM; return -ENOMEM;
bat_device_init(); bat_socket_init();
debugfs_init();
/* initialize layer 2 interface */ /* initialize layer 2 interface */
soft_device = alloc_netdev(sizeof(struct bat_priv) , "bat%d", soft_device = alloc_netdev(sizeof(struct bat_priv) , "bat%d",
interface_setup); interface_setup);
if (!soft_device) { if (!soft_device) {
printk(KERN_ERR "batman-adv:" pr_err("Unable to allocate the batman interface\n");
"Unable to allocate the batman interface\n");
goto end; goto end;
} }
retval = register_netdev(soft_device); retval = register_netdev(soft_device);
if (retval < 0) { if (retval < 0) {
printk(KERN_ERR "batman-adv:" pr_err("Unable to register the batman interface: %i\n", retval);
"Unable to register the batman interface: %i\n", retval);
goto free_soft_device; goto free_soft_device;
} }
...@@ -117,15 +103,22 @@ int init_module(void) ...@@ -117,15 +103,22 @@ int init_module(void)
if (retval < 0) if (retval < 0)
goto unreg_soft_device; goto unreg_soft_device;
retval = debugfs_add_meshif(soft_device);
if (retval < 0)
goto unreg_sysfs;
register_netdevice_notifier(&hard_if_notifier); register_netdevice_notifier(&hard_if_notifier);
dev_add_pack(&batman_adv_packet_type); dev_add_pack(&batman_adv_packet_type);
printk(KERN_INFO "batman-adv:" pr_info("B.A.T.M.A.N. advanced %s%s (compatibility version %i) "
"B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n", "loaded\n", SOURCE_VERSION, REVISION_VERSION_STR,
SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION); COMPAT_VERSION);
return 0; return 0;
unreg_sysfs:
sysfs_del_meshif(soft_device);
unreg_soft_device: unreg_soft_device:
unregister_netdev(soft_device); unregister_netdev(soft_device);
soft_device = NULL; soft_device = NULL;
...@@ -138,14 +131,16 @@ int init_module(void) ...@@ -138,14 +131,16 @@ int init_module(void)
return -ENOMEM; return -ENOMEM;
} }
void cleanup_module(void) static void __exit batman_exit(void)
{ {
deactivate_module(); deactivate_module();
debugfs_destroy();
unregister_netdevice_notifier(&hard_if_notifier); unregister_netdevice_notifier(&hard_if_notifier);
hardif_remove_interfaces(); hardif_remove_interfaces();
if (soft_device) { if (soft_device) {
debugfs_del_meshif(soft_device);
sysfs_del_meshif(soft_device); sysfs_del_meshif(soft_device);
unregister_netdev(soft_device); unregister_netdev(soft_device);
soft_device = NULL; soft_device = NULL;
...@@ -157,7 +152,7 @@ void cleanup_module(void) ...@@ -157,7 +152,7 @@ void cleanup_module(void)
bat_event_workqueue = NULL; bat_event_workqueue = NULL;
} }
/* activates the module, creates bat device, starts timer ... */ /* activates the module, starts timer ... */
void activate_module(void) void activate_module(void)
{ {
if (originator_init() < 1) if (originator_init() < 1)
...@@ -171,9 +166,6 @@ void activate_module(void) ...@@ -171,9 +166,6 @@ void activate_module(void)
hna_local_add(soft_device->dev_addr); hna_local_add(soft_device->dev_addr);
if (bat_device_setup() < 1)
goto end;
if (vis_init() < 1) if (vis_init() < 1)
goto err; goto err;
...@@ -182,8 +174,7 @@ void activate_module(void) ...@@ -182,8 +174,7 @@ void activate_module(void)
goto end; goto end;
err: err:
printk(KERN_ERR "batman-adv:" pr_err("Unable to allocate memory for mesh information structures: "
"Unable to allocate memory for mesh information structures: "
"out of mem ?\n"); "out of mem ?\n");
deactivate_module(); deactivate_module();
end: end:
...@@ -208,7 +199,6 @@ void deactivate_module(void) ...@@ -208,7 +199,6 @@ void deactivate_module(void)
hna_global_free(); hna_global_free();
synchronize_net(); synchronize_net();
bat_device_destroy();
synchronize_rcu(); synchronize_rcu();
atomic_set(&module_state, MODULE_INACTIVE); atomic_set(&module_state, MODULE_INACTIVE);
...@@ -226,8 +216,7 @@ void dec_module_count(void) ...@@ -226,8 +216,7 @@ void dec_module_count(void)
int addr_to_string(char *buff, uint8_t *addr) int addr_to_string(char *buff, uint8_t *addr)
{ {
return sprintf(buff, MAC_FMT, return sprintf(buff, "%pM", addr);
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
} }
/* returns 1 if they are the same originator */ /* returns 1 if they are the same originator */
...@@ -284,6 +273,9 @@ int is_mcast(uint8_t *addr) ...@@ -284,6 +273,9 @@ int is_mcast(uint8_t *addr)
return *addr & 0x01; return *addr & 0x01;
} }
module_init(batman_init);
module_exit(batman_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_AUTHOR(DRIVER_AUTHOR);
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_MAIN_H_
#define _NET_BATMAN_ADV_MAIN_H_
/* Kernel Programming */ /* Kernel Programming */
#define LINUX #define LINUX
...@@ -27,7 +30,7 @@ ...@@ -27,7 +30,7 @@
#define DRIVER_DESC "B.A.T.M.A.N. advanced" #define DRIVER_DESC "B.A.T.M.A.N. advanced"
#define DRIVER_DEVICE "batman-adv" #define DRIVER_DEVICE "batman-adv"
#define SOURCE_VERSION "0.2.2-beta" #define SOURCE_VERSION "maint"
/* B.A.T.M.A.N. parameters */ /* B.A.T.M.A.N. parameters */
...@@ -36,10 +39,10 @@ ...@@ -36,10 +39,10 @@
#define JITTER 20 #define JITTER 20
#define TTL 50 /* Time To Live of broadcast messages */ #define TTL 50 /* Time To Live of broadcast messages */
#define PURGE_TIMEOUT 200000 /* purge originators after time in ms if no #define PURGE_TIMEOUT 200 /* purge originators after time in seconds if no
* valid packet comes in -> TODO: check * valid packet comes in -> TODO: check
* influence on TQ_LOCAL_WINDOW_SIZE */ * influence on TQ_LOCAL_WINDOW_SIZE */
#define LOCAL_HNA_TIMEOUT 3600000 #define LOCAL_HNA_TIMEOUT 3600 /* in seconds */
#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 * messages in squence numbers (should be a
...@@ -57,44 +60,42 @@ ...@@ -57,44 +60,42 @@
#define LOG_BUF_LEN 8192 /* has to be a power of 2 */ #define LOG_BUF_LEN 8192 /* has to be a power of 2 */
#define ETH_STR_LEN 20 #define ETH_STR_LEN 20
#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 #define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or
* change the size of * change the size of
* forw_packet->direct_link_flags */ * forw_packet->direct_link_flags */
#define MAX_AGGREGATION_MS 100 #define MAX_AGGREGATION_MS 100
#define RESET_PROTECTION_MS 30000 #define RESET_PROTECTION_MS 30000
#define EXPECTED_SEQNO_RANGE 4096 #define EXPECTED_SEQNO_RANGE 65536
/* don't reset again within 30 seconds */ /* don't reset again within 30 seconds */
#define MODULE_INACTIVE 0 #define MODULE_INACTIVE 0
#define MODULE_ACTIVE 1 #define MODULE_ACTIVE 1
#define MODULE_DEACTIVATING 2 #define MODULE_DEACTIVATING 2
#define BCAST_QUEUE_LEN 256 #define BCAST_QUEUE_LEN 256
#define BATMAN_QUEUE_LEN 256 #define BATMAN_QUEUE_LEN 256
/* /*
* Debug Messages * Debug Messages
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* Append 'batman-adv: ' before
* kernel messages */
#define DBG_BATMAN 1 /* all messages related to routing / flooding / #define DBG_BATMAN 1 /* all messages related to routing / flooding /
* broadcasting / etc */ * broadcasting / etc */
#define DBG_ROUTES 2 /* route or hna added / changed / deleted */ #define DBG_ROUTES 2 /* route or hna added / changed / deleted */
#define DBG_ALL 3
#ifdef CONFIG_BATMAN_ADV_DEBUG #define LOG_BUF_LEN 8192 /* has to be a power of 2 */
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 * Vis
...@@ -117,6 +118,7 @@ extern int bat_debug_type(int type); ...@@ -117,6 +118,7 @@ extern int bat_debug_type(int type);
#include <linux/slab.h> #include <linux/slab.h>
#include <net/sock.h> /* struct sock */ #include <net/sock.h> /* struct sock */
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/seq_file.h>
#include "types.h" #include "types.h"
#ifndef REVISION_VERSION #ifndef REVISION_VERSION
...@@ -134,14 +136,13 @@ extern spinlock_t orig_hash_lock; ...@@ -134,14 +136,13 @@ extern spinlock_t orig_hash_lock;
extern spinlock_t forw_bat_list_lock; extern spinlock_t forw_bat_list_lock;
extern spinlock_t forw_bcast_list_lock; extern spinlock_t forw_bcast_list_lock;
extern atomic_t vis_interval;
extern atomic_t bcast_queue_left; extern atomic_t bcast_queue_left;
extern atomic_t batman_queue_left; extern atomic_t batman_queue_left;
extern int16_t num_hna; extern int16_t num_hna;
extern struct net_device *soft_device; extern struct net_device *soft_device;
extern unsigned char broadcastAddr[]; extern unsigned char broadcast_addr[];
extern atomic_t module_state; extern atomic_t module_state;
extern struct workqueue_struct *bat_event_workqueue; extern struct workqueue_struct *bat_event_workqueue;
...@@ -155,3 +156,44 @@ int choose_orig(void *data, int32_t size); ...@@ -155,3 +156,44 @@ int choose_orig(void *data, int32_t size);
int is_my_mac(uint8_t *addr); int is_my_mac(uint8_t *addr);
int is_bcast(uint8_t *addr); int is_bcast(uint8_t *addr);
int is_mcast(uint8_t *addr); int is_mcast(uint8_t *addr);
#ifdef CONFIG_BATMAN_ADV_DEBUG
extern 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 __attribute__((unused)),
struct bat_priv *bat_priv __attribute__((unused)),
char *fmt __attribute__((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_ */
...@@ -56,28 +56,16 @@ int originator_init(void) ...@@ -56,28 +56,16 @@ int originator_init(void)
return 0; 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 * struct neigh_node *
create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
uint8_t *neigh, struct batman_if *if_incoming) uint8_t *neigh, struct batman_if *if_incoming)
{ {
/* FIXME: each orig_node->batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct neigh_node *neigh_node; struct neigh_node *neigh_node;
bat_dbg(DBG_BATMAN, "Creating new last-hop neighbor of originator\n"); bat_dbg(DBG_BATMAN, bat_priv,
"Creating new last-hop neighbor of originator\n");
neigh_node = kzalloc(sizeof(struct neigh_node), GFP_ATOMIC); neigh_node = kzalloc(sizeof(struct neigh_node), GFP_ATOMIC);
if (!neigh_node) if (!neigh_node)
...@@ -93,7 +81,7 @@ create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, ...@@ -93,7 +81,7 @@ create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
return neigh_node; return neigh_node;
} }
void free_orig_node(void *data) static void free_orig_node(void *data)
{ {
struct list_head *list_pos, *list_pos_tmp; struct list_head *list_pos, *list_pos_tmp;
struct neigh_node *neigh_node; struct neigh_node *neigh_node;
...@@ -114,6 +102,21 @@ void free_orig_node(void *data) ...@@ -114,6 +102,21 @@ void free_orig_node(void *data)
kfree(orig_node); kfree(orig_node);
} }
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);
}
/* this function finds or creates an originator entry for the given /* this function finds or creates an originator entry for the given
* address if it does not exits */ * address if it does not exits */
struct orig_node *get_orig_node(uint8_t *addr) struct orig_node *get_orig_node(uint8_t *addr)
...@@ -129,7 +132,8 @@ struct orig_node *get_orig_node(uint8_t *addr) ...@@ -129,7 +132,8 @@ struct orig_node *get_orig_node(uint8_t *addr)
if (orig_node != NULL) if (orig_node != NULL)
return orig_node; return orig_node;
bat_dbg(DBG_BATMAN, "Creating new originator: %pM\n", addr); bat_dbg(DBG_BATMAN, bat_priv,
"Creating new originator: %pM\n", addr);
orig_node = kzalloc(sizeof(struct orig_node), GFP_ATOMIC); orig_node = kzalloc(sizeof(struct orig_node), GFP_ATOMIC);
if (!orig_node) if (!orig_node)
...@@ -163,8 +167,8 @@ struct orig_node *get_orig_node(uint8_t *addr) ...@@ -163,8 +167,8 @@ struct orig_node *get_orig_node(uint8_t *addr)
swaphash = hash_resize(orig_hash, orig_hash->size * 2); swaphash = hash_resize(orig_hash, orig_hash->size * 2);
if (swaphash == NULL) if (swaphash == NULL)
printk(KERN_ERR bat_err(soft_device,
"batman-adv:Couldn't resize orig hash table\n"); "Couldn't resize orig hash table\n");
else else
orig_hash = swaphash; orig_hash = swaphash;
} }
...@@ -182,6 +186,8 @@ struct orig_node *get_orig_node(uint8_t *addr) ...@@ -182,6 +186,8 @@ struct orig_node *get_orig_node(uint8_t *addr)
static bool purge_orig_neighbors(struct orig_node *orig_node, static bool purge_orig_neighbors(struct orig_node *orig_node,
struct neigh_node **best_neigh_node) struct neigh_node **best_neigh_node)
{ {
/* FIXME: each orig_node->batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct list_head *list_pos, *list_pos_tmp; struct list_head *list_pos, *list_pos_tmp;
struct neigh_node *neigh_node; struct neigh_node *neigh_node;
bool neigh_purged = false; bool neigh_purged = false;
...@@ -193,20 +199,19 @@ static bool purge_orig_neighbors(struct orig_node *orig_node, ...@@ -193,20 +199,19 @@ static bool purge_orig_neighbors(struct orig_node *orig_node,
neigh_node = list_entry(list_pos, struct neigh_node, list); neigh_node = list_entry(list_pos, struct neigh_node, list);
if ((time_after(jiffies, if ((time_after(jiffies,
(neigh_node->last_valid + neigh_node->last_valid + PURGE_TIMEOUT * HZ)) ||
((PURGE_TIMEOUT * HZ) / 1000)))) ||
(neigh_node->if_incoming->if_status == (neigh_node->if_incoming->if_status ==
IF_TO_BE_REMOVED)) { IF_TO_BE_REMOVED)) {
if (neigh_node->if_incoming->if_status == if (neigh_node->if_incoming->if_status ==
IF_TO_BE_REMOVED) IF_TO_BE_REMOVED)
bat_dbg(DBG_BATMAN, bat_dbg(DBG_BATMAN, bat_priv,
"neighbor purge: originator %pM, " "neighbor purge: originator %pM, "
"neighbor: %pM, iface: %s\n", "neighbor: %pM, iface: %s\n",
orig_node->orig, neigh_node->addr, orig_node->orig, neigh_node->addr,
neigh_node->if_incoming->dev); neigh_node->if_incoming->dev);
else else
bat_dbg(DBG_BATMAN, bat_dbg(DBG_BATMAN, bat_priv,
"neighbor timeout: originator %pM, " "neighbor timeout: originator %pM, "
"neighbor: %pM, last_valid: %lu\n", "neighbor: %pM, last_valid: %lu\n",
orig_node->orig, neigh_node->addr, orig_node->orig, neigh_node->addr,
...@@ -226,21 +231,26 @@ static bool purge_orig_neighbors(struct orig_node *orig_node, ...@@ -226,21 +231,26 @@ static bool purge_orig_neighbors(struct orig_node *orig_node,
static bool purge_orig_node(struct orig_node *orig_node) static bool purge_orig_node(struct orig_node *orig_node)
{ {
/* FIXME: each batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct neigh_node *best_neigh_node; struct neigh_node *best_neigh_node;
if (time_after(jiffies, if (time_after(jiffies,
(orig_node->last_valid + orig_node->last_valid + 2 * PURGE_TIMEOUT * HZ)) {
((2 * PURGE_TIMEOUT * HZ) / 1000)))) {
bat_dbg(DBG_BATMAN, bat_dbg(DBG_BATMAN, bat_priv,
"Originator timeout: originator %pM, last_valid %lu\n", "Originator timeout: originator %pM, last_valid %lu\n",
orig_node->orig, (orig_node->last_valid / HZ)); orig_node->orig, (orig_node->last_valid / HZ));
return true; return true;
} else { } else {
if (purge_orig_neighbors(orig_node, &best_neigh_node)) if (purge_orig_neighbors(orig_node, &best_neigh_node)) {
update_routes(orig_node, best_neigh_node, update_routes(orig_node, best_neigh_node,
orig_node->hna_buff, orig_node->hna_buff,
orig_node->hna_buff_len); orig_node->hna_buff_len);
/* update bonding candidates, we could have lost
* some candidates. */
update_bonding_candidates(bat_priv, orig_node);
}
} }
return false; return false;
...@@ -271,49 +281,41 @@ void purge_orig(struct work_struct *work) ...@@ -271,49 +281,41 @@ void purge_orig(struct work_struct *work)
start_purge_timer(); start_purge_timer();
} }
ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, int orig_seq_print_text(struct seq_file *seq, void *offset)
size_t count, loff_t off)
{ {
HASHIT(hashit); HASHIT(hashit);
struct net_device *net_dev = (struct net_device *)seq->private;
struct bat_priv *bat_priv = netdev_priv(net_dev); struct bat_priv *bat_priv = netdev_priv(net_dev);
struct orig_node *orig_node; struct orig_node *orig_node;
struct neigh_node *neigh_node; struct neigh_node *neigh_node;
size_t hdr_len, tmp_len; int batman_count = 0;
int batman_count = 0, bytes_written = 0; int last_seen_secs;
int last_seen_msecs;
unsigned long flags; unsigned long flags;
char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN]; char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN];
if (!bat_priv->primary_if) { if ((!bat_priv->primary_if) ||
if (off == 0) (bat_priv->primary_if->if_status != IF_ACTIVE)) {
return sprintf(buff, if (!bat_priv->primary_if)
"BATMAN mesh %s disabled - " return seq_printf(seq, "BATMAN mesh %s disabled - "
"please specify interfaces to enable it\n", "please specify interfaces to enable it\n",
net_dev->name); net_dev->name);
return 0; return seq_printf(seq, "BATMAN mesh %s "
"disabled - primary interface not active\n",
net_dev->name);
} }
if (bat_priv->primary_if->if_status != IF_ACTIVE && off == 0)
return sprintf(buff,
"BATMAN mesh %s "
"disabled - primary interface not active\n",
net_dev->name);
else if (bat_priv->primary_if->if_status != IF_ACTIVE)
return 0;
rcu_read_lock(); rcu_read_lock();
hdr_len = sprintf(buff, seq_printf(seq, "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
" %-14s (%s/%i) %17s [%10s]: %20s " SOURCE_VERSION, REVISION_VERSION_STR,
"... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
"Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF",
"Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR,
bat_priv->primary_if->dev, bat_priv->primary_if->addr_str, bat_priv->primary_if->dev, bat_priv->primary_if->addr_str,
net_dev->name); net_dev->name);
seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n",
"Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop",
"outgoingIF", "Potential nexthops");
rcu_read_unlock(); rcu_read_unlock();
if (off < hdr_len)
bytes_written = hdr_len;
spin_lock_irqsave(&orig_hash_lock, flags); spin_lock_irqsave(&orig_hash_lock, flags);
while (hash_iterate(orig_hash, &hashit)) { while (hash_iterate(orig_hash, &hashit)) {
...@@ -326,44 +328,34 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, ...@@ -326,44 +328,34 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
if (orig_node->router->tq_avg == 0) if (orig_node->router->tq_avg == 0)
continue; continue;
/* estimated line length */
if (count < bytes_written + 200)
break;
addr_to_string(orig_str, orig_node->orig); addr_to_string(orig_str, orig_node->orig);
addr_to_string(router_str, orig_node->router->addr); addr_to_string(router_str, orig_node->router->addr);
last_seen_secs = jiffies_to_msecs(jiffies -
orig_node->last_valid) / 1000;
last_seen_msecs = jiffies_to_msecs(jiffies -
orig_node->last_valid) % 1000;
tmp_len = sprintf(buff + bytes_written, seq_printf(seq, "%-17s %4i.%03is (%3i) %17s [%10s]:",
"%-17s (%3i) %17s [%10s]:", orig_str, last_seen_secs, last_seen_msecs,
orig_str, orig_node->router->tq_avg, orig_node->router->tq_avg, router_str,
router_str, orig_node->router->if_incoming->dev);
orig_node->router->if_incoming->dev);
list_for_each_entry(neigh_node, &orig_node->neigh_list, list) { list_for_each_entry(neigh_node, &orig_node->neigh_list, list) {
addr_to_string(orig_str, neigh_node->addr); addr_to_string(orig_str, neigh_node->addr);
tmp_len += sprintf(buff + bytes_written + tmp_len, seq_printf(seq, " %17s (%3i)", orig_str,
" %17s (%3i)", orig_str,
neigh_node->tq_avg); neigh_node->tq_avg);
} }
tmp_len += sprintf(buff + bytes_written + tmp_len, "\n"); seq_printf(seq, "\n");
batman_count++; batman_count++;
hdr_len += tmp_len;
if (off >= hdr_len)
continue;
bytes_written += tmp_len;
} }
spin_unlock_irqrestore(&orig_hash_lock, flags); spin_unlock_irqrestore(&orig_hash_lock, flags);
if ((batman_count == 0) && (off == 0)) if ((batman_count == 0))
bytes_written += sprintf(buff + bytes_written, seq_printf(seq, "No batman nodes in range ...\n");
"No batman nodes in range ...\n");
return bytes_written; return 0;
} }
static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
...@@ -373,8 +365,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) ...@@ -373,8 +365,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
data_ptr = kmalloc(max_if_num * sizeof(TYPE_OF_WORD) * NUM_WORDS, data_ptr = kmalloc(max_if_num * sizeof(TYPE_OF_WORD) * NUM_WORDS,
GFP_ATOMIC); GFP_ATOMIC);
if (!data_ptr) { if (!data_ptr) {
printk(KERN_ERR pr_err("Can't resize orig: out of memory\n");
"batman-adv:Can't resize orig: out of memory\n");
return -1; return -1;
} }
...@@ -385,8 +376,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) ...@@ -385,8 +376,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
if (!data_ptr) { if (!data_ptr) {
printk(KERN_ERR pr_err("Can't resize orig: out of memory\n");
"batman-adv:Can't resize orig: out of memory\n");
return -1; return -1;
} }
...@@ -435,8 +425,7 @@ static int orig_node_del_if(struct orig_node *orig_node, ...@@ -435,8 +425,7 @@ static int orig_node_del_if(struct orig_node *orig_node,
chunk_size = sizeof(TYPE_OF_WORD) * NUM_WORDS; chunk_size = sizeof(TYPE_OF_WORD) * NUM_WORDS;
data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC);
if (!data_ptr) { if (!data_ptr) {
printk(KERN_ERR pr_err("Can't resize orig: out of memory\n");
"batman-adv:Can't resize orig: out of memory\n");
return -1; return -1;
} }
...@@ -457,8 +446,7 @@ static int orig_node_del_if(struct orig_node *orig_node, ...@@ -457,8 +446,7 @@ static int orig_node_del_if(struct orig_node *orig_node,
data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
if (!data_ptr) { if (!data_ptr) {
printk(KERN_ERR pr_err("Can't resize orig: out of memory\n");
"batman-adv:Can't resize orig: out of memory\n");
return -1; return -1;
} }
......
...@@ -19,16 +19,18 @@ ...@@ -19,16 +19,18 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_ORIGINATOR_H_
#define _NET_BATMAN_ADV_ORIGINATOR_H_
int originator_init(void); int originator_init(void);
void free_orig_node(void *data);
void originator_free(void); void originator_free(void);
void purge_orig(struct work_struct *work); void purge_orig(struct work_struct *work);
struct orig_node *orig_find(char *mac);
struct orig_node *get_orig_node(uint8_t *addr); struct orig_node *get_orig_node(uint8_t *addr);
struct neigh_node * struct neigh_node *
create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
uint8_t *neigh, struct batman_if *if_incoming); uint8_t *neigh, struct batman_if *if_incoming);
ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, int orig_seq_print_text(struct seq_file *seq, void *offset);
size_t count, loff_t off);
int orig_hash_add_if(struct batman_if *batman_if, int max_if_num); int orig_hash_add_if(struct batman_if *batman_if, int max_if_num);
int orig_hash_del_if(struct batman_if *batman_if, int max_if_num); int orig_hash_del_if(struct batman_if *batman_if, int max_if_num);
#endif /* _NET_BATMAN_ADV_ORIGINATOR_H_ */
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_PACKET_H_
#define _NET_BATMAN_ADV_PACKET_H_
#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */ #define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
#define BAT_PACKET 0x01 #define BAT_PACKET 0x01
...@@ -28,9 +31,10 @@ ...@@ -28,9 +31,10 @@
#define BAT_VIS 0x05 #define BAT_VIS 0x05
/* this file is included by batctl which needs these defines */ /* this file is included by batctl which needs these defines */
#define COMPAT_VERSION 8 #define COMPAT_VERSION 11
#define DIRECTLINK 0x40 #define DIRECTLINK 0x40
#define VIS_SERVER 0x20 #define VIS_SERVER 0x20
#define PRIMARIES_FIRST_HOP 0x10
/* ICMP message types */ /* ICMP message types */
#define ECHO_REPLY 0 #define ECHO_REPLY 0
...@@ -48,7 +52,7 @@ struct batman_packet { ...@@ -48,7 +52,7 @@ struct batman_packet {
uint8_t version; /* batman version field */ uint8_t version; /* batman version field */
uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
uint8_t tq; uint8_t tq;
uint16_t seqno; uint32_t seqno;
uint8_t orig[6]; uint8_t orig[6];
uint8_t prev_sender[6]; uint8_t prev_sender[6];
uint8_t ttl; uint8_t ttl;
...@@ -68,6 +72,23 @@ struct icmp_packet { ...@@ -68,6 +72,23 @@ struct icmp_packet {
uint8_t uid; uint8_t uid;
} __attribute__((packed)); } __attribute__((packed));
#define BAT_RR_LEN 16
/* icmp_packet_rr must start with all fields from imcp_packet
as this is assumed by code that handles ICMP packets */
struct icmp_packet_rr {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t msg_type; /* see ICMP message types above */
uint8_t ttl;
uint8_t dst[6];
uint8_t orig[6];
uint16_t seqno;
uint8_t uid;
uint8_t rr_cur;
uint8_t rr[BAT_RR_LEN][ETH_ALEN];
} __attribute__((packed));
struct unicast_packet { struct unicast_packet {
uint8_t packet_type; uint8_t packet_type;
uint8_t version; /* batman version field */ uint8_t version; /* batman version field */
...@@ -79,18 +100,21 @@ struct bcast_packet { ...@@ -79,18 +100,21 @@ struct bcast_packet {
uint8_t packet_type; uint8_t packet_type;
uint8_t version; /* batman version field */ uint8_t version; /* batman version field */
uint8_t orig[6]; uint8_t orig[6];
uint16_t seqno; uint8_t ttl;
uint32_t seqno;
} __attribute__((packed)); } __attribute__((packed));
struct vis_packet { struct vis_packet {
uint8_t packet_type; uint8_t packet_type;
uint8_t version; /* batman version field */ uint8_t version; /* batman version field */
uint8_t vis_type; /* which type of vis-participant sent this? */ uint8_t vis_type; /* which type of vis-participant sent this? */
uint8_t seqno; /* sequence number */
uint8_t entries; /* number of entries behind this struct */ uint8_t entries; /* number of entries behind this struct */
uint32_t seqno; /* sequence number */
uint8_t ttl; /* TTL */ uint8_t ttl; /* TTL */
uint8_t vis_orig[6]; /* originator that informs about its uint8_t vis_orig[6]; /* originator that informs about its
* neighbors */ * neighbors */
uint8_t target_orig[6]; /* who should receive this packet */ uint8_t target_orig[6]; /* who should receive this packet */
uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */ uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */
} __attribute__((packed)); } __attribute__((packed));
#endif /* _NET_BATMAN_ADV_PACKET_H_ */
...@@ -19,5 +19,10 @@ ...@@ -19,5 +19,10 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_RING_BUFFER_H_
#define _NET_BATMAN_ADV_RING_BUFFER_H_
void ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, uint8_t value); void ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, uint8_t value);
uint8_t ring_buffer_avg(uint8_t lq_recv[]); uint8_t ring_buffer_avg(uint8_t lq_recv[]);
#endif /* _NET_BATMAN_ADV_RING_BUFFER_H_ */
...@@ -19,9 +19,10 @@ ...@@ -19,9 +19,10 @@
* *
*/ */
#include "types.h" #ifndef _NET_BATMAN_ADV_ROUTING_H_
#define _NET_BATMAN_ADV_ROUTING_H_
extern wait_queue_head_t thread_wait; #include "types.h"
void slide_own_bcast_window(struct batman_if *batman_if); void slide_own_bcast_window(struct batman_if *batman_if);
void receive_bat_packet(struct ethhdr *ethhdr, void receive_bat_packet(struct ethhdr *ethhdr,
...@@ -32,8 +33,14 @@ void update_routes(struct orig_node *orig_node, ...@@ -32,8 +33,14 @@ void update_routes(struct orig_node *orig_node,
struct neigh_node *neigh_node, struct neigh_node *neigh_node,
unsigned char *hna_buff, int hna_buff_len); unsigned char *hna_buff, int hna_buff_len);
int recv_icmp_packet(struct sk_buff *skb); int recv_icmp_packet(struct sk_buff *skb);
int recv_unicast_packet(struct sk_buff *skb); int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if);
int recv_bcast_packet(struct sk_buff *skb); int recv_bcast_packet(struct sk_buff *skb);
int recv_vis_packet(struct sk_buff *skb); int recv_vis_packet(struct sk_buff *skb);
int recv_bat_packet(struct sk_buff *skb, int recv_bat_packet(struct sk_buff *skb,
struct batman_if *batman_if); struct batman_if *batman_if);
struct neigh_node *find_router(struct orig_node *orig_node,
struct batman_if *recv_if);
void update_bonding_candidates(struct bat_priv *bat_priv,
struct orig_node *orig_node);
#endif /* _NET_BATMAN_ADV_ROUTING_H_ */
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
#include "vis.h" #include "vis.h"
#include "aggregation.h" #include "aggregation.h"
#include <linux/netfilter_bridge.h>
static void send_outstanding_bcast_packet(struct work_struct *work);
/* apply hop penalty for a normal link */ /* apply hop penalty for a normal link */
static uint8_t hop_penalty(const uint8_t tq) static uint8_t hop_penalty(const uint8_t tq)
{ {
...@@ -38,15 +42,15 @@ static uint8_t hop_penalty(const uint8_t tq) ...@@ -38,15 +42,15 @@ static uint8_t hop_penalty(const uint8_t tq)
/* when do we schedule our own packet to be sent */ /* when do we schedule our own packet to be sent */
static unsigned long own_send_time(struct bat_priv *bat_priv) static unsigned long own_send_time(struct bat_priv *bat_priv)
{ {
return jiffies + return jiffies + msecs_to_jiffies(
(((atomic_read(&bat_priv->orig_interval) - JITTER + atomic_read(&bat_priv->orig_interval) -
(random32() % 2*JITTER)) * HZ) / 1000); JITTER + (random32() % 2*JITTER));
} }
/* when do we schedule a forwarded packet to be sent */ /* 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(struct bat_priv *bat_priv)
{ {
return jiffies + (((random32() % (JITTER/2)) * HZ) / 1000); return jiffies + msecs_to_jiffies(random32() % (JITTER/2));
} }
/* send out an already prepared packet to the given address via the /* send out an already prepared packet to the given address via the
...@@ -64,10 +68,8 @@ int send_skb_packet(struct sk_buff *skb, ...@@ -64,10 +68,8 @@ int send_skb_packet(struct sk_buff *skb,
goto send_skb_err; goto send_skb_err;
if (!(batman_if->net_dev->flags & IFF_UP)) { if (!(batman_if->net_dev->flags & IFF_UP)) {
printk(KERN_WARNING pr_warning("Interface %s is not up - can't send packet via "
"batman-adv:Interface %s " "that interface!\n", batman_if->dev);
"is not up - can't send packet via that interface!\n",
batman_if->dev);
goto send_skb_err; goto send_skb_err;
} }
...@@ -90,9 +92,12 @@ int send_skb_packet(struct sk_buff *skb, ...@@ -90,9 +92,12 @@ int send_skb_packet(struct sk_buff *skb,
/* dev_queue_xmit() returns a negative result on error. However on /* dev_queue_xmit() returns a negative result on error. However on
* congestion and traffic shaping, it drops and returns NET_XMIT_DROP * congestion and traffic shaping, it drops and returns NET_XMIT_DROP
* (which is > 0). This will not be treated as an error. */ * (which is > 0). This will not be treated as an error.
* Also, if netfilter/ebtables wants to block outgoing batman
* packets then giving them a chance to do so here */
return dev_queue_xmit(skb); return NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
dev_queue_xmit);
send_skb_err: send_skb_err:
kfree_skb(skb); kfree_skb(skb);
return NET_XMIT_DROP; return NET_XMIT_DROP;
...@@ -119,6 +124,8 @@ void send_raw_packet(unsigned char *pack_buff, int pack_buff_len, ...@@ -119,6 +124,8 @@ void send_raw_packet(unsigned char *pack_buff, int pack_buff_len,
static void send_packet_to_if(struct forw_packet *forw_packet, static void send_packet_to_if(struct forw_packet *forw_packet,
struct batman_if *batman_if) struct batman_if *batman_if)
{ {
/* FIXME: each batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
char *fwd_str; char *fwd_str;
uint8_t packet_num; uint8_t packet_num;
int16_t buff_pos; int16_t buff_pos;
...@@ -148,11 +155,11 @@ static void send_packet_to_if(struct forw_packet *forw_packet, ...@@ -148,11 +155,11 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ? fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ?
"Sending own" : "Sending own" :
"Forwarding")); "Forwarding"));
bat_dbg(DBG_BATMAN, bat_dbg(DBG_BATMAN, bat_priv,
"%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d," "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d,"
" IDF %s) on interface %s [%s]\n", " IDF %s) on interface %s [%s]\n",
fwd_str, (packet_num > 0 ? "aggregated " : ""), fwd_str, (packet_num > 0 ? "aggregated " : ""),
batman_packet->orig, ntohs(batman_packet->seqno), batman_packet->orig, ntohl(batman_packet->seqno),
batman_packet->tq, batman_packet->ttl, batman_packet->tq, batman_packet->ttl,
(batman_packet->flags & DIRECTLINK ? (batman_packet->flags & DIRECTLINK ?
"on" : "off"), "on" : "off"),
...@@ -167,20 +174,22 @@ static void send_packet_to_if(struct forw_packet *forw_packet, ...@@ -167,20 +174,22 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
send_raw_packet(forw_packet->packet_buff, send_raw_packet(forw_packet->packet_buff,
forw_packet->packet_len, forw_packet->packet_len,
batman_if, broadcastAddr); batman_if, broadcast_addr);
} }
/* send a batman packet */ /* send a batman packet */
static void send_packet(struct forw_packet *forw_packet) static void send_packet(struct forw_packet *forw_packet)
{ {
/* FIXME: each batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct batman_if *batman_if; struct batman_if *batman_if;
struct batman_packet *batman_packet = struct batman_packet *batman_packet =
(struct batman_packet *)(forw_packet->packet_buff); (struct batman_packet *)(forw_packet->packet_buff);
unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0); unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
if (!forw_packet->if_incoming) { if (!forw_packet->if_incoming) {
printk(KERN_ERR "batman-adv: Error - can't forward packet: " pr_err("Error - can't forward packet: incoming iface not "
"incoming iface not specified\n"); "specified\n");
return; return;
} }
...@@ -193,18 +202,18 @@ static void send_packet(struct forw_packet *forw_packet) ...@@ -193,18 +202,18 @@ static void send_packet(struct forw_packet *forw_packet)
(forw_packet->own && (forw_packet->if_incoming->if_num > 0))) { (forw_packet->own && (forw_packet->if_incoming->if_num > 0))) {
/* FIXME: what about aggregated packets ? */ /* FIXME: what about aggregated packets ? */
bat_dbg(DBG_BATMAN, bat_dbg(DBG_BATMAN, bat_priv,
"%s packet (originator %pM, seqno %d, TTL %d) " "%s packet (originator %pM, seqno %d, TTL %d) "
"on interface %s [%s]\n", "on interface %s [%s]\n",
(forw_packet->own ? "Sending own" : "Forwarding"), (forw_packet->own ? "Sending own" : "Forwarding"),
batman_packet->orig, ntohs(batman_packet->seqno), batman_packet->orig, ntohl(batman_packet->seqno),
batman_packet->ttl, forw_packet->if_incoming->dev, batman_packet->ttl, forw_packet->if_incoming->dev,
forw_packet->if_incoming->addr_str); forw_packet->if_incoming->addr_str);
send_raw_packet(forw_packet->packet_buff, send_raw_packet(forw_packet->packet_buff,
forw_packet->packet_len, forw_packet->packet_len,
forw_packet->if_incoming, forw_packet->if_incoming,
broadcastAddr); broadcast_addr);
return; return;
} }
...@@ -276,14 +285,14 @@ void schedule_own_packet(struct batman_if *batman_if) ...@@ -276,14 +285,14 @@ void schedule_own_packet(struct batman_if *batman_if)
batman_packet = (struct batman_packet *)batman_if->packet_buff; batman_packet = (struct batman_packet *)batman_if->packet_buff;
/* change sequence number to network order */ /* change sequence number to network order */
batman_packet->seqno = htons((uint16_t)atomic_read(&batman_if->seqno)); batman_packet->seqno =
htonl((uint32_t)atomic_read(&batman_if->seqno));
if (vis_server == VIS_TYPE_SERVER_SYNC) if (vis_server == VIS_TYPE_SERVER_SYNC)
batman_packet->flags = VIS_SERVER; batman_packet->flags |= VIS_SERVER;
else else
batman_packet->flags &= ~VIS_SERVER; batman_packet->flags &= ~VIS_SERVER;
/* could be read by receive_bat_packet() */
atomic_inc(&batman_if->seqno); atomic_inc(&batman_if->seqno);
slide_own_bcast_window(batman_if); slide_own_bcast_window(batman_if);
...@@ -306,7 +315,7 @@ void schedule_forward_packet(struct orig_node *orig_node, ...@@ -306,7 +315,7 @@ void schedule_forward_packet(struct orig_node *orig_node,
unsigned long send_time; unsigned long send_time;
if (batman_packet->ttl <= 1) { if (batman_packet->ttl <= 1) {
bat_dbg(DBG_BATMAN, "ttl exceeded\n"); bat_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n");
return; return;
} }
...@@ -335,13 +344,16 @@ void schedule_forward_packet(struct orig_node *orig_node, ...@@ -335,13 +344,16 @@ void schedule_forward_packet(struct orig_node *orig_node,
/* apply hop penalty */ /* apply hop penalty */
batman_packet->tq = hop_penalty(batman_packet->tq); batman_packet->tq = hop_penalty(batman_packet->tq);
bat_dbg(DBG_BATMAN, "Forwarding packet: tq_orig: %i, tq_avg: %i, " bat_dbg(DBG_BATMAN, bat_priv,
"Forwarding packet: tq_orig: %i, tq_avg: %i, "
"tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n", "tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
in_tq, tq_avg, batman_packet->tq, in_ttl - 1, in_tq, tq_avg, batman_packet->tq, in_ttl - 1,
batman_packet->ttl); batman_packet->ttl);
batman_packet->seqno = htons(batman_packet->seqno); batman_packet->seqno = htonl(batman_packet->seqno);
/* switch of primaries first hop flag when forwarding */
batman_packet->flags &= ~PRIMARIES_FIRST_HOP;
if (directlink) if (directlink)
batman_packet->flags |= DIRECTLINK; batman_packet->flags |= DIRECTLINK;
else else
...@@ -392,9 +404,12 @@ static void _add_bcast_packet_to_list(struct forw_packet *forw_packet, ...@@ -392,9 +404,12 @@ static void _add_bcast_packet_to_list(struct forw_packet *forw_packet,
int add_bcast_packet_to_list(struct sk_buff *skb) int add_bcast_packet_to_list(struct sk_buff *skb)
{ {
struct forw_packet *forw_packet; struct forw_packet *forw_packet;
struct bcast_packet *bcast_packet;
/* FIXME: each batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
if (!atomic_dec_not_zero(&bcast_queue_left)) { if (!atomic_dec_not_zero(&bcast_queue_left)) {
bat_dbg(DBG_BATMAN, "bcast packet queue full\n"); bat_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n");
goto out; goto out;
} }
...@@ -407,6 +422,10 @@ int add_bcast_packet_to_list(struct sk_buff *skb) ...@@ -407,6 +422,10 @@ int add_bcast_packet_to_list(struct sk_buff *skb)
if (!skb) if (!skb)
goto packet_free; goto packet_free;
/* as we have a copy now, it is safe to decrease the TTL */
bcast_packet = (struct bcast_packet *)skb->data;
bcast_packet->ttl--;
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
forw_packet->skb = skb; forw_packet->skb = skb;
...@@ -426,7 +445,7 @@ int add_bcast_packet_to_list(struct sk_buff *skb) ...@@ -426,7 +445,7 @@ int add_bcast_packet_to_list(struct sk_buff *skb)
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
void send_outstanding_bcast_packet(struct work_struct *work) static void send_outstanding_bcast_packet(struct work_struct *work)
{ {
struct batman_if *batman_if; struct batman_if *batman_if;
struct delayed_work *delayed_work = struct delayed_work *delayed_work =
...@@ -450,7 +469,7 @@ void send_outstanding_bcast_packet(struct work_struct *work) ...@@ -450,7 +469,7 @@ void send_outstanding_bcast_packet(struct work_struct *work)
skb1 = skb_copy(forw_packet->skb, GFP_ATOMIC); skb1 = skb_copy(forw_packet->skb, GFP_ATOMIC);
if (skb1) if (skb1)
send_skb_packet(skb1, send_skb_packet(skb1,
batman_if, broadcastAddr); batman_if, broadcast_addr);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -502,15 +521,19 @@ void send_outstanding_bat_packet(struct work_struct *work) ...@@ -502,15 +521,19 @@ void send_outstanding_bat_packet(struct work_struct *work)
void purge_outstanding_packets(struct batman_if *batman_if) void purge_outstanding_packets(struct batman_if *batman_if)
{ {
/* FIXME: each batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct forw_packet *forw_packet; struct forw_packet *forw_packet;
struct hlist_node *tmp_node, *safe_tmp_node; struct hlist_node *tmp_node, *safe_tmp_node;
unsigned long flags; unsigned long flags;
if (batman_if) if (batman_if)
bat_dbg(DBG_BATMAN, "purge_outstanding_packets(): %s\n", bat_dbg(DBG_BATMAN, bat_priv,
"purge_outstanding_packets(): %s\n",
batman_if->dev); batman_if->dev);
else else
bat_dbg(DBG_BATMAN, "purge_outstanding_packets()\n"); bat_dbg(DBG_BATMAN, bat_priv,
"purge_outstanding_packets()\n");
/* free bcast list */ /* free bcast list */
spin_lock_irqsave(&forw_bcast_list_lock, flags); spin_lock_irqsave(&forw_bcast_list_lock, flags);
......
...@@ -19,9 +19,11 @@ ...@@ -19,9 +19,11 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_SEND_H_
#define _NET_BATMAN_ADV_SEND_H_
#include "types.h" #include "types.h"
void send_own_packet_work(struct work_struct *work);
int send_skb_packet(struct sk_buff *skb, int send_skb_packet(struct sk_buff *skb,
struct batman_if *batman_if, struct batman_if *batman_if,
uint8_t *dst_addr); uint8_t *dst_addr);
...@@ -34,6 +36,7 @@ void schedule_forward_packet(struct orig_node *orig_node, ...@@ -34,6 +36,7 @@ void schedule_forward_packet(struct orig_node *orig_node,
uint8_t directlink, int hna_buff_len, uint8_t directlink, int hna_buff_len,
struct batman_if *if_outgoing); struct batman_if *if_outgoing);
int add_bcast_packet_to_list(struct sk_buff *skb); int 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 send_outstanding_bat_packet(struct work_struct *work);
void purge_outstanding_packets(struct batman_if *batman_if); void purge_outstanding_packets(struct batman_if *batman_if);
#endif /* _NET_BATMAN_ADV_SEND_H_ */
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "main.h" #include "main.h"
#include "soft-interface.h" #include "soft-interface.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "routing.h"
#include "send.h" #include "send.h"
#include "translation-table.h" #include "translation-table.h"
#include "types.h" #include "types.h"
...@@ -30,13 +31,12 @@ ...@@ -30,13 +31,12 @@
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
static uint16_t bcast_seqno = 1; /* give own bcast messages seq numbers to avoid static uint32_t bcast_seqno = 1; /* give own bcast messages seq numbers to avoid
* broadcast storms */ * broadcast storms */
static int32_t skb_packets; static int32_t skb_packets;
static int32_t skb_bad_packets; static int32_t skb_bad_packets;
unsigned char mainIfAddr[ETH_ALEN]; unsigned char main_if_addr[ETH_ALEN];
static unsigned char mainIfAddr_default[ETH_ALEN];
static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd); static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd);
static void bat_get_drvinfo(struct net_device *dev, static void bat_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info); struct ethtool_drvinfo *info);
...@@ -58,12 +58,7 @@ static const struct ethtool_ops bat_ethtool_ops = { ...@@ -58,12 +58,7 @@ static const struct ethtool_ops bat_ethtool_ops = {
void set_main_if_addr(uint8_t *addr) void set_main_if_addr(uint8_t *addr)
{ {
memcpy(mainIfAddr, addr, ETH_ALEN); memcpy(main_if_addr, addr, ETH_ALEN);
}
int main_if_was_up(void)
{
return (memcmp(mainIfAddr, mainIfAddr_default, ETH_ALEN) != 0 ? 1 : 0);
} }
int my_skb_push(struct sk_buff *skb, unsigned int len) int my_skb_push(struct sk_buff *skb, unsigned int len)
...@@ -83,69 +78,25 @@ int my_skb_push(struct sk_buff *skb, unsigned int len) ...@@ -83,69 +78,25 @@ int my_skb_push(struct sk_buff *skb, unsigned int len)
return 0; return 0;
} }
#ifdef HAVE_NET_DEVICE_OPS static int interface_open(struct net_device *dev)
static const struct net_device_ops bat_netdev_ops = {
.ndo_open = interface_open,
.ndo_stop = interface_release,
.ndo_get_stats = interface_stats,
.ndo_set_mac_address = interface_set_mac_addr,
.ndo_change_mtu = interface_change_mtu,
.ndo_start_xmit = interface_tx,
.ndo_validate_addr = eth_validate_addr
};
#endif
void interface_setup(struct net_device *dev)
{
struct bat_priv *priv = netdev_priv(dev);
char dev_addr[ETH_ALEN];
ether_setup(dev);
#ifdef HAVE_NET_DEVICE_OPS
dev->netdev_ops = &bat_netdev_ops;
#else
dev->open = interface_open;
dev->stop = interface_release;
dev->get_stats = interface_stats;
dev->set_mac_address = interface_set_mac_addr;
dev->change_mtu = interface_change_mtu;
dev->hard_start_xmit = interface_tx;
#endif
dev->destructor = free_netdev;
dev->mtu = hardif_min_mtu();
dev->hard_header_len = BAT_HEADER_LEN; /* reserve more space in the
* skbuff for our header */
/* generate random address */
random_ether_addr(dev_addr);
memcpy(dev->dev_addr, dev_addr, ETH_ALEN);
SET_ETHTOOL_OPS(dev, &bat_ethtool_ops);
memset(priv, 0, sizeof(struct bat_priv));
}
int interface_open(struct net_device *dev)
{ {
netif_start_queue(dev); netif_start_queue(dev);
return 0; return 0;
} }
int interface_release(struct net_device *dev) static int interface_release(struct net_device *dev)
{ {
netif_stop_queue(dev); netif_stop_queue(dev);
return 0; return 0;
} }
struct net_device_stats *interface_stats(struct net_device *dev) static struct net_device_stats *interface_stats(struct net_device *dev)
{ {
struct bat_priv *priv = netdev_priv(dev); struct bat_priv *priv = netdev_priv(dev);
return &priv->stats; return &priv->stats;
} }
int interface_set_mac_addr(struct net_device *dev, void *p) static int interface_set_mac_addr(struct net_device *dev, void *p)
{ {
struct sockaddr *addr = p; struct sockaddr *addr = p;
...@@ -163,7 +114,7 @@ int interface_set_mac_addr(struct net_device *dev, void *p) ...@@ -163,7 +114,7 @@ int interface_set_mac_addr(struct net_device *dev, void *p)
return 0; return 0;
} }
int interface_change_mtu(struct net_device *dev, int new_mtu) static int interface_change_mtu(struct net_device *dev, int new_mtu)
{ {
/* check ranges */ /* check ranges */
if ((new_mtu < 68) || (new_mtu > hardif_min_mtu())) if ((new_mtu < 68) || (new_mtu > hardif_min_mtu()))
...@@ -179,6 +130,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -179,6 +130,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
struct unicast_packet *unicast_packet; struct unicast_packet *unicast_packet;
struct bcast_packet *bcast_packet; struct bcast_packet *bcast_packet;
struct orig_node *orig_node; struct orig_node *orig_node;
struct neigh_node *router;
struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct bat_priv *priv = netdev_priv(dev); struct bat_priv *priv = netdev_priv(dev);
struct batman_if *batman_if; struct batman_if *batman_if;
...@@ -205,16 +157,17 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -205,16 +157,17 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
bcast_packet = (struct bcast_packet *)skb->data; bcast_packet = (struct bcast_packet *)skb->data;
bcast_packet->version = COMPAT_VERSION; bcast_packet->version = COMPAT_VERSION;
bcast_packet->ttl = TTL;
/* batman packet type: broadcast */ /* batman packet type: broadcast */
bcast_packet->packet_type = BAT_BCAST; bcast_packet->packet_type = BAT_BCAST;
/* hw address of first interface is the orig mac because only /* hw address of first interface is the orig mac because only
* this mac is known throughout the mesh */ * this mac is known throughout the mesh */
memcpy(bcast_packet->orig, mainIfAddr, ETH_ALEN); memcpy(bcast_packet->orig, main_if_addr, ETH_ALEN);
/* set broadcast sequence number */ /* set broadcast sequence number */
bcast_packet->seqno = htons(bcast_seqno); bcast_packet->seqno = htonl(bcast_seqno);
/* broadcast packet. on success, increase seqno. */ /* broadcast packet. on success, increase seqno. */
if (add_bcast_packet_to_list(skb) == NETDEV_TX_OK) if (add_bcast_packet_to_list(skb) == NETDEV_TX_OK)
...@@ -235,38 +188,36 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -235,38 +188,36 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
if (!orig_node) if (!orig_node)
orig_node = transtable_search(ethhdr->h_dest); orig_node = transtable_search(ethhdr->h_dest);
if ((orig_node) && router = find_router(orig_node, NULL);
(orig_node->router)) {
struct neigh_node *router = orig_node->router;
if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0) if (!router)
goto unlock; goto unlock;
unicast_packet = (struct unicast_packet *)skb->data; /* don't lock while sending the packets ... we therefore
* copy the required data before sending */
unicast_packet->version = COMPAT_VERSION; batman_if = router->if_incoming;
/* batman packet type: unicast */ memcpy(dstaddr, router->addr, ETH_ALEN);
unicast_packet->packet_type = BAT_UNICAST;
/* set unicast ttl */
unicast_packet->ttl = TTL;
/* copy the destination for faster routing */
memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
/* net_dev won't be available when not active */ spin_unlock_irqrestore(&orig_hash_lock, flags);
if (router->if_incoming->if_status != IF_ACTIVE)
goto unlock;
/* don't lock while sending the packets ... we therefore if (batman_if->if_status != IF_ACTIVE)
* copy the required data before sending */ goto dropped;
batman_if = router->if_incoming; if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0)
memcpy(dstaddr, router->addr, ETH_ALEN); goto dropped;
spin_unlock_irqrestore(&orig_hash_lock, flags);
send_skb_packet(skb, batman_if, dstaddr); unicast_packet = (struct unicast_packet *)skb->data;
} else {
goto unlock; unicast_packet->version = COMPAT_VERSION;
} /* batman packet type: unicast */
unicast_packet->packet_type = BAT_UNICAST;
/* set unicast ttl */
unicast_packet->ttl = TTL;
/* copy the destination for faster routing */
memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
send_skb_packet(skb, batman_if, dstaddr);
} }
priv->stats.tx_packets++; priv->stats.tx_packets++;
...@@ -315,6 +266,50 @@ void interface_rx(struct sk_buff *skb, int hdr_size) ...@@ -315,6 +266,50 @@ void interface_rx(struct sk_buff *skb, int hdr_size)
netif_rx(skb); netif_rx(skb);
} }
#ifdef HAVE_NET_DEVICE_OPS
static const struct net_device_ops bat_netdev_ops = {
.ndo_open = interface_open,
.ndo_stop = interface_release,
.ndo_get_stats = interface_stats,
.ndo_set_mac_address = interface_set_mac_addr,
.ndo_change_mtu = interface_change_mtu,
.ndo_start_xmit = interface_tx,
.ndo_validate_addr = eth_validate_addr
};
#endif
void interface_setup(struct net_device *dev)
{
struct bat_priv *priv = netdev_priv(dev);
char dev_addr[ETH_ALEN];
ether_setup(dev);
#ifdef HAVE_NET_DEVICE_OPS
dev->netdev_ops = &bat_netdev_ops;
#else
dev->open = interface_open;
dev->stop = interface_release;
dev->get_stats = interface_stats;
dev->set_mac_address = interface_set_mac_addr;
dev->change_mtu = interface_change_mtu;
dev->hard_start_xmit = interface_tx;
#endif
dev->destructor = free_netdev;
dev->mtu = hardif_min_mtu();
dev->hard_header_len = BAT_HEADER_LEN; /* reserve more space in the
* skbuff for our header */
/* generate random address */
random_ether_addr(dev_addr);
memcpy(dev->dev_addr, dev_addr, ETH_ALEN);
SET_ETHTOOL_OPS(dev, &bat_ethtool_ops);
memset(priv, 0, sizeof(struct bat_priv));
}
/* ethtool */ /* ethtool */
static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{ {
......
...@@ -19,16 +19,15 @@ ...@@ -19,16 +19,15 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_SOFT_INTERFACE_H_
#define _NET_BATMAN_ADV_SOFT_INTERFACE_H_
void set_main_if_addr(uint8_t *addr); void set_main_if_addr(uint8_t *addr);
int main_if_was_up(void);
void interface_setup(struct net_device *dev); void interface_setup(struct net_device *dev);
int interface_open(struct net_device *dev);
int interface_release(struct net_device *dev);
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); int interface_tx(struct sk_buff *skb, struct net_device *dev);
void interface_rx(struct sk_buff *skb, int hdr_size); void interface_rx(struct sk_buff *skb, int hdr_size);
int my_skb_push(struct sk_buff *skb, unsigned int len); int my_skb_push(struct sk_buff *skb, unsigned int len);
extern unsigned char mainIfAddr[]; extern unsigned char main_if_addr[];
#endif /* _NET_BATMAN_ADV_SOFT_INTERFACE_H_ */
What: /sys/class/net/<iface>/batman-adv/mesh_iface
Date: May 2010
Contact: Marek Lindner <lindner_marek@yahoo.de>
Description:
The /sys/class/net/<iface>/batman-adv/mesh_iface file
displays the batman mesh interface this <iface>
currently is associated with.
What: /sys/class/net/<iface>/batman-adv/iface_status
Date: May 2010
Contact: Marek Lindner <lindner_marek@yahoo.de>
Description:
Indicates the status of <iface> as it is seen by batman.
What: /sys/class/net/<mesh_iface>/mesh/aggregated_ogms
Date: May 2010
Contact: Marek Lindner <lindner_marek@yahoo.de>
Description:
Indicates whether the batman protocol messages of the
mesh <mesh_iface> shall be aggregated or not.
What: /sys/class/net/<mesh_iface>/mesh/bonding
Date: June 2010
Contact: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Description:
Indicates whether the data traffic going through the
mesh will be sent using multiple interfaces at the
same time (if available).
What: /sys/class/net/<mesh_iface>/mesh/orig_interval
Date: May 2010
Contact: Marek Lindner <lindner_marek@yahoo.de>
Description:
Defines the interval in milliseconds in which batman
sends its protocol messages.
What: /sys/class/net/<mesh_iface>/mesh/vis_mode
Date: May 2010
Contact: Marek Lindner <lindner_marek@yahoo.de>
Description:
Each batman node only maintains information about its
own local neighborhood, therefore generating graphs
showing the topology of the entire mesh is not easily
feasible without having a central instance to collect
the local topologies from all nodes. This file allows
to activate the collecting (server) mode.
...@@ -32,7 +32,10 @@ atomic_t hna_local_changed; ...@@ -32,7 +32,10 @@ atomic_t hna_local_changed;
DEFINE_SPINLOCK(hna_local_hash_lock); DEFINE_SPINLOCK(hna_local_hash_lock);
static DEFINE_SPINLOCK(hna_global_hash_lock); static DEFINE_SPINLOCK(hna_global_hash_lock);
static void hna_local_purge(struct work_struct *work);
static DECLARE_DELAYED_WORK(hna_local_purge_wq, hna_local_purge); static DECLARE_DELAYED_WORK(hna_local_purge_wq, hna_local_purge);
static void _hna_global_del_orig(struct hna_global_entry *hna_global_entry,
char *message);
static void hna_local_start_timer(void) static void hna_local_start_timer(void)
{ {
...@@ -57,6 +60,8 @@ int hna_local_init(void) ...@@ -57,6 +60,8 @@ int hna_local_init(void)
void hna_local_add(uint8_t *addr) void hna_local_add(uint8_t *addr)
{ {
/* FIXME: each orig_node->batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct hna_local_entry *hna_local_entry; struct hna_local_entry *hna_local_entry;
struct hna_global_entry *hna_global_entry; struct hna_global_entry *hna_global_entry;
struct hashtable_t *swaphash; struct hashtable_t *swaphash;
...@@ -77,15 +82,15 @@ void hna_local_add(uint8_t *addr) ...@@ -77,15 +82,15 @@ void hna_local_add(uint8_t *addr)
MAC-flooding. */ MAC-flooding. */
if ((num_hna + 1 > (ETH_DATA_LEN - BAT_PACKET_LEN) / ETH_ALEN) || if ((num_hna + 1 > (ETH_DATA_LEN - BAT_PACKET_LEN) / ETH_ALEN) ||
(num_hna + 1 > 255)) { (num_hna + 1 > 255)) {
bat_dbg(DBG_ROUTES, bat_dbg(DBG_ROUTES, bat_priv,
"Can't add new local hna entry (%pM): " "Can't add new local hna entry (%pM): "
"number of local hna entries exceeds packet size\n", "number of local hna entries exceeds packet size\n",
addr); addr);
return; return;
} }
bat_dbg(DBG_ROUTES, "Creating new local hna entry: %pM\n", bat_dbg(DBG_ROUTES, bat_priv,
addr); "Creating new local hna entry: %pM\n", addr);
hna_local_entry = kmalloc(sizeof(struct hna_local_entry), GFP_ATOMIC); hna_local_entry = kmalloc(sizeof(struct hna_local_entry), GFP_ATOMIC);
if (!hna_local_entry) if (!hna_local_entry)
...@@ -111,8 +116,7 @@ void hna_local_add(uint8_t *addr) ...@@ -111,8 +116,7 @@ void hna_local_add(uint8_t *addr)
hna_local_hash->size * 2); hna_local_hash->size * 2);
if (swaphash == NULL) if (swaphash == NULL)
printk(KERN_ERR "batman-adv:" pr_err("Couldn't resize local hna hash table\n");
"Couldn't resize local hna hash table\n");
else else
hna_local_hash = swaphash; hna_local_hash = swaphash;
} }
...@@ -160,59 +164,54 @@ int hna_local_fill_buffer(unsigned char *buff, int buff_len) ...@@ -160,59 +164,54 @@ int hna_local_fill_buffer(unsigned char *buff, int buff_len)
return i; return i;
} }
int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff, int hna_local_seq_print_text(struct seq_file *seq, void *offset)
size_t count, loff_t off)
{ {
struct net_device *net_dev = (struct net_device *)seq->private;
struct bat_priv *bat_priv = netdev_priv(net_dev); struct bat_priv *bat_priv = netdev_priv(net_dev);
struct hna_local_entry *hna_local_entry; struct hna_local_entry *hna_local_entry;
HASHIT(hashit); HASHIT(hashit);
int bytes_written = 0; HASHIT(hashit_count);
unsigned long flags; unsigned long flags;
size_t hdr_len; size_t buf_size, pos;
char *buff;
if (!bat_priv->primary_if) { if (!bat_priv->primary_if) {
if (off == 0) return seq_printf(seq, "BATMAN mesh %s disabled - "
return sprintf(buff, "please specify interfaces to enable it\n",
"BATMAN mesh %s disabled - " net_dev->name);
"please specify interfaces to enable it\n",
net_dev->name);
return 0;
} }
hdr_len = sprintf(buff, seq_printf(seq, "Locally retrieved addresses (from %s) "
"Locally retrieved addresses (from %s) " "announced via HNA:\n",
"announced via HNA:\n", net_dev->name);
net_dev->name);
if (off < hdr_len)
bytes_written = hdr_len;
spin_lock_irqsave(&hna_local_hash_lock, flags); spin_lock_irqsave(&hna_local_hash_lock, flags);
while (hash_iterate(hna_local_hash, &hashit)) { buf_size = 1;
hdr_len += 21; /* Estimate length for: " * xx:xx:xx:xx:xx:xx\n" */
while (hash_iterate(hna_local_hash, &hashit_count))
if (count < bytes_written + 22) buf_size += 21;
break;
if (off >= hdr_len) buff = kmalloc(buf_size, GFP_ATOMIC);
continue; if (!buff) {
spin_unlock_irqrestore(&hna_local_hash_lock, flags);
return -ENOMEM;
}
buff[0] = '\0';
pos = 0;
while (hash_iterate(hna_local_hash, &hashit)) {
hna_local_entry = hashit.bucket->data; hna_local_entry = hashit.bucket->data;
bytes_written += snprintf(buff + bytes_written, 22, pos += snprintf(buff + pos, 22, " * %pM\n",
" * " MAC_FMT "\n", hna_local_entry->addr);
hna_local_entry->addr[0],
hna_local_entry->addr[1],
hna_local_entry->addr[2],
hna_local_entry->addr[3],
hna_local_entry->addr[4],
hna_local_entry->addr[5]);
} }
spin_unlock_irqrestore(&hna_local_hash_lock, flags); spin_unlock_irqrestore(&hna_local_hash_lock, flags);
return bytes_written;
seq_printf(seq, "%s", buff);
kfree(buff);
return 0;
} }
static void _hna_local_del(void *data) static void _hna_local_del(void *data)
...@@ -225,7 +224,9 @@ static void _hna_local_del(void *data) ...@@ -225,7 +224,9 @@ static void _hna_local_del(void *data)
static void hna_local_del(struct hna_local_entry *hna_local_entry, static void hna_local_del(struct hna_local_entry *hna_local_entry,
char *message) char *message)
{ {
bat_dbg(DBG_ROUTES, "Deleting local hna entry (%pM): %s\n", /* FIXME: each orig_node->batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
bat_dbg(DBG_ROUTES, bat_priv, "Deleting local hna entry (%pM): %s\n",
hna_local_entry->addr, message); hna_local_entry->addr, message);
hash_remove(hna_local_hash, hna_local_entry->addr); hash_remove(hna_local_hash, hna_local_entry->addr);
...@@ -247,7 +248,7 @@ void hna_local_remove(uint8_t *addr, char *message) ...@@ -247,7 +248,7 @@ void hna_local_remove(uint8_t *addr, char *message)
spin_unlock_irqrestore(&hna_local_hash_lock, flags); spin_unlock_irqrestore(&hna_local_hash_lock, flags);
} }
void hna_local_purge(struct work_struct *work) static void hna_local_purge(struct work_struct *work)
{ {
struct hna_local_entry *hna_local_entry; struct hna_local_entry *hna_local_entry;
HASHIT(hashit); HASHIT(hashit);
...@@ -259,8 +260,7 @@ void hna_local_purge(struct work_struct *work) ...@@ -259,8 +260,7 @@ void hna_local_purge(struct work_struct *work)
while (hash_iterate(hna_local_hash, &hashit)) { while (hash_iterate(hna_local_hash, &hashit)) {
hna_local_entry = hashit.bucket->data; hna_local_entry = hashit.bucket->data;
timeout = hna_local_entry->last_seen + timeout = hna_local_entry->last_seen + LOCAL_HNA_TIMEOUT * HZ;
((LOCAL_HNA_TIMEOUT / 1000) * HZ);
if ((!hna_local_entry->never_purge) && if ((!hna_local_entry->never_purge) &&
time_after(jiffies, timeout)) time_after(jiffies, timeout))
hna_local_del(hna_local_entry, "address timed out"); hna_local_del(hna_local_entry, "address timed out");
...@@ -296,6 +296,8 @@ int hna_global_init(void) ...@@ -296,6 +296,8 @@ int hna_global_init(void)
void hna_global_add_orig(struct orig_node *orig_node, void hna_global_add_orig(struct orig_node *orig_node,
unsigned char *hna_buff, int hna_buff_len) unsigned char *hna_buff, int hna_buff_len)
{ {
/* FIXME: each orig_node->batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct hna_global_entry *hna_global_entry; struct hna_global_entry *hna_global_entry;
struct hna_local_entry *hna_local_entry; struct hna_local_entry *hna_local_entry;
struct hashtable_t *swaphash; struct hashtable_t *swaphash;
...@@ -322,7 +324,7 @@ void hna_global_add_orig(struct orig_node *orig_node, ...@@ -322,7 +324,7 @@ void hna_global_add_orig(struct orig_node *orig_node,
memcpy(hna_global_entry->addr, hna_ptr, ETH_ALEN); memcpy(hna_global_entry->addr, hna_ptr, ETH_ALEN);
bat_dbg(DBG_ROUTES, bat_dbg(DBG_ROUTES, bat_priv,
"Creating new global hna entry: " "Creating new global hna entry: "
"%pM (via %pM)\n", "%pM (via %pM)\n",
hna_global_entry->addr, orig_node->orig); hna_global_entry->addr, orig_node->orig);
...@@ -369,8 +371,7 @@ void hna_global_add_orig(struct orig_node *orig_node, ...@@ -369,8 +371,7 @@ void hna_global_add_orig(struct orig_node *orig_node,
hna_global_hash->size * 2); hna_global_hash->size * 2);
if (swaphash == NULL) if (swaphash == NULL)
printk(KERN_ERR "batman-adv:" pr_err("Couldn't resize global hna hash table\n");
"Couldn't resize global hna hash table\n");
else else
hna_global_hash = swaphash; hna_global_hash = swaphash;
} }
...@@ -378,71 +379,63 @@ void hna_global_add_orig(struct orig_node *orig_node, ...@@ -378,71 +379,63 @@ void hna_global_add_orig(struct orig_node *orig_node,
spin_unlock_irqrestore(&hna_global_hash_lock, flags); spin_unlock_irqrestore(&hna_global_hash_lock, flags);
} }
int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff, int hna_global_seq_print_text(struct seq_file *seq, void *offset)
size_t count, loff_t off)
{ {
struct net_device *net_dev = (struct net_device *)seq->private;
struct bat_priv *bat_priv = netdev_priv(net_dev); struct bat_priv *bat_priv = netdev_priv(net_dev);
struct hna_global_entry *hna_global_entry; struct hna_global_entry *hna_global_entry;
HASHIT(hashit); HASHIT(hashit);
int bytes_written = 0; HASHIT(hashit_count);
unsigned long flags; unsigned long flags;
size_t hdr_len; size_t buf_size, pos;
char *buff;
if (!bat_priv->primary_if) { if (!bat_priv->primary_if) {
if (off == 0) return seq_printf(seq, "BATMAN mesh %s disabled - "
return sprintf(buff, "please specify interfaces to enable it\n",
"BATMAN mesh %s disabled - " net_dev->name);
"please specify interfaces to enable it\n",
net_dev->name);
return 0;
} }
hdr_len = sprintf(buff, seq_printf(seq, "Globally announced HNAs received via the mesh %s\n",
"Globally announced HNAs received via the mesh %s " net_dev->name);
"(translation table):\n",
net_dev->name);
if (off < hdr_len)
bytes_written = hdr_len;
spin_lock_irqsave(&hna_global_hash_lock, flags); spin_lock_irqsave(&hna_global_hash_lock, flags);
while (hash_iterate(hna_global_hash, &hashit)) { buf_size = 1;
hdr_len += 43; /* Estimate length for: " * xx:xx:xx:xx:xx:xx via xx:xx:xx:xx:xx:xx\n"*/
while (hash_iterate(hna_global_hash, &hashit_count))
if (count < bytes_written + 44) buf_size += 43;
break;
if (off >= hdr_len) buff = kmalloc(buf_size, GFP_ATOMIC);
continue; if (!buff) {
spin_unlock_irqrestore(&hna_global_hash_lock, flags);
return -ENOMEM;
}
buff[0] = '\0';
pos = 0;
while (hash_iterate(hna_global_hash, &hashit)) {
hna_global_entry = hashit.bucket->data; hna_global_entry = hashit.bucket->data;
bytes_written += snprintf(buff + bytes_written, 44, pos += snprintf(buff + pos, 44,
" * " MAC_FMT " via " MAC_FMT "\n", " * %pM via %pM\n", hna_global_entry->addr,
hna_global_entry->addr[0], hna_global_entry->orig_node->orig);
hna_global_entry->addr[1],
hna_global_entry->addr[2],
hna_global_entry->addr[3],
hna_global_entry->addr[4],
hna_global_entry->addr[5],
hna_global_entry->orig_node->orig[0],
hna_global_entry->orig_node->orig[1],
hna_global_entry->orig_node->orig[2],
hna_global_entry->orig_node->orig[3],
hna_global_entry->orig_node->orig[4],
hna_global_entry->orig_node->orig[5]);
} }
spin_unlock_irqrestore(&hna_global_hash_lock, flags); spin_unlock_irqrestore(&hna_global_hash_lock, flags);
return bytes_written;
seq_printf(seq, "%s", buff);
kfree(buff);
return 0;
} }
void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, static void _hna_global_del_orig(struct hna_global_entry *hna_global_entry,
char *message) char *message)
{ {
bat_dbg(DBG_ROUTES, "Deleting global hna entry %pM (via %pM): %s\n", /* FIXME: each orig_node->batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
bat_dbg(DBG_ROUTES, bat_priv,
"Deleting global hna entry %pM (via %pM): %s\n",
hna_global_entry->addr, hna_global_entry->orig_node->orig, hna_global_entry->addr, hna_global_entry->orig_node->orig,
message); message);
......
...@@ -19,23 +19,21 @@ ...@@ -19,23 +19,21 @@
* *
*/ */
#ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
#include "types.h" #include "types.h"
int hna_local_init(void); int hna_local_init(void);
void hna_local_add(uint8_t *addr); void hna_local_add(uint8_t *addr);
void hna_local_remove(uint8_t *addr, char *message); 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(unsigned char *buff, int buff_len);
int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff, int hna_local_seq_print_text(struct seq_file *seq, void *offset);
size_t count, loff_t off);
void hna_local_purge(struct work_struct *work);
void hna_local_free(void); void hna_local_free(void);
int hna_global_init(void); int hna_global_init(void);
void hna_global_add_orig(struct orig_node *orig_node, unsigned char *hna_buff, void hna_global_add_orig(struct orig_node *orig_node, unsigned char *hna_buff,
int hna_buff_len); int hna_buff_len);
int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff, int hna_global_seq_print_text(struct seq_file *seq, void *offset);
size_t count, loff_t off);
void _hna_global_del_orig(struct hna_global_entry *hna_global_entry,
char *orig_str);
void hna_global_del_orig(struct orig_node *orig_node, char *message); void hna_global_del_orig(struct orig_node *orig_node, char *message);
void hna_global_free(void); void hna_global_free(void);
struct orig_node *transtable_search(uint8_t *addr); struct orig_node *transtable_search(uint8_t *addr);
...@@ -43,3 +41,5 @@ struct orig_node *transtable_search(uint8_t *addr); ...@@ -43,3 +41,5 @@ struct orig_node *transtable_search(uint8_t *addr);
extern spinlock_t hna_local_hash_lock; extern spinlock_t hna_local_hash_lock;
extern struct hashtable_t *hna_local_hash; extern struct hashtable_t *hna_local_hash;
extern atomic_t hna_local_changed; extern atomic_t hna_local_changed;
#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
...@@ -21,10 +21,8 @@ ...@@ -21,10 +21,8 @@
#ifndef _NET_BATMAN_ADV_TYPES_H_
#define _NET_BATMAN_ADV_TYPES_H_
#ifndef TYPES_H
#define TYPES_H
#include "packet.h" #include "packet.h"
#include "bitarray.h" #include "bitarray.h"
...@@ -52,6 +50,7 @@ struct batman_if { ...@@ -52,6 +50,7 @@ struct batman_if {
/** /**
* orig_node - structure for orig_list maintaining nodes of mesh * orig_node - structure for orig_list maintaining nodes of mesh
* @primary_addr: hosts primary interface address
* @last_valid: when last packet from this node was received * @last_valid: when last packet from this node was received
* @bcast_seqno_reset: time when the broadcast seqno window was reset * @bcast_seqno_reset: time when the broadcast seqno window was reset
* @batman_seqno_reset: time when the batman seqno window was reset * @batman_seqno_reset: time when the batman seqno window was reset
...@@ -59,9 +58,13 @@ struct batman_if { ...@@ -59,9 +58,13 @@ struct batman_if {
* @last_real_seqno: last and best known squence number * @last_real_seqno: last and best known squence number
* @last_ttl: ttl of last received packet * @last_ttl: ttl of last received packet
* @last_bcast_seqno: last broadcast sequence number received by this host * @last_bcast_seqno: last broadcast sequence number received by this host
*
* @candidates: how many candidates are available
* @selected: next bonding candidate
*/ */
struct orig_node { struct orig_node {
uint8_t orig[ETH_ALEN]; uint8_t orig[ETH_ALEN];
uint8_t primary_addr[ETH_ALEN];
struct neigh_node *router; struct neigh_node *router;
TYPE_OF_WORD *bcast_own; TYPE_OF_WORD *bcast_own;
uint8_t *bcast_own_sum; uint8_t *bcast_own_sum;
...@@ -72,12 +75,16 @@ struct orig_node { ...@@ -72,12 +75,16 @@ struct orig_node {
unsigned long batman_seqno_reset; unsigned long batman_seqno_reset;
uint8_t flags; uint8_t flags;
unsigned char *hna_buff; unsigned char *hna_buff;
int16_t hna_buff_len; int16_t hna_buff_len;
uint16_t last_real_seqno; uint32_t last_real_seqno;
uint8_t last_ttl; uint8_t last_ttl;
TYPE_OF_WORD bcast_bits[NUM_WORDS]; TYPE_OF_WORD bcast_bits[NUM_WORDS];
uint16_t last_bcast_seqno; uint32_t last_bcast_seqno;
struct list_head neigh_list; struct list_head neigh_list;
struct {
uint8_t candidates;
struct neigh_node *selected;
} bond;
}; };
/** /**
...@@ -92,6 +99,7 @@ struct neigh_node { ...@@ -92,6 +99,7 @@ struct neigh_node {
uint8_t tq_index; uint8_t tq_index;
uint8_t tq_avg; uint8_t tq_avg;
uint8_t last_ttl; uint8_t last_ttl;
struct neigh_node *next_bond_candidate;
unsigned long last_valid; unsigned long last_valid;
TYPE_OF_WORD real_bits[NUM_WORDS]; TYPE_OF_WORD real_bits[NUM_WORDS];
struct orig_node *orig_node; struct orig_node *orig_node;
...@@ -101,14 +109,18 @@ struct neigh_node { ...@@ -101,14 +109,18 @@ struct neigh_node {
struct bat_priv { struct bat_priv {
struct net_device_stats stats; struct net_device_stats stats;
atomic_t aggregation_enabled; atomic_t aggregation_enabled;
atomic_t bonding_enabled;
atomic_t vis_mode; atomic_t vis_mode;
atomic_t orig_interval; atomic_t orig_interval;
atomic_t log_level;
char num_ifaces; char num_ifaces;
struct debug_log *debug_log;
struct batman_if *primary_if; struct batman_if *primary_if;
struct kobject *mesh_obj; struct kobject *mesh_obj;
struct dentry *debug_dir;
}; };
struct device_client { struct socket_client {
struct list_head queue_list; struct list_head queue_list;
unsigned int queue_len; unsigned int queue_len;
unsigned char index; unsigned char index;
...@@ -116,9 +128,10 @@ struct device_client { ...@@ -116,9 +128,10 @@ struct device_client {
wait_queue_head_t queue_wait; wait_queue_head_t queue_wait;
}; };
struct device_packet { struct socket_packet {
struct list_head list; struct list_head list;
struct icmp_packet icmp_packet; size_t icmp_len;
struct icmp_packet_rr icmp_packet;
}; };
struct hna_local_entry { struct hna_local_entry {
...@@ -159,4 +172,12 @@ struct if_list_entry { ...@@ -159,4 +172,12 @@ struct if_list_entry {
struct hlist_node list; struct hlist_node list;
}; };
#endif struct debug_log {
char log_buff[LOG_BUF_LEN];
unsigned long log_start;
unsigned long log_end;
spinlock_t lock;
wait_queue_head_t queue_wait;
};
#endif /* _NET_BATMAN_ADV_TYPES_H_ */
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
_dummy > smallest_signed_int(_dummy); }) _dummy > smallest_signed_int(_dummy); })
#define seq_after(x, y) seq_before(y, x) #define seq_after(x, y) seq_before(y, x)
struct hashtable_t *vis_hash; static struct hashtable_t *vis_hash;
DEFINE_SPINLOCK(vis_hash_lock); static DEFINE_SPINLOCK(vis_hash_lock);
static DEFINE_SPINLOCK(recv_list_lock); static DEFINE_SPINLOCK(recv_list_lock);
static struct vis_info *my_vis_info; static struct vis_info *my_vis_info;
static struct list_head send_list; /* always locked with vis_hash_lock */ static struct list_head send_list; /* always locked with vis_hash_lock */
...@@ -115,7 +115,7 @@ static void vis_data_insert_interface(const uint8_t *interface, ...@@ -115,7 +115,7 @@ static void vis_data_insert_interface(const uint8_t *interface,
} }
/* its a new address, add it to the list */ /* its a new address, add it to the list */
entry = kmalloc(sizeof(*entry), GFP_KERNEL); entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry) if (!entry)
return; return;
memcpy(entry->addr, interface, ETH_ALEN); memcpy(entry->addr, interface, ETH_ALEN);
...@@ -142,12 +142,29 @@ static ssize_t vis_data_read_prim_sec(char *buff, struct hlist_head *if_list) ...@@ -142,12 +142,29 @@ static ssize_t vis_data_read_prim_sec(char *buff, struct hlist_head *if_list)
return len; return len;
} }
static size_t vis_data_count_prim_sec(struct hlist_head *if_list)
{
struct if_list_entry *entry;
struct hlist_node *pos;
size_t count = 0;
hlist_for_each_entry(entry, pos, if_list, list) {
if (entry->primary)
count += 9;
else
count += 23;
}
return count;
}
/* read an entry */ /* read an entry */
static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry, static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry,
uint8_t *src, bool primary) uint8_t *src, bool primary)
{ {
char to[40]; char to[18];
/* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */
addr_to_string(to, entry->dest); addr_to_string(to, entry->dest);
if (primary && entry->quality == 0) if (primary && entry->quality == 0)
return sprintf(buff, "HNA %s, ", to); return sprintf(buff, "HNA %s, ", to);
...@@ -157,38 +174,74 @@ static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry, ...@@ -157,38 +174,74 @@ static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry,
return 0; return 0;
} }
ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff, int vis_seq_print_text(struct seq_file *seq, void *offset)
size_t count, loff_t off)
{ {
HASHIT(hashit); HASHIT(hashit);
HASHIT(hashit_count);
struct vis_info *info; struct vis_info *info;
struct vis_info_entry *entries; struct vis_info_entry *entries;
struct net_device *net_dev = (struct net_device *)seq->private;
struct bat_priv *bat_priv = netdev_priv(net_dev); struct bat_priv *bat_priv = netdev_priv(net_dev);
HLIST_HEAD(vis_if_list); HLIST_HEAD(vis_if_list);
struct if_list_entry *entry; struct if_list_entry *entry;
struct hlist_node *pos, *n; struct hlist_node *pos, *n;
size_t hdr_len, tmp_len; int i;
int i, bytes_written = 0;
char tmp_addr_str[ETH_STR_LEN]; char tmp_addr_str[ETH_STR_LEN];
unsigned long flags; unsigned long flags;
int vis_server = atomic_read(&bat_priv->vis_mode); int vis_server = atomic_read(&bat_priv->vis_mode);
size_t buff_pos, buf_size;
char *buff;
if ((!bat_priv->primary_if) || if ((!bat_priv->primary_if) ||
(vis_server == VIS_TYPE_CLIENT_UPDATE)) (vis_server == VIS_TYPE_CLIENT_UPDATE))
return 0; return 0;
hdr_len = 0; buf_size = 1;
/* Estimate length */
spin_lock_irqsave(&vis_hash_lock, flags); spin_lock_irqsave(&vis_hash_lock, flags);
while (hash_iterate(vis_hash, &hashit_count)) {
info = hashit_count.bucket->data;
entries = (struct vis_info_entry *)
((char *)info + sizeof(struct vis_info));
for (i = 0; i < info->packet.entries; i++) {
if (entries[i].quality == 0)
continue;
vis_data_insert_interface(entries[i].src, &vis_if_list,
compare_orig(entries[i].src,
info->packet.vis_orig));
}
hlist_for_each_entry(entry, pos, &vis_if_list, list) {
buf_size += 18 + 26 * info->packet.entries;
/* add primary/secondary records */
if (compare_orig(entry->addr, info->packet.vis_orig))
buf_size +=
vis_data_count_prim_sec(&vis_if_list);
buf_size += 1;
}
hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) {
hlist_del(&entry->list);
kfree(entry);
}
}
buff = kmalloc(buf_size, GFP_ATOMIC);
if (!buff) {
spin_unlock_irqrestore(&vis_hash_lock, flags);
return -ENOMEM;
}
buff[0] = '\0';
buff_pos = 0;
while (hash_iterate(vis_hash, &hashit)) { while (hash_iterate(vis_hash, &hashit)) {
info = hashit.bucket->data; info = hashit.bucket->data;
entries = (struct vis_info_entry *) entries = (struct vis_info_entry *)
((char *)info + sizeof(struct vis_info)); ((char *)info + sizeof(struct vis_info));
/* estimated line length */
if (count < bytes_written + 200)
break;
for (i = 0; i < info->packet.entries; i++) { for (i = 0; i < info->packet.entries; i++) {
if (entries[i].quality == 0) if (entries[i].quality == 0)
continue; continue;
...@@ -199,30 +252,22 @@ ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff, ...@@ -199,30 +252,22 @@ ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff,
hlist_for_each_entry(entry, pos, &vis_if_list, list) { hlist_for_each_entry(entry, pos, &vis_if_list, list) {
addr_to_string(tmp_addr_str, entry->addr); addr_to_string(tmp_addr_str, entry->addr);
tmp_len = sprintf(buff + bytes_written, buff_pos += sprintf(buff + buff_pos, "%s,",
"%s,", tmp_addr_str); tmp_addr_str);
for (i = 0; i < info->packet.entries; i++) for (i = 0; i < info->packet.entries; i++)
tmp_len += vis_data_read_entry( buff_pos += vis_data_read_entry(buff + buff_pos,
buff + bytes_written + tmp_len, &entries[i],
&entries[i], entry->addr, entry->addr,
entry->primary); entry->primary);
/* add primary/secondary records */ /* add primary/secondary records */
if (compare_orig(entry->addr, info->packet.vis_orig)) if (compare_orig(entry->addr, info->packet.vis_orig))
tmp_len += vis_data_read_prim_sec( buff_pos +=
buff + bytes_written + tmp_len, vis_data_read_prim_sec(buff + buff_pos,
&vis_if_list); &vis_if_list);
tmp_len += sprintf(buff + bytes_written + tmp_len,
"\n");
hdr_len += tmp_len;
if (off >= hdr_len) buff_pos += sprintf(buff + buff_pos, "\n");
continue;
bytes_written += tmp_len;
} }
hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) { hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) {
...@@ -230,9 +275,13 @@ ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff, ...@@ -230,9 +275,13 @@ ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff,
kfree(entry); kfree(entry);
} }
} }
spin_unlock_irqrestore(&vis_hash_lock, flags); spin_unlock_irqrestore(&vis_hash_lock, flags);
return bytes_written; seq_printf(seq, "%s", buff);
kfree(buff);
return 0;
} }
/* add the info packet to the send list, if it was not /* add the info packet to the send list, if it was not
...@@ -308,7 +357,8 @@ static struct vis_info *add_packet(struct vis_packet *vis_packet, ...@@ -308,7 +357,8 @@ static struct vis_info *add_packet(struct vis_packet *vis_packet,
old_info = hash_find(vis_hash, &search_elem); old_info = hash_find(vis_hash, &search_elem);
if (old_info != NULL) { if (old_info != NULL) {
if (!seq_after(vis_packet->seqno, old_info->packet.seqno)) { if (!seq_after(ntohl(vis_packet->seqno),
ntohl(old_info->packet.seqno))) {
if (old_info->packet.seqno == vis_packet->seqno) { if (old_info->packet.seqno == vis_packet->seqno) {
recv_list_add(&old_info->recv_list, recv_list_add(&old_info->recv_list,
vis_packet->sender_orig); vis_packet->sender_orig);
...@@ -340,7 +390,7 @@ static struct vis_info *add_packet(struct vis_packet *vis_packet, ...@@ -340,7 +390,7 @@ static struct vis_info *add_packet(struct vis_packet *vis_packet,
/* Make it a broadcast packet, if required */ /* Make it a broadcast packet, if required */
if (make_broadcast) if (make_broadcast)
memcpy(info->packet.target_orig, broadcastAddr, ETH_ALEN); memcpy(info->packet.target_orig, broadcast_addr, ETH_ALEN);
/* repair if entries is longer than packet. */ /* repair if entries is longer than packet. */
if (info->packet.entries * sizeof(struct vis_info_entry) > vis_info_len) if (info->packet.entries * sizeof(struct vis_info_entry) > vis_info_len)
...@@ -474,9 +524,9 @@ static int generate_vis_packet(struct bat_priv *bat_priv) ...@@ -474,9 +524,9 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
info->packet.vis_type = atomic_read(&bat_priv->vis_mode); info->packet.vis_type = atomic_read(&bat_priv->vis_mode);
spin_lock_irqsave(&orig_hash_lock, flags); spin_lock_irqsave(&orig_hash_lock, flags);
memcpy(info->packet.target_orig, broadcastAddr, ETH_ALEN); memcpy(info->packet.target_orig, broadcast_addr, ETH_ALEN);
info->packet.ttl = TTL; info->packet.ttl = TTL;
info->packet.seqno++; info->packet.seqno = htonl(ntohl(info->packet.seqno) + 1);
info->packet.entries = 0; info->packet.entries = 0;
if (info->packet.vis_type == VIS_TYPE_CLIENT_UPDATE) { if (info->packet.vis_type == VIS_TYPE_CLIENT_UPDATE) {
...@@ -547,7 +597,7 @@ static void purge_vis_packets(void) ...@@ -547,7 +597,7 @@ static void purge_vis_packets(void)
if (info == my_vis_info) /* never purge own data. */ if (info == my_vis_info) /* never purge own data. */
continue; continue;
if (time_after(jiffies, if (time_after(jiffies,
info->first_seen + (VIS_TIMEOUT*HZ)/1000)) { info->first_seen + VIS_TIMEOUT * HZ)) {
hash_remove_bucket(vis_hash, &hashit); hash_remove_bucket(vis_hash, &hashit);
send_list_del(info); send_list_del(info);
kref_put(&info->refcount, free_info); kref_put(&info->refcount, free_info);
...@@ -591,7 +641,7 @@ static void broadcast_vis_packet(struct vis_info *info, int packet_length) ...@@ -591,7 +641,7 @@ static void broadcast_vis_packet(struct vis_info *info, int packet_length)
} }
spin_unlock_irqrestore(&orig_hash_lock, flags); spin_unlock_irqrestore(&orig_hash_lock, flags);
memcpy(info->packet.target_orig, broadcastAddr, ETH_ALEN); memcpy(info->packet.target_orig, broadcast_addr, ETH_ALEN);
} }
static void unicast_vis_packet(struct vis_info *info, int packet_length) static void unicast_vis_packet(struct vis_info *info, int packet_length)
...@@ -628,11 +678,11 @@ static void send_vis_packet(struct vis_info *info) ...@@ -628,11 +678,11 @@ static void send_vis_packet(struct vis_info *info)
int packet_length; int packet_length;
if (info->packet.ttl < 2) { if (info->packet.ttl < 2) {
printk(KERN_WARNING "batman-adv: Error - can't send vis packet: ttl exceeded\n"); pr_warning("Error - can't send vis packet: ttl exceeded\n");
return; return;
} }
memcpy(info->packet.sender_orig, mainIfAddr, ETH_ALEN); memcpy(info->packet.sender_orig, main_if_addr, ETH_ALEN);
info->packet.ttl--; info->packet.ttl--;
packet_length = sizeof(struct vis_packet) + packet_length = sizeof(struct vis_packet) +
...@@ -690,18 +740,18 @@ int vis_init(void) ...@@ -690,18 +740,18 @@ int vis_init(void)
vis_hash = hash_new(256, vis_info_cmp, vis_info_choose); vis_hash = hash_new(256, vis_info_cmp, vis_info_choose);
if (!vis_hash) { if (!vis_hash) {
printk(KERN_ERR "batman-adv:Can't initialize vis_hash\n"); pr_err("Can't initialize vis_hash\n");
goto err; goto err;
} }
my_vis_info = kmalloc(1000, GFP_ATOMIC); my_vis_info = kmalloc(1000, GFP_ATOMIC);
if (!my_vis_info) { if (!my_vis_info) {
printk(KERN_ERR "batman-adv:Can't initialize vis packet\n"); pr_err("Can't initialize vis packet\n");
goto err; goto err;
} }
/* prefill the vis info */ /* prefill the vis info */
my_vis_info->first_seen = jiffies - atomic_read(&vis_interval); my_vis_info->first_seen = jiffies - msecs_to_jiffies(VIS_INTERVAL);
INIT_LIST_HEAD(&my_vis_info->recv_list); INIT_LIST_HEAD(&my_vis_info->recv_list);
INIT_LIST_HEAD(&my_vis_info->send_list); INIT_LIST_HEAD(&my_vis_info->send_list);
kref_init(&my_vis_info->refcount); kref_init(&my_vis_info->refcount);
...@@ -713,12 +763,11 @@ int vis_init(void) ...@@ -713,12 +763,11 @@ int vis_init(void)
INIT_LIST_HEAD(&send_list); INIT_LIST_HEAD(&send_list);
memcpy(my_vis_info->packet.vis_orig, mainIfAddr, ETH_ALEN); memcpy(my_vis_info->packet.vis_orig, main_if_addr, ETH_ALEN);
memcpy(my_vis_info->packet.sender_orig, mainIfAddr, ETH_ALEN); memcpy(my_vis_info->packet.sender_orig, main_if_addr, ETH_ALEN);
if (hash_add(vis_hash, my_vis_info) < 0) { if (hash_add(vis_hash, my_vis_info) < 0) {
printk(KERN_ERR pr_err("Can't add own vis packet into hash\n");
"batman-adv:Can't add own vis packet into hash\n");
/* not in hash, need to remove it manually. */ /* not in hash, need to remove it manually. */
kref_put(&my_vis_info->refcount, free_info); kref_put(&my_vis_info->refcount, free_info);
goto err; goto err;
...@@ -764,5 +813,5 @@ void vis_quit(void) ...@@ -764,5 +813,5 @@ void vis_quit(void)
static void start_vis_timer(void) static void start_vis_timer(void)
{ {
queue_delayed_work(bat_event_workqueue, &vis_timer_wq, queue_delayed_work(bat_event_workqueue, &vis_timer_wq,
(atomic_read(&vis_interval) * HZ) / 1000); (VIS_INTERVAL * HZ) / 1000);
} }
...@@ -19,7 +19,10 @@ ...@@ -19,7 +19,10 @@
* *
*/ */
#define VIS_TIMEOUT 200000 #ifndef _NET_BATMAN_ADV_VIS_H_
#define _NET_BATMAN_ADV_VIS_H_
#define VIS_TIMEOUT 200 /* timeout of vis packets in seconds */
struct vis_info { struct vis_info {
unsigned long first_seen; unsigned long first_seen;
...@@ -44,11 +47,7 @@ struct recvlist_node { ...@@ -44,11 +47,7 @@ struct recvlist_node {
uint8_t mac[ETH_ALEN]; uint8_t mac[ETH_ALEN];
}; };
extern struct hashtable_t *vis_hash; int vis_seq_print_text(struct seq_file *seq, void *offset);
extern spinlock_t vis_hash_lock;
ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff,
size_t count, loff_t off);
void receive_server_sync_packet(struct bat_priv *bat_priv, void receive_server_sync_packet(struct bat_priv *bat_priv,
struct vis_packet *vis_packet, struct vis_packet *vis_packet,
int vis_info_len); int vis_info_len);
...@@ -57,3 +56,5 @@ void receive_client_update_packet(struct bat_priv *bat_priv, ...@@ -57,3 +56,5 @@ void receive_client_update_packet(struct bat_priv *bat_priv,
int vis_info_len); int vis_info_len);
int vis_init(void); int vis_init(void);
void vis_quit(void); void vis_quit(void);
#endif /* _NET_BATMAN_ADV_VIS_H_ */
...@@ -2,7 +2,6 @@ TODO: ...@@ -2,7 +2,6 @@ TODO:
- checkpatch.pl cleanups - checkpatch.pl cleanups
- Lindent - Lindent
- remove all wrappers - remove all wrappers
- remove typedefs
- audit userspace interface - audit userspace interface
- reserve major number - reserve major number
- cleanup the individual comedi drivers as well - cleanup the individual comedi drivers as well
......
...@@ -1845,8 +1845,15 @@ static int comedi_open(struct inode *inode, struct file *file) ...@@ -1845,8 +1845,15 @@ static int comedi_open(struct inode *inode, struct file *file)
} }
} }
if (dev->attached && dev->use_count == 0 && dev->open) if (dev->attached && dev->use_count == 0 && dev->open) {
dev->open(dev); int rc = dev->open(dev);
if (rc < 0) {
module_put(dev->driver->module);
module_put(THIS_MODULE);
mutex_unlock(&dev->mutex);
return rc;
}
}
dev->use_count++; dev->use_count++;
......
...@@ -53,62 +53,6 @@ ...@@ -53,62 +53,6 @@
COMEDI_MINORVERSION, COMEDI_MICROVERSION) COMEDI_MINORVERSION, COMEDI_MICROVERSION)
#define COMEDI_RELEASE VERSION #define COMEDI_RELEASE VERSION
#define COMEDI_INITCLEANUP_NOMODULE(x) \
static int __init x ## _init_module(void) \
{return comedi_driver_register(&(x)); } \
static void __exit x ## _cleanup_module(void) \
{comedi_driver_unregister(&(x)); } \
module_init(x ## _init_module); \
module_exit(x ## _cleanup_module);
#define COMEDI_MODULE_MACROS \
MODULE_AUTHOR("Comedi http://www.comedi.org"); \
MODULE_DESCRIPTION("Comedi low-level driver"); \
MODULE_LICENSE("GPL");
#define COMEDI_INITCLEANUP(x) \
COMEDI_MODULE_MACROS \
COMEDI_INITCLEANUP_NOMODULE(x)
#define COMEDI_PCI_INITCLEANUP_NOMODULE(comedi_driver, pci_id_table) \
static int __devinit comedi_driver ## _pci_probe(struct pci_dev *dev, \
const struct pci_device_id *ent) \
{ \
return comedi_pci_auto_config(dev, comedi_driver.driver_name); \
} \
static void __devexit comedi_driver ## _pci_remove(\
struct pci_dev *dev) \
{ \
comedi_pci_auto_unconfig(dev); \
} \
static struct pci_driver comedi_driver ## _pci_driver = \
{ \
.id_table = pci_id_table, \
.probe = &comedi_driver ## _pci_probe, \
.remove = __devexit_p(&comedi_driver ## _pci_remove) \
}; \
static int __init comedi_driver ## _init_module(void) \
{ \
int retval; \
retval = comedi_driver_register(&comedi_driver); \
if (retval < 0) \
return retval; \
comedi_driver ## _pci_driver.name = \
(char *)comedi_driver.driver_name; \
return pci_register_driver(&comedi_driver ## _pci_driver); \
} \
static void __exit comedi_driver ## _cleanup_module(void) \
{ \
pci_unregister_driver(&comedi_driver ## _pci_driver); \
comedi_driver_unregister(&comedi_driver); \
} \
module_init(comedi_driver ## _init_module); \
module_exit(comedi_driver ## _cleanup_module);
#define COMEDI_PCI_INITCLEANUP(comedi_driver, pci_id_table) \
COMEDI_MODULE_MACROS \
COMEDI_PCI_INITCLEANUP_NOMODULE(comedi_driver, pci_id_table)
#define PCI_VENDOR_ID_ADLINK 0x144a #define PCI_VENDOR_ID_ADLINK 0x144a
#define PCI_VENDOR_ID_ICP 0x104c #define PCI_VENDOR_ID_ICP 0x104c
#define PCI_VENDOR_ID_CONTEC 0x1221 #define PCI_VENDOR_ID_CONTEC 0x1221
...@@ -285,7 +229,7 @@ struct comedi_device { ...@@ -285,7 +229,7 @@ struct comedi_device {
struct fasync_struct *async_queue; struct fasync_struct *async_queue;
void (*open) (struct comedi_device *dev); int (*open) (struct comedi_device *dev);
void (*close) (struct comedi_device *dev); void (*close) (struct comedi_device *dev);
}; };
......
...@@ -117,7 +117,18 @@ static struct comedi_driver driver_8255 = { ...@@ -117,7 +117,18 @@ static struct comedi_driver driver_8255 = {
.detach = dev_8255_detach, .detach = dev_8255_detach,
}; };
COMEDI_INITCLEANUP(driver_8255); static int __init driver_8255_init_module(void)
{
return comedi_driver_register(&driver_8255);
}
static void __exit driver_8255_cleanup_module(void)
{
comedi_driver_unregister(&driver_8255);
}
module_init(driver_8255_init_module);
module_exit(driver_8255_cleanup_module);
static void do_config(struct comedi_device *dev, struct comedi_subdevice *s); static void do_config(struct comedi_device *dev, struct comedi_subdevice *s);
...@@ -457,3 +468,7 @@ static int dev_8255_detach(struct comedi_device *dev) ...@@ -457,3 +468,7 @@ static int dev_8255_detach(struct comedi_device *dev)
return 0; return 0;
} }
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
...@@ -49,7 +49,18 @@ static struct comedi_driver driver_acl7225b = { ...@@ -49,7 +49,18 @@ static struct comedi_driver driver_acl7225b = {
.offset = sizeof(struct boardtype), .offset = sizeof(struct boardtype),
}; };
COMEDI_INITCLEANUP(driver_acl7225b); static int __init driver_acl7225b_init_module(void)
{
return comedi_driver_register(&driver_acl7225b);
}
static void __exit driver_acl7225b_cleanup_module(void)
{
comedi_driver_unregister(&driver_acl7225b);
}
module_init(driver_acl7225b_init_module);
module_exit(driver_acl7225b_cleanup_module);
static int acl7225b_do_insn(struct comedi_device *dev, static int acl7225b_do_insn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
...@@ -150,3 +161,7 @@ static int acl7225b_detach(struct comedi_device *dev) ...@@ -150,3 +161,7 @@ static int acl7225b_detach(struct comedi_device *dev)
return 0; return 0;
} }
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
...@@ -247,16 +247,14 @@ int i_pci_card_data(struct pcilst_struct *amcc, ...@@ -247,16 +247,14 @@ int i_pci_card_data(struct pcilst_struct *amcc,
/* build list of amcc cards in this system */ /* build list of amcc cards in this system */
void v_pci_card_list_init(unsigned short pci_vendor, char display) void v_pci_card_list_init(unsigned short pci_vendor, char display)
{ {
struct pci_dev *pcidev; struct pci_dev *pcidev = NULL;
struct pcilst_struct *amcc, *last; struct pcilst_struct *amcc, *last;
int i; int i;
int i_Count = 0; int i_Count = 0;
amcc_devices = NULL; amcc_devices = NULL;
last = NULL; last = NULL;
for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); for_each_pci_dev(pcidev) {
pcidev != NULL;
pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
for (i_Count = 0; i_Count < 2; i_Count++) { for (i_Count = 0; i_Count < 2; i_Count++) {
pci_vendor = i_ADDIDATADeviceID[i_Count]; pci_vendor = i_ADDIDATADeviceID[i_Count];
if (pcidev->vendor == pci_vendor) { if (pcidev->vendor == pci_vendor) {
......
...@@ -2541,7 +2541,43 @@ static struct comedi_driver driver_addi = { ...@@ -2541,7 +2541,43 @@ static struct comedi_driver driver_addi = {
.offset = sizeof(struct addi_board), .offset = sizeof(struct addi_board),
}; };
COMEDI_PCI_INITCLEANUP(driver_addi, addi_apci_tbl); static int __devinit driver_addi_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, driver_addi.driver_name);
}
static void __devexit driver_addi_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
static struct pci_driver driver_addi_pci_driver = {
.id_table = addi_apci_tbl,
.probe = &driver_addi_pci_probe,
.remove = __devexit_p(&driver_addi_pci_remove)
};
static int __init driver_addi_init_module(void)
{
int retval;
retval = comedi_driver_register(&driver_addi);
if (retval < 0)
return retval;
driver_addi_pci_driver.name = (char *)driver_addi.driver_name;
return pci_register_driver(&driver_addi_pci_driver);
}
static void __exit driver_addi_cleanup_module(void)
{
pci_unregister_driver(&driver_addi_pci_driver);
comedi_driver_unregister(&driver_addi);
}
module_init(driver_addi_init_module);
module_exit(driver_addi_cleanup_module);
/* /*
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
......
...@@ -101,10 +101,10 @@ struct str_TimerMainHeader { ...@@ -101,10 +101,10 @@ struct str_TimerMainHeader {
}; };
typedef struct { struct str_AnalogOutputHeader {
unsigned short w_Nchannel; unsigned short w_Nchannel;
unsigned char b_Resolution; unsigned char b_Resolution;
} str_AnalogOutputHeader; };
struct str_AnalogInputHeader { struct str_AnalogInputHeader {
unsigned short w_Nchannel; unsigned short w_Nchannel;
...@@ -136,7 +136,7 @@ int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress, ...@@ -136,7 +136,7 @@ int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress,
int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress, int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress,
char *pc_PCIChipInformation, unsigned short w_Address, char *pc_PCIChipInformation, unsigned short w_Address,
str_AnalogOutputHeader *s_Header); struct str_AnalogOutputHeader *s_Header);
int i_EepromReadAnlogInputHeader(unsigned short w_PCIBoardEepromAddress, int i_EepromReadAnlogInputHeader(unsigned short w_PCIBoardEepromAddress,
char *pc_PCIChipInformation, unsigned short w_Address, char *pc_PCIChipInformation, unsigned short w_Address,
...@@ -635,7 +635,7 @@ void v_EepromSendCommand76(unsigned int dw_Address, unsigned int dw_EepromComman ...@@ -635,7 +635,7 @@ void v_EepromSendCommand76(unsigned int dw_Address, unsigned int dw_EepromComman
| Input Parameters : unsigned int dw_Address : PCI eeprom base address | | Input Parameters : unsigned int dw_Address : PCI eeprom base address |
| unsigned short w_offset : Offset of the adress to read | | unsigned short w_offset : Offset of the address to read |
| unsigned short * pw_Value : PCI eeprom 16 bit read value. | | unsigned short * pw_Value : PCI eeprom 16 bit read value. |
...@@ -811,7 +811,7 @@ int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress, ...@@ -811,7 +811,7 @@ int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
struct str_DigitalInputHeader s_DigitalInputHeader; struct str_DigitalInputHeader s_DigitalInputHeader;
struct str_DigitalOutputHeader s_DigitalOutputHeader; struct str_DigitalOutputHeader s_DigitalOutputHeader;
/* struct str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader; */ /* struct str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader; */
str_AnalogOutputHeader s_AnalogOutputHeader; struct str_AnalogOutputHeader s_AnalogOutputHeader;
struct str_AnalogInputHeader s_AnalogInputHeader; struct str_AnalogInputHeader s_AnalogInputHeader;
/* Read size */ /* Read size */
...@@ -1081,7 +1081,7 @@ int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress, ...@@ -1081,7 +1081,7 @@ int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress,
int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress, int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress,
char *pc_PCIChipInformation, unsigned short w_Address, char *pc_PCIChipInformation, unsigned short w_Address,
str_AnalogOutputHeader *s_Header) struct str_AnalogOutputHeader *s_Header)
{ {
unsigned short w_Temp; unsigned short w_Temp;
/* No of channels for 1st hard component */ /* No of channels for 1st hard component */
......
...@@ -1090,13 +1090,13 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev, ...@@ -1090,13 +1090,13 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
* and put into into an array array used may be for differnet pages * and put into into an array array used may be for differnet pages
*/ */
/* DMA Start Adress Low */ /* DMA Start Address Low */
outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0); outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
outw((devpriv->ul_DmaBufferHw[0] & 0xFFFF), outw((devpriv->ul_DmaBufferHw[0] & 0xFFFF),
devpriv->i_IobaseAddon + 2); devpriv->i_IobaseAddon + 2);
/*************************/ /*************************/
/* DMA Start Adress High */ /* DMA Start Address High */
/*************************/ /*************************/
outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0); outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
outw((devpriv->ul_DmaBufferHw[0] / 65536), outw((devpriv->ul_DmaBufferHw[0] / 65536),
...@@ -1733,11 +1733,11 @@ void v_APCI3120_InterruptDma(int irq, void *d) ...@@ -1733,11 +1733,11 @@ void v_APCI3120_InterruptDma(int irq, void *d)
var = devpriv->ul_DmaBufferHw[next_dma_buf]; var = devpriv->ul_DmaBufferHw[next_dma_buf];
high_word = var / 65536; high_word = var / 65536;
/* DMA Start Adress Low */ /* DMA Start Address Low */
outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0); outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
outw(low_word, devpriv->i_IobaseAddon + 2); outw(low_word, devpriv->i_IobaseAddon + 2);
/* DMA Start Adress High */ /* DMA Start Address High */
outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0); outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2); outw(high_word, devpriv->i_IobaseAddon + 2);
......
...@@ -5,3 +5,7 @@ ...@@ -5,3 +5,7 @@
#define ADDIDATA_DRIVER_NAME "addi_apci_035" #define ADDIDATA_DRIVER_NAME "addi_apci_035"
#include "addi-data/addi_common.c" #include "addi-data/addi_common.c"
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
...@@ -3,3 +3,7 @@ ...@@ -3,3 +3,7 @@
#define ADDIDATA_DRIVER_NAME "addi_apci_1032" #define ADDIDATA_DRIVER_NAME "addi_apci_1032"
#include "addi-data/addi_common.c" #include "addi-data/addi_common.c"
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
...@@ -3,3 +3,7 @@ ...@@ -3,3 +3,7 @@
#define ADDIDATA_DRIVER_NAME "addi_apci_1500" #define ADDIDATA_DRIVER_NAME "addi_apci_1500"
#include "addi-data/addi_common.c" #include "addi-data/addi_common.c"
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
...@@ -3,3 +3,7 @@ ...@@ -3,3 +3,7 @@
#define ADDIDATA_DRIVER_NAME "addi_apci_1516" #define ADDIDATA_DRIVER_NAME "addi_apci_1516"
#include "addi-data/addi_common.c" #include "addi-data/addi_common.c"
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
...@@ -3,3 +3,7 @@ ...@@ -3,3 +3,7 @@
#define ADDIDATA_DRIVER_NAME "addi_apci_1564" #define ADDIDATA_DRIVER_NAME "addi_apci_1564"
#include "addi-data/addi_common.c" #include "addi-data/addi_common.c"
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
...@@ -3,3 +3,7 @@ ...@@ -3,3 +3,7 @@
#define ADDIDATA_DRIVER_NAME "addi_apci_16xx" #define ADDIDATA_DRIVER_NAME "addi_apci_16xx"
#include "addi-data/addi_common.c" #include "addi-data/addi_common.c"
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
...@@ -3,3 +3,7 @@ ...@@ -3,3 +3,7 @@
#define ADDIDATA_DRIVER_NAME "addi_apci_2016" #define ADDIDATA_DRIVER_NAME "addi_apci_2016"
#include "addi-data/addi_common.c" #include "addi-data/addi_common.c"
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册