Staging: batman-adv
cover Staging: batman-adv
Hi,
we've tried to fix the outstanding problem regarding the sysfs filesystem and fixed some further smaller problems. I hope that it is right were we put the ABI documentation.
Linus Lüssing (1):
Staging: batman-adv: Adding netfilter-bridge hooks
Marek Lindner (4):
Staging: batman-adv: remove redundant struct declaration
Staging: batman-adv: fix rogue packets on shutdown
Staging: batman-adv: convert all sysfs files to single value files
Documentation: ABI: Add information about batman-adv sysfs entries
Sven Eckelmann (5):
Staging: batman-adv: Call unregister_netdev on failures to get rtnl lock
Staging: batman-adv: Don't call free_netdev twice
Staging: batman-adv: Move device for icmp injection to debugfs
Staging: batman-adv: Move tables from sysfs to debugfs
Staging: batman-adv: Don't allocate icmp packet with GFP_KERNEL
Best regards,
Sven
PATCH 1/10 Staging: batman-adv: remove redundant struct declaration
From: Marek Lindner <[email protected]>
The hardif_attr and the bat_attr struct share the same attributes, hence it is not necessary to specify 2 different structs.
--- drivers/staging/batman-adv/bat_sysfs.c | 48 ++++++++------------------------ drivers/staging/batman-adv/bat_sysfs.h | 13 ++++++++ 2 files changed, 25 insertions(+), 36 deletions(-)
drivers/staging/batman-adv/bat_sysfs.c +12 -36
@@ -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), \
@@ -60,14 +44,6 @@ struct bin_attribute bat_attr_##_name = { \ .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) {
@@ -433,20 +409,20 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr, } } -static HARDIF_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(mesh_iface, S_IRUGO | S_IWUSR, + show_mesh_iface, store_mesh_iface); +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,
@@ -458,12 +434,12 @@ int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) 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" , dev->name,SYSFS_IF_BAT_SUBDIR , - ((*hardif_attr)->attr).name); + ((*bat_attr)->attr).name); goto rem_attr; } }
@@ -471,8 +447,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 ; }
drivers/staging/batman-adv/bat_sysfs.h +13 -0
@@ -20,10 +20,23 @@*/ +#ifndef BAT_SYSFS_H +#define BAT_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
Signature · 1 line
1.7.1
PATCH 2/10 Staging: batman-adv: fix rogue packets on shutdown
In reply to Sven EckelmannFrom: Marek Lindner <[email protected]>
On module shutdown batman-adv would purge the internal packet queue by sending all remaining packets which could confuse other nodes. Now, the packets are silently discarded.
--- drivers/staging/batman-adv/send.c | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-)
drivers/staging/batman-adv/send.c +15 -9
@@ -440,6 +440,9 @@ void send_outstanding_bcast_packet(struct work_struct *work)hlist_del (&forw_packet->list);spin_unlock_irqrestore (&forw_bcast_list_lock, flags); +if (atomic_read (&module_state) ==MODULE_DEACTIVATING ) + goto out; +/* rebroadcast packet */ rcu_read_lock ();list_for_each_entry_rcu (batman_if, &if_list, list) {
@@ -453,15 +456,15 @@ void send_outstanding_bcast_packet(struct work_struct *work) forw_packet->num_packets++; -/* if we still have some more bcasts to send and we are not shutting -* down */ -if ((forw_packet->num_packets <3 ) && - (atomic_read (&module_state) !=MODULE_DEACTIVATING )) +/* if we still have some more bcasts to send */ +if (forw_packet->num_packets <3 ) {_add_bcast_packet_to_list (forw_packet, ((5 *HZ ) /1000 )); -else { -forw_packet_free (forw_packet); -atomic_inc (&bcast_queue_left); +return ; } + +out: +forw_packet_free (forw_packet); +atomic_inc (&bcast_queue_left); }void send_outstanding_bat_packet (struct work_struct *work)
@@ -476,6 +479,9 @@ void send_outstanding_bat_packet(struct work_struct *work)hlist_del (&forw_packet->list);spin_unlock_irqrestore (&forw_bat_list_lock, flags); +if (atomic_read (&module_state) ==MODULE_DEACTIVATING ) + goto out; +send_packet (forw_packet);/**
@@ -483,10 +489,10 @@ void send_outstanding_bat_packet(struct work_struct *work)* to determine the queues wake up time unless we are * shutting down */ -if ((forw_packet->own) && - (atomic_read (&module_state) !=MODULE_DEACTIVATING )) +if (forw_packet->own)schedule_own_packet (forw_packet->if_incoming); +out:/* don't count own packet */ if (!forw_packet->own)atomic_inc (&batman_queue_left);
Signature · 1 line
1.7.1
PATCH 3/10 Staging: batman-adv: Call unregister_netdev on failures to get rtnl lock
In reply to Sven EckelmannWe must call unregister_netdev when we couldn't initialise the batman-adv module and the soft_device was registered. There are two version of the function which we can use:
* unregister_netdevice - removes device
* unregister_netdev - takes rtnl semaphore and remove device
We don't hold the semaphore in an error situation. So we must use unregister_netdev.
--- drivers/staging/batman-adv/main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/batman-adv/main.c +1 -1
@@ -127,7 +127,7 @@ int init_module(void)return 0 ; unreg_soft_device: -unregister_netdevice (soft_device); +unregister_netdev (soft_device); free_soft_device:free_netdev (soft_device); soft_device =NULL ;
Signature · 1 line
1.7.1
PATCH 4/10 Staging: batman-adv: Don't call free_netdev twice
In reply to Sven EckelmannFree_netdev is registered as destructor in interface_setup for every soft_device. This destructor is automatically called from unregister_netdev and we must not call it again for the freed net_device.
--- drivers/staging/batman-adv/main.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/staging/batman-adv/main.c +3 -0
@@ -128,6 +128,9 @@ int init_module(void) unreg_soft_device:unregister_netdev (soft_device); + soft_device =NULL ; +return -ENOMEM ; + free_soft_device:free_netdev (soft_device); soft_device =NULL ;
Signature · 1 line
1.7.1
PATCH 5/10 Staging: batman-adv: Move device for icmp injection to debugfs
In reply to Sven Eckelmannbatctl uses /dev/batman-adv to send special batman-adv icmp packets to other nodes in the mesh. To get it working with multiple batX devices we must ensure that every mesh device can have their own socket which is used to inject those packets in exactly one mesh.
The current implementation still doesn't allow to use complete separated meshes as we rely on structures which are not part of the private data of a batman device.
--- drivers/staging/batman-adv/Makefile | 2 +- drivers/staging/batman-adv/bat_debugfs.c | 77 +++++++ drivers/staging/batman-adv/bat_debugfs.h | 33 +++ drivers/staging/batman-adv/device.c | 354 ------------------------------ drivers/staging/batman-adv/device.h | 36 --- drivers/staging/batman-adv/icmp_socket.c | 328 +++++++++++++++++++++++++++ drivers/staging/batman-adv/icmp_socket.h | 28 +++ drivers/staging/batman-adv/main.c | 21 ++- drivers/staging/batman-adv/routing.c | 4 +- drivers/staging/batman-adv/types.h | 5 +- 10 files changed, 486 insertions(+), 402 deletions(-) create mode 100644 drivers/staging/batman-adv/bat_debugfs.c create mode 100644 drivers/staging/batman-adv/bat_debugfs.h delete mode 100644 drivers/staging/batman-adv/device.c delete mode 100644 drivers/staging/batman-adv/device.h create mode 100644 drivers/staging/batman-adv/icmp_socket.c create mode 100644 drivers/staging/batman-adv/icmp_socket.h
drivers/staging/batman-adv/Makefile +1 -1
@@ -19,4 +19,4 @@ # 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 +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
drivers/staging/batman-adv/bat_debugfs.c new file +77 -0
77 lines not on this page · raw message
drivers/staging/batman-adv/bat_debugfs.h new file +33 -0
@@ -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 BAT_DEBUGFS_H +#define BAT_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
drivers/staging/batman-adv/device.c deleted +0 -354
354 lines not on this page · raw message
drivers/staging/batman-adv/device.h deleted +0 -36
@@ -1,36 +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 "types.h" - -void bat_device_init (void ); -int bat_device_setup (void ); -void bat_device_destroy (void ); -int bat_device_open (struct inode *inode,struct file *file); -int bat_device_release (struct inode *inode,struct file *file); -ssize_t bat_device_read (struct file *file,char __user *buf,size_t count, -loff_t *ppos); -ssize_t bat_device_write (struct file *file,const char __user *buff, -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);
drivers/staging/batman-adv/icmp_socket.c new file +328 -0
328 lines not on this page · raw message
drivers/staging/batman-adv/icmp_socket.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* 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 "types.h" + +#define ICMP_SOCKET "socket" + +void bat_socket_init (void ); +int bat_socket_setup (struct bat_priv *bat_priv); +void bat_socket_receive_packet (struct icmp_packet *icmp_packet);
drivers/staging/batman-adv/main.c +14 -7
@@ -21,11 +21,12 @@#include "main.h" #include "bat_sysfs.h" +#include "bat_debugfs.h" #include "routing.h" #include "send.h" #include "originator.h" #include "soft-interface.h" -#include "device.h" +#include "icmp_socket.h" #include "translation-table.h" #include "hard-interface.h" #include "types.h"
@@ -92,7 +93,8 @@ int init_module(void)if (!bat_event_workqueue)return -ENOMEM ; -bat_device_init (); +bat_socket_init (); +debugfs_init ();/* initialize layer 2 interface */ soft_device = alloc_netdev(sizeof(struct bat_priv) , "bat%d",
@@ -117,6 +119,11 @@ int init_module(void)if (retval <0 ) goto unreg_soft_device; + retval =debugfs_add_meshif (soft_device); + +if (retval <0 ) + goto unreg_sysfs; +register_netdevice_notifier (&hard_if_notifier);dev_add_pack (&batman_adv_packet_type);
@@ -126,6 +133,8 @@ int init_module(void)return 0 ; +unreg_sysfs: +sysfs_del_meshif (soft_device); unreg_soft_device:unregister_netdev (soft_device); soft_device =NULL ;
@@ -146,6 +155,7 @@ void cleanup_module(void)hardif_remove_interfaces ();if (soft_device) { +debugfs_del_meshif (soft_device);sysfs_del_meshif (soft_device);unregister_netdev (soft_device); soft_device =NULL ;
@@ -157,7 +167,7 @@ void cleanup_module(void) bat_event_workqueue =NULL ; } -/* activates the module, creates bat device, starts timer ... */ +/* activates the module, starts timer ... */ void activate_module (void ) {if (originator_init () <1 )
@@ -171,9 +181,6 @@ void activate_module(void)hna_local_add (soft_device->dev_addr); -if (bat_device_setup () <1 ) - goto end; -if (vis_init () <1 ) goto err;
@@ -208,7 +215,7 @@ void deactivate_module(void)hna_global_free ();synchronize_net (); -bat_device_destroy (); +debugfs_destroy ();synchronize_rcu ();atomic_set (&module_state,MODULE_INACTIVE );
drivers/staging/batman-adv/routing.c +2 -2
@@ -25,7 +25,7 @@#include "hash.h" #include "soft-interface.h" #include "hard-interface.h" -#include "device.h" +#include "icmp_socket.h" #include "translation-table.h" #include "originator.h" #include "types.h"
@@ -668,7 +668,7 @@ static int recv_my_icmp_packet(struct sk_buff *skb)/* add data to device queue */ if (icmp_packet->msg_type !=ECHO_REQUEST ) { -bat_device_receive_packet (icmp_packet); +bat_socket_receive_packet (icmp_packet);return NET_RX_DROP ; }
drivers/staging/batman-adv/types.h +3 -2
@@ -106,9 +106,10 @@ struct bat_priv {char num_ifaces;struct batman_if *primary_if;struct kobject *mesh_obj; +struct dentry *debug_dir; }; -struct device_client { +struct socket_client {struct list_head queue_list;unsigned int queue_len;unsigned char index;
@@ -116,7 +117,7 @@ struct device_client {wait_queue_head_t queue_wait; }; -struct device_packet { +struct socket_packet {struct list_head list;struct icmp_packet icmp_packet; };
Signature · 1 line
1.7.1
PATCH 6/10 Staging: batman-adv: Move tables from sysfs to debugfs
In reply to Sven EckelmannFiles which represent more than a single attribute aren't allowed in sysfs. As we have some files which aren't essential and are lists or tables aggregated from data from different places inside batman-adv, we must place them in a filesystem without such a restriction.
--- drivers/staging/batman-adv/bat_debugfs.c | 71 +++++++++++ drivers/staging/batman-adv/bat_sysfs.c | 79 ------------ drivers/staging/batman-adv/main.h | 3 +- drivers/staging/batman-adv/originator.c | 64 +++------- drivers/staging/batman-adv/originator.h | 3 +- drivers/staging/batman-adv/translation-table.c | 153 ++++++++++++------------ drivers/staging/batman-adv/translation-table.h | 6 +- drivers/staging/batman-adv/vis.c | 111 ++++++++++++----- drivers/staging/batman-adv/vis.h | 3 +- 9 files changed, 253 insertions(+), 240 deletions(-)
drivers/staging/batman-adv/bat_debugfs.c +71 -0
@@ -31,6 +31,60 @@static struct dentry *bat_debugfs; +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 );
@@ -47,6 +101,8 @@ void debugfs_destroy(void)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;
@@ -57,7 +113,22 @@ int debugfs_add_meshif(struct net_device *dev)bat_socket_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) { +printk (KERN_ERR "batman-adv: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 ;
drivers/staging/batman-adv/bat_sysfs.c +0 -79
110 lines not on this page · raw message
drivers/staging/batman-adv/main.h +2 -1
@@ -70,7 +70,7 @@#define MODULE_ACTIVE 1#define MODULE_DEACTIVATING 2 -#define BCAST_QUEUE_LEN 256 +#define BCAST_QUEUE_LEN 256#define BATMAN_QUEUE_LEN 256/*
@@ -117,6 +117,7 @@ extern int bat_debug_type(int type);#include <linux/slab.h> #include <net/sock.h> /* struct sock */ #include <linux/jiffies.h> +#include <linux/seq_file.h> #include "types.h" #ifndef REVISION_VERSION
drivers/staging/batman-adv/originator.c +19 -45
111 lines not on this page · raw message
drivers/staging/batman-adv/originator.h +1 -2
@@ -28,7 +28,6 @@ struct orig_node *get_orig_node(uint8_t *addr);struct neigh_node *create_neighbor (struct orig_node *orig_node,struct orig_node *orig_neigh_node,uint8_t *neigh,struct batman_if *if_incoming); -ssize_t orig_fill_buffer_text (struct net_device *net_dev,char *buff, -size_t count,loff_t off); +int orig_seq_print_text (struct seq_file *seq,void *offset);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);
drivers/staging/batman-adv/translation-table.c +77 -76
201 lines not on this page · raw message
drivers/staging/batman-adv/translation-table.h +2 -4
@@ -25,15 +25,13 @@ int hna_local_init(void);void hna_local_add (uint8_t *addr);void hna_local_remove (uint8_t *addr,char *message);int hna_local_fill_buffer (unsigned char *buff,int buff_len); -int hna_local_fill_buffer_text (struct net_device *net_dev,char *buff, -size_t count,loff_t off); +int hna_local_seq_print_text (struct seq_file *seq,void *offset);void hna_local_purge (struct work_struct *work);void hna_local_free (void );int hna_global_init (void );void hna_global_add_orig (struct orig_node *orig_node,unsigned char *hna_buff,int hna_buff_len); -int hna_global_fill_buffer_text (struct net_device *net_dev,char *buff, -size_t count,loff_t off); +int hna_global_seq_print_text (struct seq_file *seq,void *offset);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);
drivers/staging/batman-adv/vis.c +80 -31
176 lines not on this page · raw message
drivers/staging/batman-adv/vis.h +1 -2
@@ -47,8 +47,7 @@ struct recvlist_node {extern struct hashtable_t *vis_hash;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); +int vis_seq_print_text (struct seq_file *seq,void *offset);void receive_server_sync_packet (struct bat_priv *bat_priv,struct vis_packet *vis_packet,int vis_info_len);
Signature · 1 line
1.7.1
PATCH 7/10 Staging: batman-adv: Don't allocate icmp packet with GFP_KERNEL
In reply to Sven EckelmannA new buffer for a packet is created when a icmp packet is received. This happens in a context with disabled irq. Thus we are not allowed to sleep or call function which might sleep. kmalloc must be called with GFP_ATOMIC instead of GFP_KERNEL to ensure that it does not sleep.
--- drivers/staging/batman-adv/icmp_socket.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/batman-adv/icmp_socket.c +1 -1
@@ -283,7 +283,7 @@ static void bat_socket_add_packet(struct socket_client *socket_client,struct socket_packet *socket_packet;unsigned long flags; - socket_packet =kmalloc (sizeof (struct socket_packet ),GFP_KERNEL ); + socket_packet =kmalloc (sizeof (struct socket_packet ),GFP_ATOMIC );if (!socket_packet)return ;
Signature · 1 line
1.7.1
PATCH 8/10 Staging: batman-adv: convert all sysfs files to single value files
In reply to Sven EckelmannFrom: Marek Lindner <[email protected]>
This patch removes the extra usage output which came when the sysfs files were read.
--- drivers/staging/batman-adv/bat_sysfs.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
drivers/staging/batman-adv/bat_sysfs.c +12 -12
@@ -36,18 +36,18 @@ struct bat_attribute bat_attr_##_name = { \ .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);
@@ -91,10 +91,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,
@@ -109,7 +108,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)) ||
@@ -143,7 +143,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)); }
@@ -180,14 +180,14 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr,return count; } -static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR, - show_aggr_ogm, store_aggr_ogm); +static BAT_ATTR(aggregated_ogms, S_IRUGO | S_IWUSR, + show_aggr_ogms, store_aggr_ogms); 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);static struct bat_attribute *mesh_attrs[] = { - &bat_attr_aggregate_ogm, + &bat_attr_aggregated_ogms, &bat_attr_vis_mode, &bat_attr_orig_interval,NULL ,
@@ -261,7 +261,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" ); }
Signature · 1 line
1.7.1
PATCH 9/10 Staging: batman-adv: Adding netfilter-bridge hooks
In reply to Sven EckelmannFrom: Linus Lüssing <[email protected]>
batman-adv is receiving and sending the packets of its own ether type on a very early/low level. Therefore we need to add explicit hooks to give netfilter/ebtables a chance to filter them.
--- drivers/staging/batman-adv/hard-interface.c | 14 +++++++++++++- drivers/staging/batman-adv/send.c | 9 +++++++-- 2 files changed, 20 insertions(+), 3 deletions(-)
drivers/staging/batman-adv/hard-interface.c +13 -1
@@ -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))
@@ -432,6 +433,11 @@ out:return NOTIFY_DONE ; } +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,
@@ -451,6 +457,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;
@@ -530,7 +543,6 @@ err_out:return NET_RX_DROP ; } -struct notifier_block hard_if_notifier = { .notifier_call = hard_if_event, };
drivers/staging/batman-adv/send.c +7 -2
@@ -29,6 +29,8 @@#include "vis.h" #include "aggregation.h" +#include <linux/netfilter_bridge.h> +/* apply hop penalty for a normal link */ static uint8_t hop_penalty (const uint8_t tq) {
@@ -90,9 +92,12 @@ int send_skb_packet(struct sk_buff *skb,/* dev_queue_xmit() returns a negative result on error. However on * 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:kfree_skb (skb);return NET_XMIT_DROP ;
Signature · 1 line
1.7.1
PATCH 10/10 Documentation: ABI: Add information about batman-adv sysfs entries
In reply to Sven EckelmannFrom: Marek Lindner <[email protected]>
Add documents about new sysfs entries in
* /sys/class/net/<iface>/batman-adv/mesh_iface
* /sys/class/net/<mesh_iface>/mesh/vis_mode
--- .../ABI/testing/sysfs-class-net-batman-adv | 14 ++++++++++ Documentation/ABI/testing/sysfs-class-net-mesh | 27 ++++++++++++++++++++ 2 files changed, 41 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-net-batman-adv create mode 100644 Documentation/ABI/testing/sysfs-class-net-mesh
Documentation/ABI/testing/sysfs-class-net-batman-adv new file +14 -0
@@ -0,0 +1,14 @@ + +What: /sys/class/net/<iface>/batman-adv/mesh_iface +Date: May 2010 +Contact: Marek Lindner <[email protected]> +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 <[email protected]> +Description: + Indicates the status of <iface> as it is seen by batman.
Documentation/ABI/testing/sysfs-class-net-mesh new file +27 -0
@@ -0,0 +1,27 @@ + +What: /sys/class/net/<mesh_iface>/mesh/aggregated_ogms +Date: May 2010 +Contact: Marek Lindner <[email protected]> +Description: + Indicates whether the batman protocol messages of the + mesh <mesh_iface> shall be aggregated or not. + +What: /sys/class/net/<mesh_iface>/mesh/orig_interval +Date: May 2010 +Contact: Marek Lindner <[email protected]> +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 <[email protected]> +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. Once + activated the topology can be retrieved by reading + the vis_data file.
Signature · 1 line
1.7.1
Re: [B.A.T.M.A.N.] [PATCH 10/10] Documentation: ABI: Add information about batman-adv sysfs entries
Quoted 11 lines · Sven Eckelmann
From: Marek Lindner <[email protected]>
Add documents about new sysfs entries in
* /sys/class/net/<iface>/batman-adv/mesh_iface
* /sys/class/net/<mesh_iface>/mesh/vis_modeSigned-off-by Marek Lindner <[email protected]>Signed-off-by Sven Eckelmann <[email protected]>--- .../ABI/testing/sysfs-class-net-batman-adv | 14 ++++++++++ Documentation/ABI/testing/sysfs-class-net-mesh | 27 ++++++++++++++++++++
For now, can you keep this within the drivers/staging/batman/ directory, just so everything is nice and self-contained? When it moves to the main part of the kernel tree, then it can move into the Documentation/ABI/testing/ directory, ok?
Documentation/ABI/testing/sysfs-class-net-mesh line 27
Quoted 12 lines
Documentation/ABI/testing/sysfs-class-net-mesh new file +12
-0+What: /sys/class/net/<mesh_iface>/mesh/vis_mode +Date: May 2010 +Contact: Marek Lindner <[email protected]> +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. Once + activated the topology can be retrieved by reading + the vis_data file.
Isn't the vis_data file in debugfs now? If so, shouldn't this file move there as well? Or at least don't point to a file that doesn't exist in sysfs :)
thanks,
greg k-h
Re: [B.A.T.M.A.N.] [PATCH 10/10] Documentation: ABI: Add information about batman-adv sysfs entries
Quoted 21 lines · Greg KH
Quoted 7 lines · Sven Eckelmann
From: Marek Lindner <[email protected]>
Add documents about new sysfs entries in
* /sys/class/net/<iface>/batman-adv/mesh_iface
* /sys/class/net/<mesh_iface>/mesh/vis_modeQuoted 7 lines
Signed-off-by Marek Lindner <[email protected]>Signed-off-by Sven Eckelmann <[email protected]>---
.../ABI/testing/sysfs-class-net-batman-adv | 14 ++++++++++ Documentation/ABI/testing/sysfs-class-net-mesh | 27++++++++++++++++++++
For now, can you keep this within the
drivers/staging/batman/directory, just so everything is nice and self-contained? When it moves to the main part of the kernel tree, then it can move into theDocumentation/ABI/testing/directory, ok?
Quoted 16 lines
Documentation/ABI/testing/sysfs-class-net-mesh line 27
Quoted 12 lines
Documentation/ABI/testing/sysfs-class-net-mesh new file +12
-0+What: /sys/class/net/<mesh_iface>/mesh/vis_mode +Date: May 2010 +Contact: Marek Lindner <[email protected]> +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. Once + activated the topology can be retrieved by reading + the vis_data file.Isn't the
vis_datafile in debugfs now? If so, shouldn't this file move there as well? Or at least don't point to a file that doesn't exist in sysfs :)
No, vis_data is the output. vis_mode says if a node is a client or a server. A server can generate that output... but as vis_mode and vis_data are two different things, I think that not both must be moved to debugfs. For example a client should be able to move into client mode or read his current status without having debugfs compiled inside his kernel - the client will never get the output vis_data, so it isn't important for him to have debugfs. But I will remove that sentence.
Best regards,
Sven
Quoted 5 lines · Sven Eckelmann
Hi,
we've tried to fix the outstanding problem regarding the sysfs filesystem and fixed some further smaller problems. I hope that it is right were we put the ABI documentation.
Not really, but I responded to where it should go on that message.
As we are now past the .35 merge window, you should consider what patches should be acceptable for the .35 release, and which should wait until .36. It looks like about half of these patches should be queued up for .35 as they are bug fixes, right? The api changes by moving stuff into debugfs should wait for .36.
So could you split this patch set up into two different ones? One you want to see go into .35 and one for .36?
thanks,
greg k-h
Quoted 8 lines · Greg KH
Quoted 5 lines · Sven Eckelmann
Hi,
we've tried to fix the outstanding problem regarding the sysfs filesystem and fixed some further smaller problems. I hope that it is right were we put the ABI documentation.
Not really, but I responded to where it should go on that message.
Thanks. I will move them to the right place.
Quoted 5 lines
As we are now past the .35 merge window, you should consider what patches should be acceptable for the .35 release, and which should wait until .36. It looks like about half of these patches should be queued up for .35 as they are bug fixes, right? The api changes by moving stuff into debugfs should wait for .36.
The merge window is already closed? v2.6.34 was released 6 days ago. Or do you mean that your merge window for staging is closed?
Quoted 2 lines
So could you split this patch set up into two different ones? One you want to see go into .35 and one for .36?
Yes, will do that.
Best regards,
Sven
Quoted 12 lines · Sven Eckelmann
Quoted 8 lines · Greg KH
Quoted 5 lines · Sven Eckelmann
Hi,
we've tried to fix the outstanding problem regarding the sysfs filesystem and fixed some further smaller problems. I hope that it is right were we put the ABI documentation.
Not really, but I responded to where it should go on that message.
Thanks. I will move them to the right place.
Quoted 8 lines
Quoted 5 lines
As we are now past the .35 merge window, you should consider what patches should be acceptable for the .35 release, and which should wait until .36. It looks like about half of these patches should be queued up for .35 as they are bug fixes, right? The api changes by moving stuff into debugfs should wait for .36.
The merge window is already closed? v2.6.34 was released 6 days ago. Or do you mean that your merge window for staging is closed?
The merge window is for the subsystem maintainers to send stuff to Linus. That stuff must have already been in the linux-next tree for a bit to test it out and ensure that it doesn't break anyone.
So that means that you need to get things to the subsystem maintainers a week or so before the merge window opens up if you want to see it go into the next kernel release.
And yes, this means the merge window for the staging tree for new features is now closed. Only bugfixes will be accepted for .35 from now on, but I can easily queue up stuff for .36, I just have to wait until .35-rc1 is out before I can add it to my public tree for inclusion in the linux-next tree.
Hope this explains things a bit better.
greg k-h
Greg KH wrote:
[...]
Quoted 11 lines
Quoted 2 lines
The merge window is already closed? v2.6.34 was released 6 days ago. Or do you mean that your merge window for staging is closed?
The merge window is for the subsystem maintainers to send stuff to Linus. That stuff must have already been in the linux-next tree for a bit to test it out and ensure that it doesn't break anyone.
So that means that you need to get things to the subsystem maintainers a week or so before the merge window opens up if you want to see it go into the next kernel release.
Quoted 7 lines
And yes, this means the merge window for the staging tree for new features is now closed. Only bugfixes will be accepted for .35 from now on, but I can easily queue up stuff for .36, I just have to wait until .35-rc1 is out before I can add it to my public tree for inclusion in the linux-next tree.
Hope this explains things a bit better.
Yes, helped a lot :)
thanks,
Sven
Quoted 19 lines · Sven Eckelmann
Greg KH wrote:
[...]Quoted 17 lines
Quoted 2 lines
The merge window is already closed? v2.6.34 was released 6 days ago. Or do you mean that your merge window for staging is closed?
The merge window is for the subsystem maintainers to send stuff to Linus. That stuff must have already been in the linux-next tree for a bit to test it out and ensure that it doesn't break anyone.
So that means that you need to get things to the subsystem maintainers a week or so before the merge window opens up if you want to see it go into the next kernel release.
And yes, this means the merge window for the staging tree for new features is now closed. Only bugfixes will be accepted for .35 from now on, but I can easily queue up stuff for .36, I just have to wait until .35-rc1 is out before I can add it to my public tree for inclusion in the linux-next tree.
Quoted 3 lines
Quoted 1 line
Hope this explains things a bit better.
Yes, helped a lot :)
Great, I got your patches, and will queue them up starting next week when the .35-rc1 kernel is out.
thanks,
greg k-h