[B.A.T.M.A.N.] Batman gateway lock ups
by Outback Dingo
see pastebin
http://www.pastebin.ca/1194874
pertinent info
dmesg | grep 'batgat loaded'
batgat: [init_module:96] batgat loaded rv1025
uname -a
Linux nightwing 2.6.23.16 #16 Tue Apr 22 20:00:17 ART 2008 mips unknown
root@nightwing:~# batmand -v
WARNING: You are using the unstable batman branch. If you are interested in
*using* batman get the latest stable release !
B.A.T.M.A.N. 0.3-beta (compatibility version 5)
lsmod
Module Size Used by Tainted:
P
sch_htb 14048
2
ath_ahb 103616
0
wlan_xauth 480
0
wlan_wep 4000
0
wlan_tkip 9856
0
wlan_ccmp 5440
2
wlan_acl 1920 0
ath_rate_minstrel 8352 1
ath_hal 136832 3 ath_ahb,ath_rate_minstrel
wlan_scan_sta 8768 1
wlan_scan_ap 6656 0
wlan 152464 10
ath_ahb,wlan_xauth,wlan_wep,wlan_tkip,wlan_ccmp,wlan_acl,ath_rate_minstrel,wlan_scan_sta,wlan_scan_ap
batgat 10944 1
ipt_iprange 672 0
ipt_TOS 832 0
ipt_TTL 928 0
xt_MARK 960 3
ipt_ECN 1472 0
xt_CLASSIFY 640 0
ipt_ttl 704 0
ipt_tos 544 0
ipt_time 1568 0
xt_tcpmss 1088 0
xt_statistic 832 0
xt_mark 672 7
xt_mac 736 3
xt_length 736 0
ipt_ecn 1024 0
xt_DSCP 1056 0
xt_dscp 832 0
imq 2096 0
ipt_IMQ 672 2
xt_string 896 0
xt_layer7 9840 0
ipt_ipp2p 6784 0
ipt_LOG 4640 0
xt_CHAOS 1792 0
xt_DELUDE 2624 1
xt_TARPIT 2816 1
xt_quota 800 0
xt_portscan 2016 0
xt_pkttype 704 0
xt_physdev 1488 0
ipt_owner 800 0
iptable_raw 832 0
xt_NOTRACK 832 0
xt_CONNMARK 1088 0
ipt_recent 4992 0
xt_helper 992 0
xt_conntrack 1312 0
xt_connmark 832 0
xt_connbytes 1312 0
tun 6592 0
13 years, 6 months
[B.A.T.M.A.N.] [PATCH] Make batman timer functions thread safe
by Sven Eckelmann
The calculation inside of update_internal_clock aren't atomic and can lead to
bogus time informations when many threads calling get_time_msec64 or
get_time_msec.
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
---
batman/posix/posix.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/batman/posix/posix.c b/batman/posix/posix.c
index dd24a65..042a2b9 100644
--- a/batman/posix/posix.c
+++ b/batman/posix/posix.c
@@ -49,6 +49,7 @@ static float system_tick;
uint8_t tunnel_running = 0;
+static pthread_mutex_t batman_clock_mutex = PTHREAD_MUTEX_INITIALIZER;
void update_internal_clock()
{
@@ -61,14 +62,26 @@ void update_internal_clock()
uint32_t get_time_msec()
{
+ uint32_t time;
+
+ pthread_mutex_lock(&batman_clock_mutex);
update_internal_clock();
- return (uint32_t)(((float)(batman_clock_ticks) * 1000) / system_tick);
+ time = (uint32_t)(((float)(batman_clock_ticks) * 1000) / system_tick);
+ pthread_mutex_unlock(&batman_clock_mutex);
+
+ return time;
}
uint64_t get_time_msec64()
{
+ uint64_t time;
+
+ pthread_mutex_lock(&batman_clock_mutex);
update_internal_clock();
- return (uint64_t)(((float)(batman_clock_ticks) * 1000) / system_tick);
+ time = (uint64_t)(((float)(batman_clock_ticks) * 1000) / system_tick);
+ pthread_mutex_unlock(&batman_clock_mutex);
+
+ return time;
}
/* batman animation */
--
1.6.0.1
14 years, 1 month
[B.A.T.M.A.N.] batman-exp hang on 95% CPU load
by Stephan Enderlein (Freifunk Dresden)
Hi,
I currently use batman-experimental rev 1105. Yesterday
a node was not reachable. The "top" showed me that batmand
was running with almost 100% load.
I could not attach to the batmand to watch any debug info or states.
When calling batmand -cd8 (or others) the call simply hangs without
prints.
The only call I could make was batmand -c, which displayed:
/sbin/batmand [not-all-options-displayed] -r 1 -a 10.12.10.16/28 -a
172.16.10.17/32 eth1 tbb /t
logread did not show any batman message. The memory consumption was also ok.
After hard killing and starting the daemon batmand runs normal.
Creating a core dump on wrt was not possible.
Do you have already seen this?
/Stephan
---------------------------------------
Dipl.Informatiker(FH) Stephan Enderlein
Freifunk Dresden
14 years, 4 months
[B.A.T.M.A.N.] [PATCH] Remove dead stores in batmand
by Sven Eckelmann
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
---
batman/batman.c | 4 ++--
batman/originator.c | 2 --
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/batman/batman.c b/batman/batman.c
index d7e2389..eda5774 100644
--- a/batman/batman.c
+++ b/batman/batman.c
@@ -897,7 +897,7 @@ int8_t batman(void)
char orig_str[ADDR_STR_LEN], neigh_str[ADDR_STR_LEN], ifaddr_str[ADDR_STR_LEN], oldorig_str[ADDR_STR_LEN];
int16_t hna_buff_count, hna_buff_len, packet_len, curr_packet_len;
uint8_t forward_old, if_rp_filter_all_old, if_rp_filter_default_old, if_send_redirects_all_old, if_send_redirects_default_old;
- uint8_t is_my_addr, is_my_orig, is_my_oldorig, is_broadcast, is_duplicate, is_bidirectional, is_bntog, has_directlink_flag;
+ uint8_t is_my_addr, is_my_orig, is_my_oldorig, is_broadcast, is_duplicate, is_bidirectional, has_directlink_flag;
int8_t res;
@@ -1005,7 +1005,7 @@ int8_t batman(void)
addr_to_string(bat_packet->orig, orig_str, sizeof(orig_str));
addr_to_string(bat_packet->old_orig, oldorig_str, sizeof(oldorig_str));
- is_my_addr = is_my_orig = is_my_oldorig = is_broadcast = is_duplicate = is_bidirectional = is_bntog = 0;
+ is_my_addr = is_my_orig = is_my_oldorig = is_broadcast = 0;
has_directlink_flag = (bat_packet->flags & DIRECTLINK ? 1 : 0);
diff --git a/batman/originator.c b/batman/originator.c
index 8097d4a..7f13f3d 100644
--- a/batman/originator.c
+++ b/batman/originator.c
@@ -219,8 +219,6 @@ void update_orig( struct orig_node *orig_node, struct bat_packet *in, uint32_t n
if ( ( neigh_node->tq_avg > max_tq ) || ( ( neigh_node->tq_avg == max_tq ) && ( neigh_node->orig_node->bcast_own_sum[if_incoming->if_num] > max_bcast_own ) ) || ( ( orig_node->router == neigh_node ) && ( neigh_node->tq_avg == max_tq ) ) ) {
- max_tq = neigh_node->tq_avg;
- max_bcast_own = neigh_node->orig_node->bcast_own_sum[if_incoming->if_num];
best_neigh_node = neigh_node;
}
--
1.6.0.1
14 years, 4 months
[B.A.T.M.A.N.] [PATCH] Mark not returning functions with __noreturn__
by Sven Eckelmann
The gcc feature for functions that will definitely not return should help the
static analyzer and the optimizer slightly. See
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function-Attri...
for more informations.
---
batman/os.h | 8 +++++++-
batman/posix/posix.c | 4 ++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/batman/os.h b/batman/os.h
index b1e9423..d29ebf1 100644
--- a/batman/os.h
+++ b/batman/os.h
@@ -22,6 +22,12 @@
#include "batman.h"
+#ifdef __GNUC_MINOR__
+#define NO_RETURN __attribute__ ((__noreturn__))
+#else
+#define NO_RETURN
+#endif
+
uint32_t get_time_msec(void);
uint64_t get_time_msec64(void);
int32_t rand_num( int32_t limit );
@@ -34,7 +40,7 @@ void add_del_hna( struct orig_node *orig_node, int8_t del );
int8_t is_aborted();
void handler( int32_t sig );
void segmentation_fault( int32_t sig );
-void restore_and_exit( uint8_t is_sigsegv );
+void restore_and_exit( uint8_t is_sigsegv ) NO_RETURN;
/* route.c */
void add_del_route( uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src_ip, int32_t ifi, char *dev, uint8_t rt_table, int8_t route_type, int8_t del );
diff --git a/batman/posix/posix.c b/batman/posix/posix.c
index b94ceae..432b45f 100644
--- a/batman/posix/posix.c
+++ b/batman/posix/posix.c
@@ -499,6 +499,8 @@ void restore_and_exit( uint8_t is_sigsegv ) {
if ( !is_sigsegv )
exit(EXIT_FAILURE);
+ else
+ raise( SIGSEGV );
}
@@ -515,8 +517,6 @@ void segmentation_fault( int32_t sig ) {
restore_and_exit(1);
- raise( SIGSEGV );
-
}
--
1.6.0.1
14 years, 4 months
[B.A.T.M.A.N.] Possible null pointer dereference in batman's update_routes
by Sven Eckelmann
Hi,
I am not sure but I think it could be possible that there is a null pointer
dereference at batman.c:420
I assume that it is possible that neigh_node is NULL and orig_node->router is
also NULL in batman.c:412. Now we dereference neigh_node in batman.c:420 as
third parameter of add_del_route.
I don't know if the third parameter should be set to 0 if neigh_node is NULL
or if the "if"-statement is wrong - so i will not send a patch this time.
Best regards,
Sven
14 years, 4 months
[B.A.T.M.A.N.] [PATCH] Sync hash implementation of batgat and batman-adv
by Sven Eckelmann
The compare functions had a different interpretation of its return value and
kmalloc can sleep inside batgat because we are running in user context of
kernel.
---
batman/linux/modules/gateway.c | 4 +-
batman/linux/modules/gateway24.c | 4 +-
batman/linux/modules/hash.c | 266 ++++++++++++++++++++------------------
batman/linux/modules/hash.h | 9 +-
4 files changed, 149 insertions(+), 134 deletions(-)
diff --git a/batman/linux/modules/gateway.c b/batman/linux/modules/gateway.c
index 41d75b5..1f2dc24 100644
--- a/batman/linux/modules/gateway.c
+++ b/batman/linux/modules/gateway.c
@@ -713,12 +713,12 @@ static struct gw_client *get_ip_addr(struct sockaddr_in *client_addr)
* the ip address is the first/second field in the struct */
int compare_wip(void *data1, void *data2)
{
- return ( memcmp( data1, data2, 4 ) );
+ return ( !memcmp( data1, data2, 4 ) );
}
int compare_vip(void *data1, void *data2)
{
- return ( memcmp( data1 + 4, data2 + 4, 4 ) );
+ return ( !memcmp( data1 + 4, data2 + 4, 4 ) );
}
/* hashfunction to choose an entry in a hash table of given size */
diff --git a/batman/linux/modules/gateway24.c b/batman/linux/modules/gateway24.c
index dbd1f42..a8d58e6 100644
--- a/batman/linux/modules/gateway24.c
+++ b/batman/linux/modules/gateway24.c
@@ -693,12 +693,12 @@ static int kernel_recvmsg(struct socket *sock, struct msghdr *msg, struct iovec
int compare_wip(void *data1, void *data2)
{
- return ( memcmp( data1, data2, 4 ) );
+ return ( !memcmp( data1, data2, 4 ) );
}
int compare_vip(void *data1, void *data2)
{
- return ( memcmp( data1 + 4, data2 + 4, 4 ) );
+ return ( !memcmp( data1 + 4, data2 + 4, 4 ) );
}
int choose_wip(void *data, int32_t size)
diff --git a/batman/linux/modules/hash.c b/batman/linux/modules/hash.c
index ae009be..e88c6e0 100644
--- a/batman/linux/modules/hash.c
+++ b/batman/linux/modules/hash.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2006 B.A.T.M.A.N. contributors:
+/*
+ * Copyright (C) 2006-2008 B.A.T.M.A.N. contributors:
* Simon Wunderlich, 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.
@@ -17,294 +17,304 @@
*
*/
+
+
+
+
#include <linux/string.h> /* strlen, strstr, strncmp ... */
#include <linux/slab.h>
#include "hash.h"
+
/* clears the hash */
-void hash_init(struct hashtable_t *hash) {
+void hash_init(struct hashtable_t *hash)
+{
int i;
- hash->elements=0;
- for (i=0 ; i<hash->size ; i++) {
+
+ hash->elements = 0;
+
+ for (i = 0 ; i < hash->size; i++)
hash->table[i] = NULL;
- }
}
-
/* remove the hash structure. if hashdata_free_cb != NULL,
* this function will be called to remove the elements inside of the hash.
* if you don't remove the elements, memory might be leaked. */
-void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb) {
+void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb)
+{
struct element_t *bucket, *last_bucket;
int i;
- for (i=0; i<hash->size; i++) {
+ for (i = 0; i < hash->size; i++) {
+ bucket = hash->table[i];
- bucket= hash->table[i];
while (bucket != NULL) {
+ if (free_cb != NULL)
+ free_cb(bucket->data);
- if (free_cb!=NULL)
- free_cb( bucket->data );
-
- last_bucket= bucket;
- bucket= bucket->next;
+ last_bucket = bucket;
+ bucket = bucket->next;
kfree(last_bucket);
-
}
}
+
hash_destroy(hash);
}
-
-
/* free only the hashtable and the hash itself. */
-void hash_destroy(struct hashtable_t *hash) {
-
- kfree( hash->table );
- kfree( hash );
-
+void hash_destroy(struct hashtable_t *hash)
+{
+ kfree(hash->table);
+ kfree(hash);
}
-
-
-
/* iterate though the hash. first element is selected with iter_in NULL.
* use the returned iterator to access the elements until hash_it_t returns NULL. */
-struct hash_it_t *hash_iterate(struct hashtable_t *hash, struct hash_it_t *iter_in) {
+struct hash_it_t *hash_iterate(struct hashtable_t *hash, struct hash_it_t *iter_in)
+{
struct hash_it_t *iter;
if (iter_in == NULL) {
- iter= kmalloc(sizeof(struct hash_it_t), GFP_KERNEL);
- iter->index = -1;
+ iter = kmalloc(sizeof(struct hash_it_t), GFP_KERNEL);
+ iter->index = -1;
iter->bucket = NULL;
iter->prev_bucket = NULL;
- } else
+ } else {
iter= iter_in;
+ }
/* sanity checks first (if our bucket got deleted in the last iteration): */
- if (iter->bucket!=NULL) {
+ if (iter->bucket != NULL) {
if (iter->first_bucket != NULL) {
-
/* we're on the first element and it got removed after the last iteration. */
if ((*iter->first_bucket) != iter->bucket) {
-
/* there are still other elements in the list */
- if ( (*iter->first_bucket) != NULL ) {
+ if ((*iter->first_bucket) != NULL) {
iter->prev_bucket = NULL;
- iter->bucket= (*iter->first_bucket);
- iter->first_bucket = &hash->table[ iter->index ];
- return(iter);
+ iter->bucket = (*iter->first_bucket);
+ iter->first_bucket = &hash->table[iter->index];
+ return iter;
} else {
iter->bucket = NULL;
}
-
}
-
- } else if ( iter->prev_bucket != NULL ) {
-
- /* we're not on the first element, and the bucket got removed after the last iteration.
+ } else if (iter->prev_bucket != NULL) {
+ /*
+ * we're not on the first element, and the bucket got removed after the last iteration.
* the last bucket's next pointer is not pointing to our actual bucket anymore.
- * select the next. */
- if ( iter->prev_bucket->next != iter->bucket )
- iter->bucket= iter->prev_bucket;
-
+ * select the next.
+ */
+ if (iter->prev_bucket->next != iter->bucket)
+ iter->bucket = iter->prev_bucket;
}
-
}
/* now as we are sane, select the next one if there is some */
- if (iter->bucket!=NULL) {
- if (iter->bucket->next!=NULL) {
- iter->prev_bucket= iter->bucket;
- iter->bucket= iter->bucket->next;
+ if (iter->bucket != NULL) {
+ if (iter->bucket->next != NULL) {
+ iter->prev_bucket = iter->bucket;
+ iter->bucket = iter->bucket->next;
iter->first_bucket = NULL;
- return(iter);
+ return iter;
}
}
- /* if not returned yet, we've reached the last one on the index and have to search forward */
+ /* if not returned yet, we've reached the last one on the index and have to search forward */
iter->index++;
- while ( iter->index < hash->size ) { /* go through the entries of the hash table */
- if ((hash->table[ iter->index ]) != NULL){
+ /* go through the entries of the hash table */
+ while (iter->index < hash->size) {
+ if ((hash->table[iter->index]) != NULL){
iter->prev_bucket = NULL;
- iter->bucket = hash->table[ iter->index ];
- iter->first_bucket = &hash->table[ iter->index ];
- return(iter); /* if this table entry is not null, return it */
- } else
- iter->index++; /* else, go to the next */
+ iter->bucket = hash->table[iter->index];
+ iter->first_bucket = &hash->table[iter->index];
+ return iter;
+ } else {
+ iter->index++;
+ }
}
+
/* nothing to iterate over anymore */
kfree(iter);
- return(NULL);
+ return NULL;
}
-
/* allocates and clears the hash */
-struct hashtable_t *hash_new(int size, hashdata_compare_cb compare, hashdata_choose_cb choose) {
+struct hashtable_t *hash_new(int size, hashdata_compare_cb compare, hashdata_choose_cb choose)
+{
struct hashtable_t *hash;
- hash= kmalloc( sizeof(struct hashtable_t) , GFP_KERNEL);
- if ( hash == NULL ) /* could not allocate the hash control structure */
- return (NULL);
+ hash = kmalloc(sizeof(struct hashtable_t) , GFP_KERNEL);
+
+ if (hash == NULL)
+ return NULL;
- hash->size= size;
- hash->table= kmalloc( sizeof(struct element_t *) * size, GFP_KERNEL);
- if ( hash->table == NULL ) { /* could not allocate the table */
+ hash->size = size;
+ hash->table = kmalloc(sizeof(struct element_t *) * size, GFP_KERNEL);
+
+ if (hash->table == NULL) {
kfree(hash);
- return(NULL);
+ return NULL;
}
+
hash_init(hash);
- hash->compare= compare;
- hash->choose= choose;
- return(hash);
-}
+ hash->compare = compare;
+ hash->choose = choose;
+
+ return hash;
+}
/* adds data to the hashtable. returns 0 on success, -1 on error */
-int hash_add(struct hashtable_t *hash, void *data) {
+int hash_add(struct hashtable_t *hash, void *data)
+{
int index;
struct element_t *bucket, *prev_bucket = NULL;
- index = hash->choose( data, hash->size );
+ index = hash->choose(data, hash->size);
bucket = hash->table[index];
- while ( bucket!=NULL ) {
- if (0 == hash->compare( bucket->data, data ))
- return(-1);
+ while (bucket != NULL) {
+ if (hash->compare(bucket->data, data))
+ return -1;
prev_bucket = bucket;
- bucket= bucket->next;
+ bucket = bucket->next;
}
/* found the tail of the list, add new element */
- if (NULL == (bucket= kmalloc(sizeof(struct element_t),GFP_KERNEL)))
- return(-1); /* debugMalloc failed */
+ bucket = kmalloc(sizeof(struct element_t),GFP_KERNEL);
+
+ if (bucket == NULL)
+ return -1;
- bucket->data= data; /* init the new bucket */
- bucket->next= NULL;
+ bucket->data = data;
+ bucket->next = NULL;
/* and link it */
- if ( prev_bucket == NULL ) {
+ if (prev_bucket == NULL)
hash->table[index] = bucket;
- } else {
+ else
prev_bucket->next = bucket;
- }
hash->elements++;
- return(0);
-
+ return 0;
}
+
/* finds data, based on the key in keydata. returns the found data on success, or NULL on error */
-void *hash_find(struct hashtable_t *hash, void *keydata) {
+void *hash_find(struct hashtable_t *hash, void *keydata)
+{
int index;
struct element_t *bucket;
- index = hash->choose( keydata , hash->size );
+ index = hash->choose(keydata , hash->size);
bucket = hash->table[index];
- while ( bucket!=NULL ) {
- if (0 == hash->compare( bucket->data, keydata ))
- return( bucket->data );
+ while (bucket != NULL) {
+ if (hash->compare(bucket->data, keydata))
+ return bucket->data;
- bucket= bucket->next;
+ bucket = bucket->next;
}
- return(NULL);
-
+ return NULL;
}
/* remove bucket (this might be used in hash_iterate() if you already found the bucket
* you want to delete and don't need the overhead to find it again with hash_remove().
* But usually, you don't want to use this function, as it fiddles with hash-internals. */
-void *hash_remove_bucket(struct hashtable_t *hash, struct hash_it_t *hash_it_t) {
+void *hash_remove_bucket(struct hashtable_t *hash, struct hash_it_t *hash_it_t)
+{
void *data_save;
- data_save = hash_it_t->bucket->data; /* save the pointer to the data */
+ data_save = hash_it_t->bucket->data;
- if ( hash_it_t->prev_bucket != NULL ) {
+ if (hash_it_t->prev_bucket != NULL)
hash_it_t->prev_bucket->next = hash_it_t->bucket->next;
- } else if ( hash_it_t->first_bucket != NULL ) {
+ else if (hash_it_t->first_bucket != NULL)
(*hash_it_t->first_bucket) = hash_it_t->bucket->next;
- }
kfree(hash_it_t->bucket);
-
hash->elements--;
- return( data_save );
+ return data_save;
}
-
/* removes data from hash, if found. returns pointer do data on success,
* so you can remove the used structure yourself, or NULL on error .
* data could be the structure you use with just the key filled,
* we just need the key for comparing. */
-void *hash_remove(struct hashtable_t *hash, void *data) {
+void *hash_remove(struct hashtable_t *hash, void *data)
+{
struct hash_it_t hash_it_t;
- hash_it_t.index = hash->choose( data, hash->size );
+ hash_it_t.index = hash->choose(data, hash->size);
hash_it_t.bucket = hash->table[hash_it_t.index];
hash_it_t.prev_bucket = NULL;
- while ( hash_it_t.bucket!=NULL ) {
- if (0 == hash->compare( hash_it_t.bucket->data, data )) {
+ while (hash_it_t.bucket != NULL) {
+ if (hash->compare(hash_it_t.bucket->data, data)) {
hash_it_t.first_bucket = (hash_it_t.bucket == hash->table[hash_it_t.index] ? &hash->table[ hash_it_t.index ] : NULL);
- return( hash_remove_bucket(hash, &hash_it_t) );
+ return hash_remove_bucket(hash, &hash_it_t);
}
hash_it_t.prev_bucket = hash_it_t.bucket;
hash_it_t.bucket= hash_it_t.bucket->next;
}
- return(NULL);
-
+ return NULL;
}
-
/* resize the hash, returns the pointer to the new hash or NULL on error. removes the old hash on success. */
-struct hashtable_t *hash_resize(struct hashtable_t *hash, int size) {
+struct hashtable_t *hash_resize(struct hashtable_t *hash, int size)
+{
struct hashtable_t *new_hash;
struct element_t *bucket;
int i;
/* initialize a new hash with the new size */
- if (NULL == (new_hash= hash_new(size, hash->compare, hash->choose)))
- return(NULL);
+ new_hash = hash_new(size, hash->compare, hash->choose);
+
+ if (new_hash == NULL)
+ return NULL;
/* copy the elements */
- for (i=0; i<hash->size; i++) {
- bucket= hash->table[i];
+ for (i = 0; i < hash->size; i++) {
+ bucket = hash->table[i];
+
while (bucket != NULL) {
- hash_add( new_hash, bucket->data );
- bucket= bucket->next;
+ hash_add(new_hash, bucket->data);
+ bucket = bucket->next;
}
}
- hash_delete(hash, NULL); /* remove hash and eventual overflow buckets but not the content itself. */
- return( new_hash);
+ /* remove hash and eventual overflow buckets but not the content itself. */
+ hash_delete(hash, NULL);
+ return new_hash;
}
-/* print the hash table for debugging */
-void hash_debug(struct hashtable_t *hash) {
+/* print the hash table for debugging
+void hash_debug(struct hashtable_t *hash)
+{
int i;
struct element_t *bucket;
for (i=0; i<hash->size;i++) {
- printk("[%d] ",i);
+ printf("[%d] ",i);
bucket= hash->table[i];
while (bucket != NULL) {
- printk("-> [%10p] ", bucket);
+ printf("-> [%10p] ", bucket);
bucket= bucket->next;
}
- printk("\n");
+ printf("\n");
}
- printk("\n");
+ printf("\n");
}
+ */
diff --git a/batman/linux/modules/hash.h b/batman/linux/modules/hash.h
index a87cdcb..a778f04 100644
--- a/batman/linux/modules/hash.h
+++ b/batman/linux/modules/hash.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2006 B.A.T.M.A.N. contributors:
+/*
+ * Copyright (C) 2006-2008 B.A.T.M.A.N. contributors:
* Simon Wunderlich, 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.
@@ -16,6 +16,11 @@
* 02110-1301, USA
*
*/
+
+
+
+
+
#ifndef _BATMAN_HASH_H
#define _BATMAN_HASH_H
--
1.6.0.1
14 years, 4 months
[B.A.T.M.A.N.] [PATCH] Send TUNNEL_IP_REQUEST as response of TUNNEL_IP_REQUEST
by Sven Eckelmann
Userspace gateway sends TUNNEL_IP_REQUEST when he receives TUNNEL_IP_REQUEST
and will not start to send new IP as TUNNEL_DATA
---
batman/linux/modules/gateway.c | 1 -
batman/linux/modules/gateway24.c | 1 -
2 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/batman/linux/modules/gateway.c b/batman/linux/modules/gateway.c
index 154497e..9411575 100644
--- a/batman/linux/modules/gateway.c
+++ b/batman/linux/modules/gateway.c
@@ -405,7 +405,6 @@ static int packet_recv_thread(void *data)
if(client_data != NULL) {
- buffer[0] = TUNNEL_DATA;
memcpy( &buffer[1], &client_data->vip_addr, sizeof( client_data->vip_addr ) );
iov.iov_base = buffer;
diff --git a/batman/linux/modules/gateway24.c b/batman/linux/modules/gateway24.c
index 585fe85..9b60fe4 100644
--- a/batman/linux/modules/gateway24.c
+++ b/batman/linux/modules/gateway24.c
@@ -385,7 +385,6 @@ static int packet_recv_thread(void *data)
if(client_data != NULL) {
- buffer[0] = TUNNEL_DATA;
memcpy( &buffer[1], &client_data->vip_addr, sizeof( client_data->vip_addr ) );
iov.iov_base = buffer;
--
1.6.0.1
14 years, 4 months
[B.A.T.M.A.N.] [PATCH] Don't use iterator of wip_hash to delete bucket in vip_hash
by Sven Eckelmann
The hash iterator of a hash has different pointers inside of it. When somebody
tries to delete a bucket in another hash with hash_remove_bucket most data will
be changed in the hash the iterator belongs and not the target hash.
---
batman/linux/modules/gateway.c | 2 +-
batman/linux/modules/gateway24.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/batman/linux/modules/gateway.c b/batman/linux/modules/gateway.c
index 1f2dc24..fcf4dd2 100644
--- a/batman/linux/modules/gateway.c
+++ b/batman/linux/modules/gateway.c
@@ -383,7 +383,7 @@ static int packet_recv_thread(void *data)
if( ( jiffies - client_data->last_keep_alive ) / HZ > LEASE_TIME ) {
hash_remove_bucket(wip_hash, hashit);
- hash_remove_bucket(vip_hash, hashit);
+ hash_remove(vip_hash, client_data);
tmp_entry = kmalloc(sizeof(struct free_client_data), GFP_KERNEL);
if(tmp_entry != NULL) {
diff --git a/batman/linux/modules/gateway24.c b/batman/linux/modules/gateway24.c
index a8d58e6..e26154b 100644
--- a/batman/linux/modules/gateway24.c
+++ b/batman/linux/modules/gateway24.c
@@ -364,7 +364,7 @@ static int packet_recv_thread(void *data)
if( ( jiffies - client_data->last_keep_alive ) / HZ > LEASE_TIME ) {
hash_remove_bucket(wip_hash, hashit);
- hash_remove_bucket(vip_hash, hashit);
+ hash_remove(vip_hash, client_data);
tmp_entry = kmalloc(sizeof(struct free_client_data), GFP_KERNEL);
if(tmp_entry != NULL) {
--
1.6.0.1
14 years, 4 months
[B.A.T.M.A.N.] [PATCH] Allow unoptimized builds of batgat
by Sven Eckelmann
Currently htons is a functions provided by userspace libraries and will only be
replaced by a special builtin functions of gcc when optimization is enabled.
Linux v2.6.27-rc2-497-gbc2aa80 will provide these function symbols as macros
for in-kernel usage.
---
batman/linux/modules/gateway.c | 4 ++--
batman/linux/modules/gateway24.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/batman/linux/modules/gateway.c b/batman/linux/modules/gateway.c
index 9411575..41d75b5 100644
--- a/batman/linux/modules/gateway.c
+++ b/batman/linux/modules/gateway.c
@@ -313,7 +313,7 @@ static int packet_recv_thread(void *data)
server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = INADDR_ANY;
- server_addr.sin_port = htons( (unsigned short) BATMAN_PORT );
+ server_addr.sin_port = __constant_htons( (unsigned short) BATMAN_PORT );
if ( ( sock_create_kern( PF_INET, SOCK_RAW, IPPROTO_RAW, &inet_sock ) ) < 0 ) {
@@ -551,7 +551,7 @@ static int bat_netdev_xmit( struct sk_buff *skb, struct net_device *dev )
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = client_data->wip_addr;
- sa.sin_port = htons( (unsigned short)BATMAN_PORT );
+ sa.sin_port = __constant_htons( (unsigned short)BATMAN_PORT );
msg.msg_flags = MSG_NOSIGNAL | MSG_DONTWAIT;
msg.msg_name = &sa;
diff --git a/batman/linux/modules/gateway24.c b/batman/linux/modules/gateway24.c
index 9b60fe4..dbd1f42 100644
--- a/batman/linux/modules/gateway24.c
+++ b/batman/linux/modules/gateway24.c
@@ -291,7 +291,7 @@ static int packet_recv_thread(void *data)
server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = INADDR_ANY;
- server_addr.sin_port = htons( (unsigned short) BATMAN_PORT );
+ server_addr.sin_port = __constant_htons( (unsigned short) BATMAN_PORT );
if ( ( sock_create( PF_INET, SOCK_RAW, IPPROTO_RAW, &inet_sock ) ) < 0 ) {
@@ -509,7 +509,7 @@ static int bat_netdev_xmit( struct sk_buff *skb, struct net_device *dev )
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = client_data->wip_addr;
- sa.sin_port = htons( (unsigned short)BATMAN_PORT );
+ sa.sin_port = __constant_htons( (unsigned short)BATMAN_PORT );
msg.msg_flags = MSG_NOSIGNAL | MSG_DONTWAIT;
msg.msg_name = &sa;
--
1.6.0.1
14 years, 4 months