You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Staging: Merge staging-next into Linus's tree
Conflicts: drivers/staging/Kconfig drivers/staging/batman-adv/bat_sysfs.c drivers/staging/batman-adv/device.c drivers/staging/batman-adv/hard-interface.c drivers/staging/cx25821/cx25821-audups11.c Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <asm/mshyperv.h>
|
||||
|
||||
struct ms_hyperv_info ms_hyperv;
|
||||
EXPORT_SYMBOL_GPL(ms_hyperv);
|
||||
|
||||
static bool __init ms_hyperv_platform(void)
|
||||
{
|
||||
|
||||
+11
-3
@@ -97,6 +97,8 @@ source "drivers/staging/octeon/Kconfig"
|
||||
|
||||
source "drivers/staging/serqt_usb2/Kconfig"
|
||||
|
||||
source "drivers/staging/spectra/Kconfig"
|
||||
|
||||
source "drivers/staging/quatech_usb2/Kconfig"
|
||||
|
||||
source "drivers/staging/vt6655/Kconfig"
|
||||
@@ -115,7 +117,7 @@ source "drivers/staging/sep/Kconfig"
|
||||
|
||||
source "drivers/staging/iio/Kconfig"
|
||||
|
||||
source "drivers/staging/ramzswap/Kconfig"
|
||||
source "drivers/staging/zram/Kconfig"
|
||||
|
||||
source "drivers/staging/wlags49_h2/Kconfig"
|
||||
|
||||
@@ -127,8 +129,6 @@ source "drivers/staging/samsung-laptop/Kconfig"
|
||||
|
||||
source "drivers/staging/sm7xx/Kconfig"
|
||||
|
||||
source "drivers/staging/dt3155/Kconfig"
|
||||
|
||||
source "drivers/staging/dt3155v4l/Kconfig"
|
||||
|
||||
source "drivers/staging/crystalhd/Kconfig"
|
||||
@@ -147,5 +147,13 @@ source "drivers/staging/msm/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
|
||||
|
||||
@@ -23,6 +23,7 @@ obj-$(CONFIG_R8187SE) += rtl8187se/
|
||||
obj-$(CONFIG_RTL8192SU) += rtl8192su/
|
||||
obj-$(CONFIG_RTL8192U) += rtl8192u/
|
||||
obj-$(CONFIG_RTL8192E) += rtl8192e/
|
||||
obj-$(CONFIG_SPECTRA) += spectra/
|
||||
obj-$(CONFIG_TRANZPORT) += frontier/
|
||||
obj-$(CONFIG_DREAM) += dream/
|
||||
obj-$(CONFIG_POHMELFS) += pohmelfs/
|
||||
@@ -39,13 +40,12 @@ obj-$(CONFIG_VME_BUS) += vme/
|
||||
obj-$(CONFIG_MRST_RAR_HANDLER) += memrar/
|
||||
obj-$(CONFIG_DX_SEP) += sep/
|
||||
obj-$(CONFIG_IIO) += iio/
|
||||
obj-$(CONFIG_RAMZSWAP) += ramzswap/
|
||||
obj-$(CONFIG_ZRAM) += zram/
|
||||
obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/
|
||||
obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/
|
||||
obj-$(CONFIG_BATMAN_ADV) += batman-adv/
|
||||
obj-$(CONFIG_SAMSUNG_LAPTOP) += samsung-laptop/
|
||||
obj-$(CONFIG_FB_SM7XX) += sm7xx/
|
||||
obj-$(CONFIG_DT3155) += dt3155/
|
||||
obj-$(CONFIG_VIDEO_DT3155) += dt3155v4l/
|
||||
obj-$(CONFIG_CRYSTALHD) += crystalhd/
|
||||
obj-$(CONFIG_CXT1E1) += cxt1e1/
|
||||
@@ -54,3 +54,7 @@ obj-$(CONFIG_ADIS16255) += adis16255/
|
||||
obj-$(CONFIG_FB_XGI) += xgifb/
|
||||
obj-$(CONFIG_TOUCHSCREEN_MRSTOUCH) += mrst-touchscreen/
|
||||
obj-$(CONFIG_MSM_STAGING) += msm/
|
||||
obj-$(CONFIG_EASYCAP) += easycap/
|
||||
obj-$(CONFIG_SOLO6X10) += solo6x10/
|
||||
obj-$(CONFIG_TIDSPBRIDGE) += tidspbridge/
|
||||
obj-$(CONFIG_ACPI_QUICKSTART) += quickstart/
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
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:
|
||||
|
||||
* support latest kernels (2.6.20 - 2.6.33)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
config BATMAN_ADV
|
||||
tristate "B.A.T.M.A.N. Advanced Meshing Protocol"
|
||||
depends on PROC_FS && NET
|
||||
depends on NET
|
||||
default n
|
||||
---help---
|
||||
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
# 02110-1301, USA
|
||||
#
|
||||
|
||||
obj-m += 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
|
||||
obj-$(CONFIG_BATMAN_ADV) += batman-adv.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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[state: 03-05-2010]
|
||||
[state: 12-06-2010]
|
||||
|
||||
BATMAN-ADV
|
||||
----------
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
Request a review.
|
||||
Process the comments from the review.
|
||||
Move into mainline proper.
|
||||
* Use hweight* for hamming weight calculation
|
||||
* Save/cache packets direktly as skb instead of using a normal memory region
|
||||
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:
|
||||
Marek Lindner <lindner_marek@yahoo.de>
|
||||
|
||||
@@ -106,11 +106,14 @@ static void new_aggregated_packet(unsigned char *packet_buff,
|
||||
{
|
||||
struct forw_packet *forw_packet_aggr;
|
||||
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 */
|
||||
if (!own_packet) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -252,9 +255,9 @@ void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
|
||||
while (aggregated_packet(buff_pos, packet_len,
|
||||
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. */
|
||||
batman_packet->seqno = ntohs(batman_packet->seqno);
|
||||
batman_packet->seqno = ntohl(batman_packet->seqno);
|
||||
|
||||
hna_buff = packet_buff + buff_pos + BAT_PACKET_LEN;
|
||||
receive_bat_packet(ethhdr, batman_packet,
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NET_BATMAN_ADV_AGGREGATION_H_
|
||||
#define _NET_BATMAN_ADV_AGGREGATION_H_
|
||||
|
||||
#include "main.h"
|
||||
|
||||
/* is there another aggregated packet here? */
|
||||
@@ -36,3 +39,5 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
|
||||
unsigned long send_time);
|
||||
void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
|
||||
int packet_len, struct batman_if *if_incoming);
|
||||
|
||||
#endif /* _NET_BATMAN_ADV_AGGREGATION_H_ */
|
||||
|
||||
@@ -0,0 +1,341 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 @@
|
||||
|
||||
#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) \
|
||||
struct bat_attribute bat_attr_##_name = { \
|
||||
.attr = {.name = __stringify(_name), \
|
||||
@@ -52,34 +36,18 @@ struct bat_attribute bat_attr_##_name = { \
|
||||
.store = _store, \
|
||||
};
|
||||
|
||||
#define BAT_BIN_ATTR(_name, _mode, _read, _write) \
|
||||
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,
|
||||
static ssize_t show_aggr_ogms(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 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");
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
struct device *dev = to_dev(kobj->parent);
|
||||
@@ -99,23 +67,73 @@ static ssize_t store_aggr_ogm(struct kobject *kobj, struct attribute *attr,
|
||||
if (buff[count - 1] == '\n')
|
||||
buff[count - 1] = '\0';
|
||||
|
||||
printk(KERN_INFO "batman-adv:Invalid parameter for 'aggregate OGM' setting on mesh %s received: %s\n",
|
||||
net_dev->name, buff);
|
||||
bat_info(net_dev,
|
||||
"Invalid parameter for 'aggregate OGM' setting"
|
||||
"received: %s\n", buff);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (atomic_read(&bat_priv->aggregation_enabled) == aggr_tmp)
|
||||
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 ?
|
||||
"enabled" : "disabled", aggr_tmp == 1 ? "enabled" : "disabled",
|
||||
net_dev->name);
|
||||
"enabled" : "disabled", aggr_tmp == 1 ? "enabled" :
|
||||
"disabled");
|
||||
|
||||
atomic_set(&bat_priv->aggregation_enabled, (unsigned)aggr_tmp);
|
||||
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,
|
||||
char *buff)
|
||||
{
|
||||
@@ -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));
|
||||
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 ?
|
||||
"client" : "server",
|
||||
VIS_TYPE_SERVER_SYNC, VIS_TYPE_CLIENT_UPDATE);
|
||||
"client" : "server");
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
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,
|
||||
if (buff[count - 1] == '\n')
|
||||
buff[count - 1] = '\0';
|
||||
|
||||
printk(KERN_INFO "batman-adv:Invalid parameter for 'vis mode' setting on mesh %s received: %s\n",
|
||||
net_dev->name, buff);
|
||||
bat_info(net_dev,
|
||||
"Invalid parameter for 'vis mode' setting received: "
|
||||
"%s\n", buff);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
|
||||
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 ?
|
||||
"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);
|
||||
return count;
|
||||
@@ -175,7 +194,7 @@ static ssize_t show_orig_interval(struct kobject *kobj, struct attribute *attr,
|
||||
struct device *dev = to_dev(kobj->parent);
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -190,91 +209,87 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr,
|
||||
|
||||
ret = strict_strtoul(buff, 10, &orig_interval_tmp);
|
||||
if (ret) {
|
||||
printk(KERN_INFO "batman-adv:Invalid parameter for 'orig_interval' setting on mesh %s received: %s\n",
|
||||
net_dev->name, buff);
|
||||
bat_info(net_dev, "Invalid parameter for 'orig_interval' "
|
||||
"setting received: %s\n", buff);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (orig_interval_tmp <= JITTER * 2) {
|
||||
printk(KERN_INFO "batman-adv:New originator interval too small: %li (min: %i)\n",
|
||||
orig_interval_tmp, JITTER * 2);
|
||||
if (orig_interval_tmp < JITTER * 2) {
|
||||
bat_info(net_dev, "New originator interval too small: %li "
|
||||
"(min: %i)\n", orig_interval_tmp, JITTER * 2);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (atomic_read(&bat_priv->orig_interval) == orig_interval_tmp)
|
||||
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),
|
||||
orig_interval_tmp, net_dev->name);
|
||||
orig_interval_tmp);
|
||||
|
||||
atomic_set(&bat_priv->orig_interval, orig_interval_tmp);
|
||||
return count;
|
||||
}
|
||||
|
||||
static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR,
|
||||
show_aggr_ogm, store_aggr_ogm);
|
||||
#ifdef CONFIG_BATMAN_ADV_DEBUG
|
||||
static ssize_t show_log_level(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 log_level = atomic_read(&bat_priv->log_level);
|
||||
|
||||
return sprintf(buff, "%d\n", log_level);
|
||||
}
|
||||
|
||||
static ssize_t store_log_level(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);
|
||||
unsigned long log_level_tmp;
|
||||
int ret;
|
||||
|
||||
ret = strict_strtoul(buff, 10, &log_level_tmp);
|
||||
if (ret) {
|
||||
bat_info(net_dev, "Invalid parameter for 'log_level' "
|
||||
"setting received: %s\n", buff);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (log_level_tmp > 3) {
|
||||
bat_info(net_dev, "New log level too big: %li "
|
||||
"(max: %i)\n", log_level_tmp, 3);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (atomic_read(&bat_priv->log_level) == log_level_tmp)
|
||||
return count;
|
||||
|
||||
atomic_set(&bat_priv->log_level, (unsigned)log_level_tmp);
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
static BAT_ATTR(aggregated_ogms, S_IRUGO | S_IWUSR,
|
||||
show_aggr_ogms, store_aggr_ogms);
|
||||
static BAT_ATTR(bonding, S_IRUGO | S_IWUSR, show_bond, store_bond);
|
||||
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 bat_attribute *mesh_attrs[] = {
|
||||
&bat_attr_aggregate_ogm,
|
||||
&bat_attr_aggregated_ogms,
|
||||
&bat_attr_bonding,
|
||||
&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 net_device *net_dev = to_net_dev(dev);
|
||||
|
||||
return hna_local_fill_buffer_text(net_dev, buff, count, off);
|
||||
}
|
||||
|
||||
static ssize_t transtable_global_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 net_device *net_dev = to_net_dev(dev);
|
||||
|
||||
return hna_global_fill_buffer_text(net_dev, buff, count, off);
|
||||
}
|
||||
|
||||
static ssize_t originators_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 net_device *net_dev = to_net_dev(dev);
|
||||
|
||||
return orig_fill_buffer_text(net_dev, buff, count, off);
|
||||
}
|
||||
|
||||
static ssize_t vis_data_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 net_device *net_dev = to_net_dev(dev);
|
||||
|
||||
return vis_fill_buffer_text(net_dev, buff, count, off);
|
||||
}
|
||||
|
||||
static BAT_BIN_ATTR(transtable_local, S_IRUGO, transtable_local_read, NULL);
|
||||
static BAT_BIN_ATTR(transtable_global, S_IRUGO, transtable_global_read, NULL);
|
||||
static BAT_BIN_ATTR(originators, S_IRUGO, originators_read, NULL);
|
||||
static BAT_BIN_ATTR(vis_data, S_IRUGO, vis_data_read, NULL);
|
||||
|
||||
static struct bin_attribute *mesh_bin_attrs[] = {
|
||||
&bat_attr_transtable_local,
|
||||
&bat_attr_transtable_global,
|
||||
&bat_attr_originators,
|
||||
&bat_attr_vis_data,
|
||||
#ifdef CONFIG_BATMAN_ADV_DEBUG
|
||||
&bat_attr_log_level,
|
||||
#endif
|
||||
NULL,
|
||||
};
|
||||
|
||||
@@ -283,22 +298,24 @@ int sysfs_add_meshif(struct net_device *dev)
|
||||
struct kobject *batif_kobject = &dev->dev.kobj;
|
||||
struct bat_priv *bat_priv = netdev_priv(dev);
|
||||
struct bat_attribute **bat_attr;
|
||||
struct bin_attribute **bin_attr;
|
||||
int err;
|
||||
|
||||
/* FIXME: should be done in the general mesh setup
|
||||
routine as soon as we have it */
|
||||
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->orig_interval, 1000);
|
||||
atomic_set(&bat_priv->log_level, 0);
|
||||
|
||||
bat_priv->primary_if = NULL;
|
||||
bat_priv->num_ifaces = 0;
|
||||
|
||||
bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR,
|
||||
batif_kobject);
|
||||
if (!bat_priv->mesh_obj) {
|
||||
printk(KERN_ERR "batman-adv:Can't add sysfs directory: %s/%s\n",
|
||||
dev->name, SYSFS_IF_MESH_SUBDIR);
|
||||
bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
|
||||
SYSFS_IF_MESH_SUBDIR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -306,28 +323,15 @@ int sysfs_add_meshif(struct net_device *dev)
|
||||
err = sysfs_create_file(bat_priv->mesh_obj,
|
||||
&((*bat_attr)->attr));
|
||||
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,
|
||||
((*bat_attr)->attr).name);
|
||||
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;
|
||||
|
||||
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:
|
||||
for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr)
|
||||
sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr));
|
||||
@@ -342,10 +346,6 @@ void sysfs_del_meshif(struct net_device *dev)
|
||||
{
|
||||
struct bat_priv *bat_priv = netdev_priv(dev);
|
||||
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)
|
||||
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,
|
||||
if (!batman_if)
|
||||
return 0;
|
||||
|
||||
return sprintf(buff, "status: %s\ncommands: none, bat0\n",
|
||||
return sprintf(buff, "%s\n",
|
||||
batman_if->if_status == IF_NOT_IN_USE ?
|
||||
"none" : "bat0");
|
||||
}
|
||||
@@ -390,8 +390,8 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
|
||||
if (buff[count - 1] == '\n')
|
||||
buff[count - 1] = '\0';
|
||||
|
||||
printk(KERN_ERR "batman-adv:Invalid parameter for 'mesh_iface' setting received: %s\n",
|
||||
buff);
|
||||
pr_err("Invalid parameter for 'mesh_iface' setting received: "
|
||||
"%s\n", buff);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
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[] = {
|
||||
&hardif_attr_mesh_iface,
|
||||
&hardif_attr_iface_status,
|
||||
static struct bat_attribute *batman_attrs[] = {
|
||||
&bat_attr_mesh_iface,
|
||||
&bat_attr_iface_status,
|
||||
NULL,
|
||||
};
|
||||
|
||||
int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
|
||||
{
|
||||
struct kobject *hardif_kobject = &dev->dev.kobj;
|
||||
struct hardif_attribute **hardif_attr;
|
||||
struct bat_attribute **bat_attr;
|
||||
int err;
|
||||
|
||||
*hardif_obj = kobject_create_and_add(SYSFS_IF_BAT_SUBDIR,
|
||||
hardif_kobject);
|
||||
|
||||
if (!*hardif_obj) {
|
||||
printk(KERN_ERR "batman-adv:Can't add sysfs directory: %s/%s\n",
|
||||
dev->name, SYSFS_IF_BAT_SUBDIR);
|
||||
bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
|
||||
SYSFS_IF_BAT_SUBDIR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (hardif_attr = batman_attrs; *hardif_attr; ++hardif_attr) {
|
||||
err = sysfs_create_file(*hardif_obj, &((*hardif_attr)->attr));
|
||||
for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) {
|
||||
err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr));
|
||||
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,
|
||||
((*hardif_attr)->attr).name);
|
||||
((*bat_attr)->attr).name);
|
||||
goto rem_attr;
|
||||
}
|
||||
}
|
||||
@@ -471,8 +471,8 @@ int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
|
||||
return 0;
|
||||
|
||||
rem_attr:
|
||||
for (hardif_attr = batman_attrs; *hardif_attr; ++hardif_attr)
|
||||
sysfs_remove_file(*hardif_obj, &((*hardif_attr)->attr));
|
||||
for (bat_attr = batman_attrs; *bat_attr; ++bat_attr)
|
||||
sysfs_remove_file(*hardif_obj, &((*bat_attr)->attr));
|
||||
out:
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -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_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);
|
||||
void sysfs_del_meshif(struct net_device *dev);
|
||||
int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev);
|
||||
void sysfs_del_hardif(struct kobject **hardif_obj);
|
||||
|
||||
#endif /* _NET_BATMAN_ADV_SYSFS_H_ */
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
|
||||
/* returns true if the corresponding bit in the given seq_bits indicates true
|
||||
* and curr_seqno is within range of last_seqno */
|
||||
uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint16_t last_seqno,
|
||||
uint16_t curr_seqno)
|
||||
uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno,
|
||||
uint32_t curr_seqno)
|
||||
{
|
||||
int16_t diff, word_offset, word_num;
|
||||
int32_t diff, word_offset, word_num;
|
||||
|
||||
diff = last_seqno - curr_seqno;
|
||||
if (diff < 0 || diff >= TQ_LOCAL_WINDOW_SIZE) {
|
||||
@@ -63,7 +63,7 @@ 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)
|
||||
static void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n)
|
||||
{
|
||||
int32_t word_offset, word_num;
|
||||
int32_t i;
|
||||
@@ -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)
|
||||
* 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)
|
||||
{
|
||||
/* 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
|
||||
* 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,
|
||||
|
||||
if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE)
|
||||
|| (seq_num_diff < EXPECTED_SEQNO_RANGE)) {
|
||||
bat_dbg(DBG_BATMAN,
|
||||
bat_dbg(DBG_BATMAN, bat_priv,
|
||||
"We missed a lot of packets (%i) !\n",
|
||||
seq_num_diff - 1);
|
||||
bit_reset_window(seq_bits);
|
||||
@@ -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)
|
||||
|| (seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
|
||||
|
||||
bat_dbg(DBG_BATMAN,
|
||||
bat_dbg(DBG_BATMAN, bat_priv,
|
||||
"Other host probably restarted!\n");
|
||||
|
||||
bit_reset_window(seq_bits);
|
||||
|
||||
@@ -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 */
|
||||
#define TYPE_OF_WORD unsigned long
|
||||
@@ -26,20 +28,19 @@
|
||||
|
||||
/* returns true if the corresponding bit in the given seq_bits indicates true
|
||||
* and curr_seqno is within range of last_seqno */
|
||||
uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint16_t last_seqno,
|
||||
uint16_t curr_seqno);
|
||||
uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno,
|
||||
uint32_t curr_seqno);
|
||||
|
||||
/* turn corresponding bit on, so we can remember that we got the packet */
|
||||
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
|
||||
* 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);
|
||||
|
||||
/* count the hamming weight, how many good packets did we receive? */
|
||||
int bit_packet_count(TYPE_OF_WORD *seq_bits);
|
||||
|
||||
#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */
|
||||
|
||||
@@ -1,354 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007-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 <linux/device.h>
|
||||
#include <linux/slab.h>
|
||||
#include "main.h"
|
||||
#include "device.h"
|
||||
#include "send.h"
|
||||
#include "types.h"
|
||||
#include "hash.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");
|
||||
|
||||
if (IS_ERR(batman_class)) {
|
||||
printk(KERN_ERR "batman-adv:"
|
||||
"Could not register class 'batman-adv'\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
device_create(batman_class, NULL, MKDEV(tmp_major, 0), NULL,
|
||||
"batman-adv");
|
||||
|
||||
Major = tmp_major;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void bat_device_destroy(void)
|
||||
{
|
||||
if (!Major)
|
||||
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)
|
||||
{
|
||||
unsigned int i;
|
||||
struct device_client *device_client;
|
||||
|
||||
device_client = kmalloc(sizeof(struct device_client), GFP_KERNEL);
|
||||
|
||||
if (!device_client)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(device_client_hash); i++) {
|
||||
if (!device_client_hash[i]) {
|
||||
device_client_hash[i] = device_client;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ARRAY_SIZE(device_client_hash)) {
|
||||
printk(KERN_ERR "batman-adv:"
|
||||
"Error - can't add another packet client: "
|
||||
"maximum number of clients reached\n");
|
||||
kfree(device_client);
|
||||
return -EXFULL;
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD(&device_client->queue_list);
|
||||
device_client->queue_len = 0;
|
||||
device_client->index = i;
|
||||
spin_lock_init(&device_client->lock);
|
||||
init_waitqueue_head(&device_client->queue_wait);
|
||||
|
||||
file->private_data = device_client;
|
||||
|
||||
inc_module_count();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bat_device_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct device_client *device_client =
|
||||
(struct device_client *)file->private_data;
|
||||
struct device_packet *device_packet;
|
||||
struct list_head *list_pos, *list_pos_tmp;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&device_client->lock, flags);
|
||||
|
||||
/* for all packets in the queue ... */
|
||||
list_for_each_safe(list_pos, list_pos_tmp, &device_client->queue_list) {
|
||||
device_packet = list_entry(list_pos,
|
||||
struct device_packet, list);
|
||||
|
||||
list_del(list_pos);
|
||||
kfree(device_packet);
|
||||
}
|
||||
|
||||
device_client_hash[device_client->index] = NULL;
|
||||
spin_unlock_irqrestore(&device_client->lock, flags);
|
||||
|
||||
kfree(device_client);
|
||||
dec_module_count();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t bat_device_read(struct file *file, char __user *buf, size_t count,
|
||||
loff_t *ppos)
|
||||
{
|
||||
struct device_client *device_client =
|
||||
(struct device_client *)file->private_data;
|
||||
struct device_packet *device_packet;
|
||||
int error;
|
||||
unsigned long flags;
|
||||
|
||||
if ((file->f_flags & O_NONBLOCK) && (device_client->queue_len == 0))
|
||||
return -EAGAIN;
|
||||
|
||||
if ((!buf) || (count < sizeof(struct icmp_packet)))
|
||||
return -EINVAL;
|
||||
|
||||
if (!access_ok(VERIFY_WRITE, buf, count))
|
||||
return -EFAULT;
|
||||
|
||||
error = wait_event_interruptible(device_client->queue_wait,
|
||||
device_client->queue_len);
|
||||
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
spin_lock_irqsave(&device_client->lock, flags);
|
||||
|
||||
device_packet = list_first_entry(&device_client->queue_list,
|
||||
struct device_packet, list);
|
||||
list_del(&device_packet->list);
|
||||
device_client->queue_len--;
|
||||
|
||||
spin_unlock_irqrestore(&device_client->lock, flags);
|
||||
|
||||
error = __copy_to_user(buf, &device_packet->icmp_packet,
|
||||
sizeof(struct icmp_packet));
|
||||
|
||||
kfree(device_packet);
|
||||
|
||||
if (error)
|
||||
return -EFAULT;
|
||||
|
||||
return sizeof(struct icmp_packet);
|
||||
}
|
||||
|
||||
ssize_t bat_device_write(struct file *file, const char __user *buff,
|
||||
size_t len, loff_t *off)
|
||||
{
|
||||
struct device_client *device_client =
|
||||
(struct device_client *)file->private_data;
|
||||
struct icmp_packet icmp_packet;
|
||||
struct orig_node *orig_node;
|
||||
struct batman_if *batman_if;
|
||||
uint8_t dstaddr[ETH_ALEN];
|
||||
unsigned long flags;
|
||||
|
||||
if (len < sizeof(struct icmp_packet)) {
|
||||
bat_dbg(DBG_BATMAN, "batman-adv:"
|
||||
"Error - can't send packet from char device: "
|
||||
"invalid packet size\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!access_ok(VERIFY_READ, buff, sizeof(struct icmp_packet)))
|
||||
return -EFAULT;
|
||||
|
||||
if (__copy_from_user(&icmp_packet, buff, sizeof(icmp_packet)))
|
||||
return -EFAULT;
|
||||
|
||||
if (icmp_packet.packet_type != BAT_ICMP) {
|
||||
bat_dbg(DBG_BATMAN, "batman-adv:"
|
||||
"Error - can't send packet from char device: "
|
||||
"got bogus packet type (expected: BAT_ICMP)\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (icmp_packet.msg_type != ECHO_REQUEST) {
|
||||
bat_dbg(DBG_BATMAN, "batman-adv:"
|
||||
"Error - can't send packet from char device: "
|
||||
"got bogus message type (expected: ECHO_REQUEST)\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
icmp_packet.uid = device_client->index;
|
||||
|
||||
if (icmp_packet.version != COMPAT_VERSION) {
|
||||
icmp_packet.msg_type = PARAMETER_PROBLEM;
|
||||
icmp_packet.ttl = COMPAT_VERSION;
|
||||
bat_device_add_packet(device_client, &icmp_packet);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (atomic_read(&module_state) != MODULE_ACTIVE)
|
||||
goto dst_unreach;
|
||||
|
||||
spin_lock_irqsave(&orig_hash_lock, flags);
|
||||
orig_node = ((struct orig_node *)hash_find(orig_hash, icmp_packet.dst));
|
||||
|
||||
if (!orig_node)
|
||||
goto unlock;
|
||||
|
||||
if (!orig_node->router)
|
||||
goto unlock;
|
||||
|
||||
batman_if = orig_node->router->if_incoming;
|
||||
memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
|
||||
|
||||
spin_unlock_irqrestore(&orig_hash_lock, flags);
|
||||
|
||||
if (!batman_if)
|
||||
goto dst_unreach;
|
||||
|
||||
if (batman_if->if_status != IF_ACTIVE)
|
||||
goto dst_unreach;
|
||||
|
||||
memcpy(icmp_packet.orig,
|
||||
batman_if->net_dev->dev_addr,
|
||||
ETH_ALEN);
|
||||
|
||||
send_raw_packet((unsigned char *)&icmp_packet,
|
||||
sizeof(struct icmp_packet),
|
||||
batman_if, dstaddr);
|
||||
|
||||
goto out;
|
||||
|
||||
unlock:
|
||||
spin_unlock_irqrestore(&orig_hash_lock, flags);
|
||||
dst_unreach:
|
||||
icmp_packet.msg_type = DESTINATION_UNREACHABLE;
|
||||
bat_device_add_packet(device_client, &icmp_packet);
|
||||
out:
|
||||
return len;
|
||||
}
|
||||
|
||||
unsigned int bat_device_poll(struct file *file, poll_table *wait)
|
||||
{
|
||||
struct device_client *device_client =
|
||||
(struct device_client *)file->private_data;
|
||||
|
||||
poll_wait(file, &device_client->queue_wait, wait);
|
||||
|
||||
if (device_client->queue_len > 0)
|
||||
return POLLIN | POLLRDNORM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bat_device_add_packet(struct device_client *device_client,
|
||||
struct icmp_packet *icmp_packet)
|
||||
{
|
||||
struct device_packet *device_packet;
|
||||
unsigned long flags;
|
||||
|
||||
device_packet = kmalloc(sizeof(struct device_packet), GFP_ATOMIC);
|
||||
|
||||
if (!device_packet)
|
||||
return;
|
||||
|
||||
INIT_LIST_HEAD(&device_packet->list);
|
||||
memcpy(&device_packet->icmp_packet, icmp_packet,
|
||||
sizeof(struct icmp_packet));
|
||||
|
||||
spin_lock_irqsave(&device_client->lock, flags);
|
||||
|
||||
/* while waiting for the lock the device_client could have been
|
||||
* deleted */
|
||||
if (!device_client_hash[icmp_packet->uid]) {
|
||||
spin_unlock_irqrestore(&device_client->lock, flags);
|
||||
kfree(device_packet);
|
||||
return;
|
||||
}
|
||||
|
||||
list_add_tail(&device_packet->list, &device_client->queue_list);
|
||||
device_client->queue_len++;
|
||||
|
||||
if (device_client->queue_len > 100) {
|
||||
device_packet = list_first_entry(&device_client->queue_list,
|
||||
struct device_packet, list);
|
||||
|
||||
list_del(&device_packet->list);
|
||||
kfree(device_packet);
|
||||
device_client->queue_len--;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&device_client->lock, flags);
|
||||
|
||||
wake_up(&device_client->queue_wait);
|
||||
}
|
||||
|
||||
void bat_device_receive_packet(struct icmp_packet *icmp_packet)
|
||||
{
|
||||
struct device_client *hash = device_client_hash[icmp_packet->uid];
|
||||
|
||||
if (hash)
|
||||
bat_device_add_packet(hash, icmp_packet);
|
||||
}
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "hash.h"
|
||||
|
||||
#include <linux/if_arp.h>
|
||||
#include <linux/netfilter_bridge.h>
|
||||
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
@@ -108,7 +109,7 @@ static void set_primary_if(struct bat_priv *bat_priv,
|
||||
set_main_if_addr(batman_if->net_dev->dev_addr);
|
||||
|
||||
batman_packet = (struct batman_packet *)(batman_if->packet_buff);
|
||||
batman_packet->flags = 0;
|
||||
batman_packet->flags = PRIMARIES_FIRST_HOP;
|
||||
batman_packet->ttl = TTL;
|
||||
|
||||
/***
|
||||
@@ -149,12 +150,10 @@ static void check_known_mac_addr(uint8_t *addr)
|
||||
if (!compare_orig(batman_if->net_dev->dev_addr, addr))
|
||||
continue;
|
||||
|
||||
printk(KERN_WARNING "batman-adv:"
|
||||
"The newly added mac address (%pM) already exists on: %s\n",
|
||||
addr, batman_if->dev);
|
||||
printk(KERN_WARNING "batman-adv:"
|
||||
"It is strongly recommended to keep mac addresses unique"
|
||||
"to avoid problems!\n");
|
||||
pr_warning("The newly added mac address (%pM) already exists "
|
||||
"on: %s\n", addr, batman_if->dev);
|
||||
pr_warning("It is strongly recommended to keep mac addresses "
|
||||
"unique to avoid problems!\n");
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
@@ -188,7 +187,8 @@ void update_min_mtu(void)
|
||||
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)
|
||||
{
|
||||
if (batman_if->if_status != IF_INACTIVE)
|
||||
@@ -206,8 +206,7 @@ static void hardif_activate_interface(struct bat_priv *bat_priv,
|
||||
if (!bat_priv->primary_if)
|
||||
set_primary_if(bat_priv, batman_if);
|
||||
|
||||
printk(KERN_INFO "batman-adv:Interface activated: %s\n",
|
||||
batman_if->dev);
|
||||
bat_info(net_dev, "Interface activated: %s\n", batman_if->dev);
|
||||
|
||||
if (atomic_read(&module_state) == MODULE_INACTIVE)
|
||||
activate_module();
|
||||
@@ -216,7 +215,8 @@ static void hardif_activate_interface(struct bat_priv *bat_priv,
|
||||
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) &&
|
||||
(batman_if->if_status != IF_TO_BE_ACTIVATED))
|
||||
@@ -226,8 +226,7 @@ static void hardif_deactivate_interface(struct batman_if *batman_if)
|
||||
|
||||
batman_if->if_status = IF_INACTIVE;
|
||||
|
||||
printk(KERN_INFO "batman-adv:Interface deactivated: %s\n",
|
||||
batman_if->dev);
|
||||
bat_info(net_dev, "Interface deactivated: %s\n", batman_if->dev);
|
||||
|
||||
update_min_mtu();
|
||||
}
|
||||
@@ -245,9 +244,8 @@ int hardif_enable_interface(struct batman_if *batman_if)
|
||||
batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);
|
||||
|
||||
if (!batman_if->packet_buff) {
|
||||
printk(KERN_ERR "batman-adv:"
|
||||
"Can't add interface packet (%s): out of memory\n",
|
||||
batman_if->dev);
|
||||
bat_err(soft_device, "Can't add interface packet (%s): "
|
||||
"out of memory\n", batman_if->dev);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -265,13 +263,12 @@ int hardif_enable_interface(struct batman_if *batman_if)
|
||||
orig_hash_add_if(batman_if, bat_priv->num_ifaces);
|
||||
|
||||
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))
|
||||
hardif_activate_interface(bat_priv, batman_if);
|
||||
hardif_activate_interface(soft_device, bat_priv, batman_if);
|
||||
else
|
||||
printk(KERN_ERR "batman-adv:"
|
||||
"Not using interface %s "
|
||||
bat_err(soft_device, "Not using interface %s "
|
||||
"(retrying later): interface not active\n",
|
||||
batman_if->dev);
|
||||
|
||||
@@ -291,12 +288,12 @@ void hardif_disable_interface(struct batman_if *batman_if)
|
||||
struct bat_priv *bat_priv = netdev_priv(soft_device);
|
||||
|
||||
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)
|
||||
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--;
|
||||
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)
|
||||
|
||||
batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
|
||||
if (!batman_if) {
|
||||
printk(KERN_ERR "batman-adv:"
|
||||
"Can't add interface (%s): out of memory\n",
|
||||
pr_err("Can't add interface (%s): out of memory\n",
|
||||
net_dev->name);
|
||||
goto out;
|
||||
}
|
||||
@@ -407,11 +403,11 @@ static int hard_if_event(struct notifier_block *this,
|
||||
case NETDEV_REGISTER:
|
||||
break;
|
||||
case NETDEV_UP:
|
||||
hardif_activate_interface(bat_priv, batman_if);
|
||||
hardif_activate_interface(soft_device, bat_priv, batman_if);
|
||||
break;
|
||||
case NETDEV_GOING_DOWN:
|
||||
case NETDEV_DOWN:
|
||||
hardif_deactivate_interface(batman_if);
|
||||
hardif_deactivate_interface(soft_device, batman_if);
|
||||
break;
|
||||
case NETDEV_UNREGISTER:
|
||||
hardif_remove_interface(batman_if);
|
||||
@@ -432,11 +428,18 @@ out:
|
||||
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
|
||||
* interface */
|
||||
int batman_skb_recv(struct sk_buff *skb, struct net_device *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_if *batman_if;
|
||||
struct net_device_stats *stats;
|
||||
@@ -452,6 +455,13 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
|
||||
if (atomic_read(&module_state) != MODULE_ACTIVE)
|
||||
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 */
|
||||
if (unlikely(skb_headlen(skb) < 2))
|
||||
goto err_free;
|
||||
@@ -478,7 +488,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
|
||||
batman_packet = (struct batman_packet *)skb->data;
|
||||
|
||||
if (batman_packet->version != COMPAT_VERSION) {
|
||||
bat_dbg(DBG_BATMAN,
|
||||
bat_dbg(DBG_BATMAN, bat_priv,
|
||||
"Drop packet: incompatible batman version (%i)\n",
|
||||
batman_packet->version);
|
||||
goto err_free;
|
||||
@@ -500,7 +510,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
|
||||
|
||||
/* unicast packet */
|
||||
case BAT_UNICAST:
|
||||
ret = recv_unicast_packet(skb);
|
||||
ret = recv_unicast_packet(skb, batman_if);
|
||||
break;
|
||||
|
||||
/* broadcast packet */
|
||||
@@ -531,7 +541,6 @@ err_out:
|
||||
return NET_RX_DROP;
|
||||
}
|
||||
|
||||
|
||||
struct notifier_block hard_if_notifier = {
|
||||
.notifier_call = hard_if_event,
|
||||
};
|
||||
|
||||
@@ -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_TO_BE_REMOVED 1
|
||||
#define IF_INACTIVE 2
|
||||
@@ -38,3 +41,5 @@ int batman_skb_recv(struct sk_buff *skb,
|
||||
struct net_device *orig_dev);
|
||||
int hardif_min_mtu(void);
|
||||
void update_min_mtu(void);
|
||||
|
||||
#endif /* _NET_BATMAN_ADV_HARD_INTERFACE_H_ */
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "hash.h"
|
||||
|
||||
/* clears the hash */
|
||||
void hash_init(struct hashtable_t *hash)
|
||||
static void hash_init(struct hashtable_t *hash)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user