batman-adv tries to resend broadcasts on all interfaces up to three
times. For each round and each interface it must provide a skb which
gets consumed by the sending function.
It is unnecessary to copy the data of each broadcast because the actual
data is either not shared or already copied by add_bcast_packet_to_list.
So it is enough to just copy the skb control data
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
---
batman-adv/send.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/batman-adv/send.c b/batman-adv/send.c
index cd6be2b..934bd8a 100644
--- a/batman-adv/send.c
+++ b/batman-adv/send.c
@@ -476,7 +476,7 @@ static void send_outstanding_bcast_packet(struct work_struct *work)
rcu_read_lock();
list_for_each_entry_rcu(batman_if, &if_list, list) {
/* send a copy of the saved skb */
- skb1 = skb_copy(forw_packet->skb, GFP_ATOMIC);
+ skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC);
if (skb1)
send_skb_packet(skb1,
batman_if, broadcast_addr);
--
1.7.1
Hi,
I improved the patchset a bit more:
* batctl crash fixed
* batctl man page update
* crash in find_routers()
* cash when forwarding broadcasts
* one forgotten global variable eliminated
Thanks for the (off-list) feedback I received so far. I will submit these
patches if nobody objects during the coming days.
Regards,
Marek
Hi,
first thing: thanks for your help to get some review for batman-adv from davem
and the netdev ml. I've added some new points to the TODO list. They are partly
resolved or work is done to solve them, but will postpone them and get them
hopefully ready and tested for 2.6.37.
Nevertheless there are some smaller changes which want to resolve with 2.6.36.
One is to allow to build it together with dt3155 directly into the kernel and
the other one should fix that we try to change stats of a different device. The
latter one will clash with an unlucky try by the netdev guys to change the
behaviour of dev_get_stats and the batman-adv source code.
This merge conflict is quite easy to resolve. Just delete the dev_get_stats
line in hard-interface.c in batman_skb_recv and the new variable temp added by
them.
I can also provide a patch on top of linux-next instead of staging-next-2.6 if
you would prefer it in this situation. I will call it
"[PATCH-next 1/3] Staging: batman-adv: Don't increment stats of foreign device"
I hope that it doesn't create more confusion as necessary. :)
thanks,
Sven
Randy Dunlap (1):
Staging: batman-adv: don't use default init_module/cleanup_module function names
Sven Eckelmann (2):
Staging: batman-adv: Don't increment stats of foreign device
Staging: batman-adv: Update TODO with new points from review
drivers/staging/batman-adv/TODO | 9 ++++++---
drivers/staging/batman-adv/hard-interface.c | 7 -------
drivers/staging/batman-adv/main.c | 7 +++++--
3 files changed, 11 insertions(+), 12 deletions(-)
Fromy: Randy Dunlap <randy.dunlap(a)oracle.com>
Fix two staging drivers to use module_init()/module_exit()
instead of default init_module() and cleanup_module() function names
so that there are no name conflicts when both are built-in.
drivers/staging/dt3155/built-in.o: In function `cleanup_module':
(.text+0xc0): multiple definition of `cleanup_module'
drivers/staging/batman-adv/built-in.o:(.text+0x330): first defined here
drivers/staging/dt3155/built-in.o: In function `init_module':
(.text+0xe60): multiple definition of `init_module'
drivers/staging/batman-adv/built-in.o:(.text+0x400): first defined here
Signed-off-by: Randy Dunlap <randy.dunlap(a)oracle.com>
Cc: Scott Smedley <ss(a)aao.gov.au>
Cc: Marek Lindner <lindner_marek(a)yahoo.de>
Cc: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
Cc: Andrew Lunn <andrew(a)lunn.ch>
Cc: b.a.t.m.a.n(a)lists.open-mesh.net
Cc: Greg Kroah-Hartman <gregkh(a)suse.de
---
drivers/staging/batman-adv/main.c | 7 +++++--
drivers/staging/dt3155/dt3155_drv.c | 23 ++++++++++-------------
2 files changed, 15 insertions(+), 15 deletions(-)
--- linux-next-20100719.orig/drivers/staging/batman-adv/main.c
+++ linux-next-20100719/drivers/staging/batman-adv/main.c
@@ -59,7 +59,7 @@ static struct packet_type batman_adv_pac
struct workqueue_struct *bat_event_workqueue;
-int init_module(void)
+int batman_init(void)
{
int retval;
@@ -131,7 +131,7 @@ end:
return -ENOMEM;
}
-void cleanup_module(void)
+void batman_exit(void)
{
deactivate_module();
@@ -273,6 +273,9 @@ int is_mcast(uint8_t *addr)
return *addr & 0x01;
}
+module_init(batman_init);
+module_exit(batman_exit);
+
MODULE_LICENSE("GPL");
MODULE_AUTHOR(DRIVER_AUTHOR);
--- linux-next-20100719.orig/drivers/staging/dt3155/dt3155_drv.c
+++ linux-next-20100719/drivers/staging/dt3155/dt3155_drv.c
@@ -47,7 +47,7 @@ MA 02111-1307 USA
+ might want to get rid of MAXboards for allocating initial buffer.
confusing and not necessary
- + in cleanup_module the MOD_IN_USE looks like it is check after it should
+ + in dt3155_exit the MOD_IN_USE looks like it is check after it should
* GFP_DMA should not be set with a PCI system (pg 291)
@@ -166,7 +166,7 @@ static void quick_stop (int minor)
*
* - looks like this isr supports IRQ sharing (or could) JML
* - Assumes irq's are disabled, via SA_INTERRUPT flag
- * being set in request_irq() call from init_module()
+ * being set in request_irq() call from dt3155_init()
*****************************************************/
static void dt3155_isr(int irq, void *dev_id, struct pt_regs *regs)
{
@@ -836,7 +836,7 @@ dt3155_unlocked_ioctl(struct file *file,
/*****************************************************
* file operations supported by DT3155 driver
- * needed by init_module
+ * needed by dt3155_init
* register_chrdev
*****************************************************/
static struct file_operations dt3155_fops = {
@@ -937,10 +937,8 @@ err:
u32 allocatorAddr = 0;
-/*****************************************************
- * init_module()
- *****************************************************/
-int init_module(void)
+
+int dt3155_init(void)
{
struct dt3155_status *dts;
int index;
@@ -1059,16 +1057,13 @@ int init_module(void)
return 0;
}
-/*****************************************************
- * cleanup_module(void)
- *
- *****************************************************/
-void cleanup_module(void)
+
+void dt3155_exit(void)
{
struct dt3155_status *dts;
int index;
- printk("DT3155: cleanup_module called\n");
+ printk("DT3155: dt3155_exit called\n");
/* removed DMA allocated with the allocator */
#ifdef STANDALONE_ALLOCATOR
@@ -1092,3 +1087,5 @@ void cleanup_module(void)
}
}
+module_init(dt3155_init);
+module_exit(dt3155_exit);
The Kernighan algorithm is not able to calculate the number of set bits
in parallel and the compiler cannot replace it with optimized
instructions.
The kernel provides specialised functions for each cpu which can either
use a software implementation or hardware instruction depending on the
target cpu.
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
---
batman-adv/bitarray.c | 15 +++++----------
batman-adv/bitarray.h | 3 ++-
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/batman-adv/bitarray.c b/batman-adv/bitarray.c
index dd4193c..9dbaf1e 100644
--- a/batman-adv/bitarray.c
+++ b/batman-adv/bitarray.c
@@ -22,6 +22,8 @@
#include "main.h"
#include "bitarray.h"
+#include <linux/bitops.h>
+
/* 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, uint32_t last_seqno,
@@ -187,21 +189,14 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff,
}
/* count the hamming weight, how many good packets did we receive? just count
- * the 1's. The inner loop uses the Kernighan algorithm, see
- * http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan
+ * the 1's.
*/
int bit_packet_count(TYPE_OF_WORD *seq_bits)
{
int i, hamming = 0;
- TYPE_OF_WORD word;
- for (i = 0; i < NUM_WORDS; i++) {
- word = seq_bits[i];
+ for (i = 0; i < NUM_WORDS; i++)
+ hamming += hweight_long(seq_bits[i]);
- while (word) {
- word &= word-1;
- hamming++;
- }
- }
return hamming;
}
diff --git a/batman-adv/bitarray.h b/batman-adv/bitarray.h
index 01897d6..c0c1730 100644
--- a/batman-adv/bitarray.h
+++ b/batman-adv/bitarray.h
@@ -22,7 +22,8 @@
#ifndef _NET_BATMAN_ADV_BITARRAY_H_
#define _NET_BATMAN_ADV_BITARRAY_H_
-/* you should choose something big, if you don't want to waste cpu */
+/* you should choose something big, if you don't want to waste cpu
+ and keep the type in sync with bit_packet_count */
#define TYPE_OF_WORD unsigned long
#define WORD_BIT_SIZE (sizeof(TYPE_OF_WORD) * 8)
--
1.7.1