performance patches (v2)
Hi,
I continued improving the the performance patches which results in the first usable version. I tested it in a VM environment as well as on real hardware and did not encounter problematic behavior anymore.
Changes since v1:
* code rebased on top of the trunk
* orig_node NULL pointer dereference fixed (thanks Linus)
* bcast_own / bcast_own_sum are now protected by a spinlock
* orig_node reference count had to be increased in transtable_search()
Known issues:
* bonding / alternating candidates are not secured by refcounting [see find_router()] - ideas welcome
Give this code a try and let me know what you find.
Regards,
Marek
PATCH 1/9 batman-adv: protect neighbor nodes with reference counters
--- batman-adv/originator.c | 20 +++++++++++++++----- batman-adv/originator.h | 8 +++++--- batman-adv/routing.c | 7 +++++++ batman-adv/types.h | 1 + 4 files changed, 28 insertions(+), 8 deletions(-)
batman-adv/originator.c +15 -5
@@ -59,9 +59,18 @@ err:return 0 ; } -struct neigh_node * -create_neighbor (struct orig_node *orig_node,struct orig_node *orig_neigh_node, -uint8_t *neigh,struct batman_if *if_incoming) +void neigh_node_free_ref (struct kref *refcount) +{ +struct neigh_node *neigh_node; + + neigh_node = container_of(refcount, struct neigh_node, refcount); +kfree (neigh_node); +} + +struct neigh_node *create_neighbor (struct orig_node *orig_node, +struct orig_node *orig_neigh_node, +uint8_t *neigh, +struct batman_if *if_incoming) {struct bat_priv *bat_priv =netdev_priv (if_incoming->soft_iface);struct neigh_node *neigh_node;
@@ -78,6 +87,7 @@ create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,memcpy (neigh_node->addr, neigh,ETH_ALEN ); neigh_node->orig_node = orig_neigh_node; neigh_node->if_incoming = if_incoming; +kref_init (&neigh_node->refcount);list_add_tail (&neigh_node->list, &orig_node->neigh_list);return neigh_node;
@@ -95,7 +105,7 @@ static void free_orig_node(void *data, void *arg) neigh_node = list_entry(list_pos, struct neigh_node, list);list_del (list_pos); -kfree (neigh_node); +kref_put (&neigh_node->refcount, neigh_node_free_ref); }frag_list_free (&orig_node->frag_list);
@@ -228,7 +238,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, neigh_purged = true;list_del (list_pos); -kfree (neigh_node); +kref_put (&neigh_node->refcount, neigh_node_free_ref); }else {if ((*best_neigh_node ==NULL ) || (neigh_node->tq_avg > (*best_neigh_node)->tq_avg))
batman-adv/originator.h +5 -3
@@ -26,9 +26,11 @@ int originator_init(struct bat_priv *bat_priv);void originator_free (struct bat_priv *bat_priv);void purge_orig_ref (struct bat_priv *bat_priv);struct orig_node *get_orig_node (struct bat_priv *bat_priv,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); +struct neigh_node *create_neighbor (struct orig_node *orig_node, +struct orig_node *orig_neigh_node, +uint8_t *neigh, +struct batman_if *if_incoming); +void neigh_node_free_ref (struct kref *refcount);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);
batman-adv/routing.c +7 -0
@@ -82,6 +82,8 @@ static void update_route(struct bat_priv *bat_priv,struct neigh_node *neigh_node, unsigned char *hna_buff, int hna_buff_len) { + struct neigh_node *neigh_node_tmp; +/* route deleted */ if ((orig_node->router !=NULL ) && (neigh_node ==NULL )) {
@@ -108,7 +110,12 @@ static void update_route(struct bat_priv *bat_priv, orig_node->router->addr); } +if (neigh_node) +kref_get (&neigh_node->refcount); + neigh_node_tmp = orig_node->router; orig_node->router = neigh_node; +if (neigh_node_tmp) +kref_put (&neigh_node_tmp->refcount, neigh_node_free_ref); }
batman-adv/types.h +1 -0
@@ -115,6 +115,7 @@ struct neigh_node {struct neigh_node *next_bond_candidate;unsigned long last_valid;TYPE_OF_WORD real_bits[NUM_WORDS ]; +struct kref refcount;struct orig_node *orig_node;struct batman_if *if_incoming; };
Signature · 1 line
1.7.2.3
PATCH 2/9 batman-adv: convert neighbor list to hlist
In reply to Marek Lindner--- batman-adv/originator.c | 28 +++++++++++++++------------- batman-adv/routing.c | 29 ++++++++++++++++++----------- batman-adv/types.h | 4 ++-- 3 files changed, 35 insertions(+), 26 deletions(-)
batman-adv/originator.c +15 -13
@@ -82,29 +82,28 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node,if (!neigh_node)return NULL ; -INIT_LIST_HEAD (&neigh_node->list); +INIT_HLIST_NODE (&neigh_node->list);memcpy (neigh_node->addr, neigh,ETH_ALEN ); neigh_node->orig_node = orig_neigh_node; neigh_node->if_incoming = if_incoming;kref_init (&neigh_node->refcount); -list_add_tail (&neigh_node->list, &orig_node->neigh_list); +hlist_add_head (&neigh_node->list, &orig_node->neigh_list);return neigh_node; }static void free_orig_node (void *data,void *arg) { -struct list_head *list_pos, *list_pos_tmp; +struct hlist_node *node, *node_tmp;struct neigh_node *neigh_node;struct orig_node *orig_node = (struct orig_node *)data;struct bat_priv *bat_priv = (struct bat_priv *)arg;/* for all neighbors towards this originator ... */ -list_for_each_safe (list_pos, list_pos_tmp, &orig_node->neigh_list) { - neigh_node = list_entry(list_pos, struct neigh_node, list); - -list_del (list_pos); +hlist_for_each_entry_safe (neigh_node, node, node_tmp, + &orig_node->neigh_list, list) { +hlist_del (&neigh_node->list);kref_put (&neigh_node->refcount, neigh_node_free_ref); }
@@ -152,7 +151,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)if (!orig_node)return NULL ; -INIT_LIST_HEAD (&orig_node->neigh_list); +INIT_HLIST_HEAD (&orig_node->neigh_list);memcpy (orig_node->orig, addr,ETH_ALEN ); orig_node->router =NULL ;
@@ -207,15 +206,15 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,struct orig_node *orig_node, struct neigh_node **best_neigh_node) { - struct list_head *list_pos, *list_pos_tmp; + struct hlist_node *node, *node_tmp;struct neigh_node *neigh_node;bool neigh_purged = false; *best_neigh_node =NULL ;/* for all neighbors towards this originator ... */ -list_for_each_safe (list_pos, list_pos_tmp, &orig_node->neigh_list) { - neigh_node = list_entry(list_pos, struct neigh_node, list); +hlist_for_each_entry_safe (neigh_node, node, node_tmp, + &orig_node->neigh_list, list) { if ((time_after(jiffies, neigh_node->last_valid + PURGE_TIMEOUT * HZ)) ||
@@ -237,7 +236,8 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, (neigh_node->last_valid / HZ)); neigh_purged = true; -list_del (list_pos); + +hlist_del (&neigh_node->list);kref_put (&neigh_node->refcount, neigh_node_free_ref); }else { if ((*best_neigh_node == NULL) ||
@@ -328,6 +328,7 @@ void purge_orig_ref(struct bat_priv *bat_priv)int orig_seq_print_text (struct seq_file *seq,void *offset) {HASHIT (hashit); +struct hlist_node *node;struct element_t *bucket;struct net_device *net_dev = (struct net_device *)seq->private;struct bat_priv *bat_priv =netdev_priv (net_dev);
@@ -379,7 +380,8 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) orig_node->router->tq_avg, orig_node->router->addr, orig_node->router->if_incoming->net_dev->name); -list_for_each_entry (neigh_node, &orig_node->neigh_list, list) { +hlist_for_each_entry (neigh_node, node, + &orig_node->neigh_list, list) {seq_printf (seq," %pM (%3i)" , neigh_node->addr, neigh_node->tq_avg); }
batman-adv/routing.c +18 -11
@@ -142,12 +142,12 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, {struct bat_priv *bat_priv =netdev_priv (if_incoming->soft_iface);struct neigh_node *neigh_node =NULL , *tmp_neigh_node =NULL ; +struct hlist_node *node;unsigned char total_count;if (orig_node == orig_neigh_node) { -list_for_each_entry (tmp_neigh_node, - &orig_node->neigh_list, - list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_node->neigh_list, list) { if (compare_orig(tmp_neigh_node->addr, orig_neigh_node->orig) &&
@@ -167,8 +167,8 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, neigh_node->last_valid = jiffies; }else {/* find packet count of corresponding one hop neighbor */ -list_for_each_entry (tmp_neigh_node, - &orig_neigh_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_neigh_node->neigh_list, list) { if (compare_orig(tmp_neigh_node->addr, orig_neigh_node->orig) &&
@@ -253,12 +253,14 @@ static void update_orig(struct bat_priv *bat_priv, char is_duplicate) {struct neigh_node *neigh_node =NULL , *tmp_neigh_node =NULL ; +struct hlist_node *node;int tmp_hna_buff_len;bat_dbg (DBG_BATMAN , bat_priv,"update_originator(): " "Searching and updating originator entry of received packet\n" ); -list_for_each_entry (tmp_neigh_node, &orig_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_node->neigh_list, list) {if (compare_orig (tmp_neigh_node->addr, ethhdr->h_source) && (tmp_neigh_node->if_incoming == if_incoming)) { neigh_node = tmp_neigh_node;
@@ -384,6 +386,7 @@ static char count_real_packets(struct ethhdr *ethhdr,struct bat_priv *bat_priv =netdev_priv (if_incoming->soft_iface);struct orig_node *orig_node;struct neigh_node *tmp_neigh_node; +struct hlist_node *node;char is_duplicate =0 ;int32_t seq_diff;int need_update =0 ;
@@ -400,7 +403,8 @@ static char count_real_packets(struct ethhdr *ethhdr, &orig_node->batman_seqno_reset))return -1 ; -list_for_each_entry (tmp_neigh_node, &orig_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_node->neigh_list, list) { is_duplicate |= get_bit_status(tmp_neigh_node->real_bits, orig_node->last_real_seqno,
@@ -452,6 +456,7 @@ void update_bonding_candidates(struct bat_priv *bat_priv,int candidates;int interference_candidate;int best_tq; +struct hlist_node *node, *node2;struct neigh_node *tmp_neigh_node, *tmp_neigh_node2;struct neigh_node *first_candidate, *last_candidate;
@@ -471,13 +476,15 @@ void update_bonding_candidates(struct bat_priv *bat_priv,* as "bonding partner" */ /* first, zero the list */ -list_for_each_entry (tmp_neigh_node, &orig_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_node->neigh_list, list) { tmp_neigh_node->next_bond_candidate =NULL ; } first_candidate =NULL ; last_candidate =NULL ; -list_for_each_entry (tmp_neigh_node, &orig_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_node->neigh_list, list) {/* only consider if it has the same primary address ... */ if (memcmp(orig_node->orig,
@@ -494,8 +501,8 @@ void update_bonding_candidates(struct bat_priv *bat_priv,* select this candidate because of possible interference. */ interference_candidate =0 ; -list_for_each_entry (tmp_neigh_node2, - &orig_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node2, node2, + &orig_node->neigh_list, list) {if (tmp_neigh_node2 == tmp_neigh_node)continue ;
batman-adv/types.h +2 -2
@@ -83,7 +83,7 @@ struct orig_node {uint8_t last_ttl;TYPE_OF_WORD bcast_bits[NUM_WORDS ];uint32_t last_bcast_seqno; -struct list_head neigh_list; +struct hlist_head neigh_list;struct list_head frag_list;unsigned long last_frag_packet;struct {
@@ -105,7 +105,7 @@ struct gw_node {* @last_valid: when last packet via this neighbor was received */ struct neigh_node { -struct list_head list; +struct hlist_node list;uint8_t addr[ETH_ALEN ];uint8_t real_packet_count;uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE ];
Signature · 1 line
1.7.2.3
PATCH 3/9 batman-adv: protect neighbor list with rcu locks
In reply to Marek Lindner--- batman-adv/originator.c | 31 ++++++++++++++++++++++++++----- batman-adv/routing.c | 13 +++++++++++++ batman-adv/types.h | 2 ++ 3 files changed, 41 insertions(+), 5 deletions(-)
batman-adv/originator.c +26 -5
@@ -67,6 +67,14 @@ void neigh_node_free_ref(struct kref *refcount)kfree (neigh_node); } +static void neigh_node_free_rcu (struct rcu_head *rcu) +{ +struct neigh_node *neigh_node; + + neigh_node = container_of(rcu, struct neigh_node, rcu); +kref_put (&neigh_node->refcount, neigh_node_free_ref); +} + struct neigh_node *create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, uint8_t *neigh,
@@ -89,7 +97,9 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node, neigh_node->if_incoming = if_incoming;kref_init (&neigh_node->refcount); -hlist_add_head (&neigh_node->list, &orig_node->neigh_list); +spin_lock_bh (&orig_node->neigh_list_lock); +hlist_add_head_rcu (&neigh_node->list, &orig_node->neigh_list); +spin_unlock_bh (&orig_node->neigh_list_lock);return neigh_node; }
@@ -100,13 +110,17 @@ static void free_orig_node(void *data, void *arg)struct orig_node *orig_node = (struct orig_node *)data;struct bat_priv *bat_priv = (struct bat_priv *)arg; +spin_lock_bh (&orig_node->neigh_list_lock); +/* for all neighbors towards this originator ... */ hlist_for_each_entry_safe (neigh_node, node, node_tmp, &orig_node->neigh_list, list) { -hlist_del (&neigh_node->list); -kref_put (&neigh_node->refcount, neigh_node_free_ref); +hlist_del_rcu (&neigh_node->list); +call_rcu (&neigh_node->rcu, neigh_node_free_rcu); } +spin_unlock_bh (&orig_node->neigh_list_lock); +frag_list_free (&orig_node->frag_list);hna_global_del_orig (bat_priv, orig_node,"originator timed out" );
@@ -152,6 +166,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)return NULL ;INIT_HLIST_HEAD (&orig_node->neigh_list); +spin_lock_init (&orig_node->neigh_list_lock);memcpy (orig_node->orig, addr,ETH_ALEN ); orig_node->router =NULL ;
@@ -212,6 +227,8 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, *best_neigh_node =NULL ; +spin_lock_bh (&orig_node->neigh_list_lock); +/* for all neighbors towards this originator ... */ hlist_for_each_entry_safe (neigh_node, node, node_tmp, &orig_node->neigh_list, list) {
@@ -237,14 +254,16 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, neigh_purged = true; -hlist_del (&neigh_node->list); -kref_put (&neigh_node->refcount, neigh_node_free_ref); +hlist_del_rcu (&neigh_node->list); +call_rcu (&neigh_node->rcu, neigh_node_free_rcu); }else {if ((*best_neigh_node ==NULL ) || (neigh_node->tq_avg > (*best_neigh_node)->tq_avg)) *best_neigh_node = neigh_node; } } + +spin_unlock_bh (&orig_node->neigh_list_lock);return neigh_purged; }
@@ -380,11 +399,13 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) orig_node->router->tq_avg, orig_node->router->addr, orig_node->router->if_incoming->net_dev->name); +rcu_read_lock ();hlist_for_each_entry (neigh_node, node, &orig_node->neigh_list, list) {seq_printf (seq," %pM (%3i)" , neigh_node->addr, neigh_node->tq_avg); } +rcu_read_unlock ();seq_printf (seq,"\n" ); batman_count++;
batman-adv/routing.c +13 -0
@@ -146,6 +146,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,unsigned char total_count;if (orig_node == orig_neigh_node) { +rcu_read_lock ();hlist_for_each_entry (tmp_neigh_node, node, &orig_node->neigh_list, list) {
@@ -154,6 +155,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, (tmp_neigh_node->if_incoming == if_incoming)) neigh_node = tmp_neigh_node; } +rcu_read_unlock ();if (!neigh_node) neigh_node = create_neighbor(orig_node,
@@ -167,6 +169,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, neigh_node->last_valid = jiffies; }else {/* find packet count of corresponding one hop neighbor */ +rcu_read_lock ();hlist_for_each_entry (tmp_neigh_node, node, &orig_neigh_node->neigh_list, list) {
@@ -175,6 +178,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, (tmp_neigh_node->if_incoming == if_incoming)) neigh_node = tmp_neigh_node; } +rcu_read_unlock ();if (!neigh_node) neigh_node = create_neighbor(orig_neigh_node,
@@ -259,6 +263,7 @@ static void update_orig(struct bat_priv *bat_priv,bat_dbg (DBG_BATMAN , bat_priv,"update_originator(): " "Searching and updating originator entry of received packet\n" ); +rcu_read_lock ();hlist_for_each_entry (tmp_neigh_node, node, &orig_node->neigh_list, list) { if (compare_orig(tmp_neigh_node->addr, ethhdr->h_source) &&
@@ -275,6 +280,7 @@ static void update_orig(struct bat_priv *bat_priv, tmp_neigh_node->tq_avg =ring_buffer_avg (tmp_neigh_node->tq_recv); } +rcu_read_unlock ();if (!neigh_node) {struct orig_node *orig_tmp;
@@ -403,6 +409,7 @@ static char count_real_packets(struct ethhdr *ethhdr, &orig_node->batman_seqno_reset))return -1 ; +rcu_read_lock ();hlist_for_each_entry (tmp_neigh_node, node, &orig_node->neigh_list, list) {
@@ -424,6 +431,7 @@ static char count_real_packets(struct ethhdr *ethhdr, tmp_neigh_node->real_packet_count =bit_packet_count (tmp_neigh_node->real_bits); } +rcu_read_unlock ();if (need_update) { bat_dbg(DBG_BATMAN, bat_priv,
@@ -476,13 +484,17 @@ void update_bonding_candidates(struct bat_priv *bat_priv,* as "bonding partner" */ /* first, zero the list */ +rcu_read_lock ();hlist_for_each_entry (tmp_neigh_node, node, &orig_node->neigh_list, list) { tmp_neigh_node->next_bond_candidate =NULL ; } +rcu_read_unlock (); first_candidate =NULL ; last_candidate =NULL ; + +rcu_read_lock ();hlist_for_each_entry (tmp_neigh_node, node, &orig_node->neigh_list, list) {
@@ -536,6 +548,7 @@ void update_bonding_candidates(struct bat_priv *bat_priv, candidates++; } +rcu_read_unlock ();if (candidates >0 ) { first_candidate->next_bond_candidate = last_candidate;
batman-adv/types.h +2 -0
@@ -85,6 +85,7 @@ struct orig_node {uint32_t last_bcast_seqno;struct hlist_head neigh_list;struct list_head frag_list; +spinlock_t neigh_list_lock;/* protects neighbor list */ unsigned long last_frag_packet;struct {uint8_t candidates;
@@ -116,6 +117,7 @@ struct neigh_node {unsigned long last_valid;TYPE_OF_WORD real_bits[NUM_WORDS ];struct kref refcount; +struct rcu_head rcu;struct orig_node *orig_node;struct batman_if *if_incoming; };
Signature · 1 line
1.7.2.3
PATCH 4/9 batman-adv: remove hash resize functions
In reply to Marek Lindner--- batman-adv/hash.h | 38 -------------------------------------- batman-adv/originator.c | 14 +------------- batman-adv/translation-table.c | 32 ++------------------------------ 3 files changed, 3 insertions(+), 81 deletions(-)
batman-adv/hash.h +0 -38
@@ -181,44 +181,6 @@ static inline void *hash_find(struct hashtable_t *hash,return NULL ; } -/* resize the hash, returns the pointer to the new hash or NULL on -* error. removes the old hash on success */ -static inline struct hashtable_t *hash_resize (struct hashtable_t *hash, -hashdata_choose_cb choose, -int size) -{ -struct hashtable_t *new_hash; -struct hlist_head *head, *new_head; -struct hlist_node *walk, *safe; -struct element_t *bucket; -int i, new_index; - -/* initialize a new hash with the new size */ - new_hash =hash_new (size); - -if (new_hash ==NULL ) -return NULL ; - -/* copy the elements */ -for (i =0 ; i < hash->size; i++) { - head = &hash->table[i]; - -hlist_for_each_safe (walk, safe, head) { - bucket = hlist_entry(walk, struct element_t, hlist); - - new_index =choose (bucket->data, size); - new_head = &new_hash->table[new_index]; - -hlist_del (walk); -hlist_add_head (walk, new_head); - } - } - -hash_destroy (hash); - -return new_hash; -} -/* iterate though the hash. First element is selected if an iterator * initialized with HASHIT() is supplied as iter. Use the returned * (or supplied) iterator to access the elements until hash_iterate returns
batman-adv/originator.c +1 -13
@@ -45,7 +45,7 @@ int originator_init(struct bat_priv *bat_priv)return 1 ;spin_lock_bh (&bat_priv->orig_hash_lock); - bat_priv->orig_hash =hash_new (128 ); + bat_priv->orig_hash =hash_new (1024 );if (!bat_priv->orig_hash) goto err;
@@ -147,7 +147,6 @@ void originator_free(struct bat_priv *bat_priv)struct orig_node *get_orig_node (struct bat_priv *bat_priv,uint8_t *addr) {struct orig_node *orig_node; -struct hashtable_t *swaphash;int size;int hash_added;
@@ -196,17 +195,6 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)if (hash_added <0 ) goto free_bcast_own_sum; -if (bat_priv->orig_hash->elements *4 > bat_priv->orig_hash->size) { - swaphash =hash_resize (bat_priv->orig_hash, choose_orig, - bat_priv->orig_hash->size *2 ); - -if (!swaphash) -bat_dbg (DBG_BATMAN , bat_priv, -"Couldn't resize orig hash table\n" ); -else - bat_priv->orig_hash = swaphash; - } -return orig_node; free_bcast_own_sum:kfree (orig_node->bcast_own_sum);
batman-adv/translation-table.c +2 -30
@@ -42,7 +42,7 @@ int hna_local_init(struct bat_priv *bat_priv)if (bat_priv->hna_local_hash)return 1 ; - bat_priv->hna_local_hash =hash_new (128 ); + bat_priv->hna_local_hash =hash_new (1024 );if (!bat_priv->hna_local_hash)return 0 ;
@@ -58,7 +58,6 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr)struct bat_priv *bat_priv =netdev_priv (soft_iface);struct hna_local_entry *hna_local_entry;struct hna_global_entry *hna_global_entry; -struct hashtable_t *swaphash;int required_bytes;spin_lock_bh (&bat_priv->hna_lhash_lock);
@@ -113,17 +112,6 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr) bat_priv->num_local_hna++;atomic_set (&bat_priv->hna_local_changed,1 ); -if (bat_priv->hna_local_hash->elements *4 > - bat_priv->hna_local_hash->size) { - swaphash =hash_resize (bat_priv->hna_local_hash, choose_orig, - bat_priv->hna_local_hash->size *2 ); - -if (!swaphash) -pr_err ("Couldn't resize local hna hash table\n" ); -else - bat_priv->hna_local_hash = swaphash; - } -spin_unlock_bh (&bat_priv->hna_lhash_lock);/* remove address from global hash if present */
@@ -302,7 +290,7 @@ int hna_global_init(struct bat_priv *bat_priv)if (bat_priv->hna_global_hash)return 1 ; - bat_priv->hna_global_hash =hash_new (128 ); + bat_priv->hna_global_hash =hash_new (1024 );if (!bat_priv->hna_global_hash)return 0 ;
@@ -316,7 +304,6 @@ void hna_global_add_orig(struct bat_priv *bat_priv, {struct hna_global_entry *hna_global_entry;struct hna_local_entry *hna_local_entry; -struct hashtable_t *swaphash;int hna_buff_count =0 ;unsigned char *hna_ptr;
@@ -382,21 +369,6 @@ void hna_global_add_orig(struct bat_priv *bat_priv, orig_node->hna_buff_len = hna_buff_len; } } - -spin_lock_bh (&bat_priv->hna_ghash_lock); - -if (bat_priv->hna_global_hash->elements *4 > - bat_priv->hna_global_hash->size) { - swaphash =hash_resize (bat_priv->hna_global_hash, choose_orig, - bat_priv->hna_global_hash->size *2 ); - -if (!swaphash) -pr_err ("Couldn't resize global hna hash table\n" ); -else - bat_priv->hna_global_hash = swaphash; - } - -spin_unlock_bh (&bat_priv->hna_ghash_lock); }int hna_global_seq_print_text (struct seq_file *seq,void *offset)
Signature · 1 line
1.7.2.3
PATCH 5/9 batman-adv: protect each hash row with rcu locks
In reply to Marek Lindner--- batman-adv/hash.c | 46 +++++++++++---- batman-adv/hash.h | 125 ++++++++++++++++++++++++++-------------- batman-adv/icmp_socket.c | 2 + batman-adv/originator.c | 2 + batman-adv/routing.c | 12 ++++ batman-adv/translation-table.c | 15 +++++ batman-adv/unicast.c | 7 ++- batman-adv/vis.c | 4 + 8 files changed, 157 insertions(+), 56 deletions(-)
batman-adv/hash.c +34 -12
@@ -29,13 +29,16 @@ static void hash_init(struct hashtable_t *hash) hash->elements =0 ; -for (i =0 ; i < hash->size; i++) +for (i =0 ; i < hash->size; i++) {INIT_HLIST_HEAD (&hash->table[i]); +spin_lock_init (&hash->list_locks[i]); + } }/* free only the hashtable and the hash itself. */ void hash_destroy (struct hashtable_t *hash) { +kfree (hash->list_locks);kfree (hash->table);kfree (hash); }
@@ -45,22 +48,35 @@ struct hashtable_t *hash_new(int size) {struct hashtable_t *hash; - hash =kmalloc (sizeof (struct hashtable_t ) ,GFP_ATOMIC ); - -if (hash ==NULL ) + hash =kmalloc (sizeof (struct hashtable_t ),GFP_ATOMIC ); +if (!hash)return NULL ; - hash->size = size; hash->table =kmalloc (sizeof (struct element_t *) * size,GFP_ATOMIC ); +if (!hash->table) + goto free_hash; -if (hash->table ==NULL ) { -kfree (hash); -return NULL ; - } + hash->list_locks =kmalloc (sizeof (spinlock_t) * size,GFP_ATOMIC ); +if (!hash->list_locks) + goto free_table; + hash->size = size;hash_init (hash); -return hash; + +free_table: +kfree (hash->table); +free_hash: +kfree (hash); +return NULL ; +} + +void bucket_free_rcu (struct rcu_head *rcu) +{ +struct element_t *bucket; + + bucket = container_of(rcu, struct element_t, rcu); +kfree (bucket); }/* remove bucket (this might be used in hash_iterate() if you already found the
@@ -71,12 +87,18 @@ void *hash_remove_bucket(struct hashtable_t *hash, struct hash_it_t *hash_it_t) {void *data_save;struct element_t *bucket; +spinlock_t *list_lock; + + list_lock = &hash->list_locks[hash_it_t->index]; bucket = hlist_entry(hash_it_t->walk, struct element_t, hlist); data_save = bucket->data; -hlist_del (hash_it_t->walk); -kfree (bucket); +spin_lock_bh (list_lock); +hlist_del_rcu (hash_it_t->walk); +spin_unlock_bh (list_lock); + +call_rcu (&bucket->rcu, bucket_free_rcu); hash->elements--;return data_save;
batman-adv/hash.h +82 -43
227 lines not on this page · raw message
batman-adv/icmp_socket.c +2 -0
@@ -221,9 +221,11 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, goto dst_unreach;spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->dst)); +rcu_read_unlock ();if (!orig_node) goto unlock;
batman-adv/originator.c +2 -0
@@ -150,9 +150,11 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)int size;int hash_added; +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, addr)); +rcu_read_unlock ();if (orig_node)return orig_node;
batman-adv/routing.c +12 -0
@@ -850,9 +850,11 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,/* answer echo request (ping) */ /* get routing information */ spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->orig)); +rcu_read_unlock (); ret =NET_RX_DROP ; if ((orig_node != NULL) &&
@@ -912,9 +914,11 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,/* get routing information */ spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->orig)); +rcu_read_unlock (); ret =NET_RX_DROP ; if ((orig_node != NULL) &&
@@ -1006,9 +1010,11 @@ int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if)/* get routing information */ spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->dst)); +rcu_read_unlock ();if ((orig_node !=NULL ) && (orig_node->router !=NULL )) {
@@ -1079,9 +1085,11 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, router_orig->orig, ETH_ALEN) == 0) { primary_orig_node = router_orig; } else { +rcu_read_lock (); primary_orig_node =hash_find (bat_priv->orig_hash, compare_orig, choose_orig, router_orig->primary_addr); +rcu_read_unlock ();if (!primary_orig_node)return orig_node->router;
@@ -1184,9 +1192,11 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if,/* get routing information */ spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, unicast_packet->dest)); +rcu_read_unlock (); router =find_router (bat_priv, orig_node, recv_if);
@@ -1330,9 +1340,11 @@ int recv_bcast_packet(struct sk_buff *skb, struct batman_if *recv_if)return NET_RX_DROP ;spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, bcast_packet->orig)); +rcu_read_unlock ();if (orig_node ==NULL ) {spin_unlock_bh (&bat_priv->orig_hash_lock);
batman-adv/translation-table.c +15 -0
@@ -61,10 +61,12 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr)int required_bytes;spin_lock_bh (&bat_priv->hna_lhash_lock); +rcu_read_lock (); hna_local_entry = ((struct hna_local_entry *)hash_find (bat_priv->hna_local_hash, compare_orig, choose_orig, addr)); +rcu_read_unlock ();spin_unlock_bh (&bat_priv->hna_lhash_lock);if (hna_local_entry) {
@@ -117,9 +119,11 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr)/* remove address from global hash if present */ spin_lock_bh (&bat_priv->hna_ghash_lock); +rcu_read_lock (); hna_global_entry = ((struct hna_global_entry *)hash_find (bat_priv->hna_global_hash, compare_orig, choose_orig, addr)); +rcu_read_unlock ();if (hna_global_entry) _hna_global_del_orig(bat_priv, hna_global_entry,
@@ -237,9 +241,12 @@ void hna_local_remove(struct bat_priv *bat_priv,spin_lock_bh (&bat_priv->hna_lhash_lock); +rcu_read_lock (); hna_local_entry = (struct hna_local_entry *)hash_find (bat_priv->hna_local_hash, compare_orig, choose_orig, addr); +rcu_read_unlock (); +if (hna_local_entry)hna_local_del (bat_priv, hna_local_entry, message);
@@ -311,9 +318,11 @@ void hna_global_add_orig(struct bat_priv *bat_priv,spin_lock_bh (&bat_priv->hna_ghash_lock); hna_ptr = hna_buff + (hna_buff_count *ETH_ALEN ); +rcu_read_lock (); hna_global_entry = (struct hna_global_entry *)hash_find (bat_priv->hna_global_hash, compare_orig, choose_orig, hna_ptr); +rcu_read_unlock ();if (!hna_global_entry) {spin_unlock_bh (&bat_priv->hna_ghash_lock);
@@ -345,9 +354,11 @@ void hna_global_add_orig(struct bat_priv *bat_priv,spin_lock_bh (&bat_priv->hna_lhash_lock); hna_ptr = hna_buff + (hna_buff_count *ETH_ALEN ); +rcu_read_lock (); hna_local_entry = (struct hna_local_entry *)hash_find (bat_priv->hna_local_hash, compare_orig, choose_orig, hna_ptr); +rcu_read_unlock ();if (hna_local_entry) hna_local_del(bat_priv, hna_local_entry,
@@ -450,9 +461,11 @@ void hna_global_del_orig(struct bat_priv *bat_priv,while ((hna_buff_count +1 ) *ETH_ALEN <= orig_node->hna_buff_len) { hna_ptr = orig_node->hna_buff + (hna_buff_count *ETH_ALEN ); +rcu_read_lock (); hna_global_entry = (struct hna_global_entry *)hash_find (bat_priv->hna_global_hash, compare_orig, choose_orig, hna_ptr); +rcu_read_unlock ();if ((hna_global_entry) && (hna_global_entry->orig_node == orig_node))
@@ -488,9 +501,11 @@ struct orig_node *transtable_search(struct bat_priv *bat_priv, uint8_t *addr)struct hna_global_entry *hna_global_entry;spin_lock_bh (&bat_priv->hna_ghash_lock); +rcu_read_lock (); hna_global_entry = (struct hna_global_entry *)hash_find (bat_priv->hna_global_hash, compare_orig, choose_orig, addr); +rcu_read_unlock ();spin_unlock_bh (&bat_priv->hna_ghash_lock);if (!hna_global_entry)
batman-adv/unicast.c +6 -1
@@ -179,9 +179,11 @@ int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, *new_skb =NULL ;spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, unicast_packet->orig)); +rcu_read_unlock ();if (!orig_node) {pr_debug ("couldn't find originator in orig_hash\n" );
@@ -285,11 +287,14 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)/* get routing information */ if (is_multicast_ether_addr (ethhdr->h_dest)) orig_node = (struct orig_node *)gw_get_selected (bat_priv); -else +else { +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, ethhdr->h_dest)); +rcu_read_lock (); + }/* check for hna host */ if (!orig_node)
batman-adv/vis.c +4 -0
@@ -364,8 +364,10 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, sizeof(struct vis_packet));memcpy (search_packet->vis_orig, vis_packet->vis_orig,ETH_ALEN ); +rcu_read_lock (); old_info =hash_find (bat_priv->vis_hash, vis_info_cmp, vis_info_choose, &search_elem); +rcu_read_unlock ();kfree_skb (search_elem.skb_packet);if (old_info !=NULL ) {
@@ -717,9 +719,11 @@ static void unicast_vis_packet(struct bat_priv *bat_priv,spin_lock_bh (&bat_priv->orig_hash_lock); packet = (struct vis_packet *)info->skb_packet->data; +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, packet->target_orig)); +rcu_read_unlock ();if ((!orig_node) || (!orig_node->router)) goto out;
Signature · 1 line
1.7.2.3
PATCH 6/9 batman-adv: protect originator nodes with reference counters
In reply to Marek Lindner--- batman-adv/originator.c | 34 +++++++++++++++++++++++++++------- batman-adv/originator.h | 1 + batman-adv/routing.c | 39 ++++++++++++++++++++++++++------------- batman-adv/types.h | 2 ++ 4 files changed, 56 insertions(+), 20 deletions(-)
batman-adv/originator.c +27 -7
@@ -103,12 +103,13 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node,return neigh_node; } -static void free_orig_node (void *data,void *arg) +void orig_node_free_ref (struct kref *refcount) {struct hlist_node *node, *node_tmp;struct neigh_node *neigh_node; -struct orig_node *orig_node = (struct orig_node *)data; -struct bat_priv *bat_priv = (struct bat_priv *)arg; +struct orig_node *orig_node; + + orig_node = container_of(refcount, struct orig_node, refcount);spin_lock_bh (&orig_node->neigh_list_lock);
@@ -122,7 +123,8 @@ static void free_orig_node(void *data, void *arg)spin_unlock_bh (&orig_node->neigh_list_lock);frag_list_free (&orig_node->frag_list); -hna_global_del_orig (bat_priv, orig_node,"originator timed out" ); +hna_global_del_orig (orig_node->bat_priv, orig_node, +"originator timed out" );kfree (orig_node->bcast_own);kfree (orig_node->bcast_own_sum);
@@ -131,13 +133,25 @@ static void free_orig_node(void *data, void *arg)void originator_free (struct bat_priv *bat_priv) { +HASHIT (hashit); +struct element_t *bucket; +struct orig_node *orig_node; +if (!bat_priv->orig_hash)return ;cancel_delayed_work_sync (&bat_priv->orig_work);spin_lock_bh (&bat_priv->orig_hash_lock); -hash_delete (bat_priv->orig_hash, free_orig_node, bat_priv); + +while (hash_iterate (bat_priv->orig_hash, &hashit)) { + bucket = hlist_entry(hashit.walk, struct element_t, hlist); + orig_node = bucket->data; + +hash_remove_bucket (bat_priv->orig_hash, &hashit); +kref_put (&orig_node->refcount, orig_node_free_ref); + } + bat_priv->orig_hash =NULL ;spin_unlock_bh (&bat_priv->orig_hash_lock); }
@@ -156,8 +170,10 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) addr));rcu_read_unlock (); -if (orig_node) +if (orig_node) { +kref_get (&orig_node->refcount);return orig_node; + }bat_dbg (DBG_BATMAN , bat_priv,"Creating new originator: %pM\n" , addr);
@@ -168,7 +184,9 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)INIT_HLIST_HEAD (&orig_node->neigh_list);spin_lock_init (&orig_node->neigh_list_lock); +kref_init (&orig_node->refcount); + orig_node->bat_priv = bat_priv;memcpy (orig_node->orig, addr,ETH_ALEN ); orig_node->router =NULL ; orig_node->hna_buff =NULL ;
@@ -197,6 +215,8 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)if (hash_added <0 ) goto free_bcast_own_sum; +/* extra reference for return */ +kref_get (&orig_node->refcount);return orig_node; free_bcast_own_sum:kfree (orig_node->bcast_own_sum);
@@ -302,7 +322,7 @@ static void _purge_orig(struct bat_priv *bat_priv)if (orig_node->gw_flags)gw_node_delete (bat_priv, orig_node);hash_remove_bucket (bat_priv->orig_hash, &hashit); -free_orig_node (orig_node, bat_priv); +kref_put (&orig_node->refcount, orig_node_free_ref); } if (time_after(jiffies, (orig_node->last_frag_packet +
batman-adv/originator.h +1 -0
@@ -25,6 +25,7 @@int originator_init (struct bat_priv *bat_priv);void originator_free (struct bat_priv *bat_priv);void purge_orig_ref (struct bat_priv *bat_priv); +void orig_node_free_ref (struct kref *refcount);struct orig_node *get_orig_node (struct bat_priv *bat_priv,uint8_t *addr); struct neigh_node *create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
batman-adv/routing.c +26 -13
@@ -291,6 +291,8 @@ static void update_orig(struct bat_priv *bat_priv, neigh_node =create_neighbor (orig_node, orig_tmp, ethhdr->h_source, if_incoming); + +kref_put (&orig_tmp->refcount, orig_node_free_ref);if (!neigh_node)return ; }else
@@ -399,7 +401,7 @@ static char count_real_packets(struct ethhdr *ethhdr,int set_mark; orig_node =get_orig_node (bat_priv, batman_packet->orig); -if (orig_node ==NULL ) +if (!orig_node)return 0 ; seq_diff = batman_packet->seqno - orig_node->last_real_seqno;
@@ -407,7 +409,7 @@ static char count_real_packets(struct ethhdr *ethhdr,/* signalize caller that the packet is to be dropped. */ if (window_protected (bat_priv, seq_diff, &orig_node->batman_seqno_reset)) -return -1 ; + goto err;rcu_read_lock (); hlist_for_each_entry(tmp_neigh_node, node,
@@ -440,7 +442,12 @@ static char count_real_packets(struct ethhdr *ethhdr, orig_node->last_real_seqno = batman_packet->seqno; } +kref_put (&orig_node->refcount, orig_node_free_ref);return is_duplicate; + +err: +kref_put (&orig_node->refcount, orig_node_free_ref); +return -1 ; }/* copy primary address for bonding */
@@ -657,7 +664,6 @@ void receive_bat_packet(struct ethhdr *ethhdr,int offset; orig_neigh_node =get_orig_node (bat_priv, ethhdr->h_source); -if (!orig_neigh_node)return ;
@@ -678,6 +684,7 @@ void receive_bat_packet(struct ethhdr *ethhdr,bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: " "originator packet from myself (via neighbor)\n" ); +kref_put (&orig_neigh_node->refcount, orig_node_free_ref);return ; }
@@ -689,7 +696,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, } orig_node =get_orig_node (bat_priv, batman_packet->orig); -if (orig_node ==NULL ) +if (!orig_node)return ; is_duplicate =count_real_packets (ethhdr, batman_packet, if_incoming);
@@ -698,13 +705,13 @@ void receive_bat_packet(struct ethhdr *ethhdr,bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: packet within seqno protection time " "(sender: %pM)\n" , ethhdr->h_source); -return ; + goto out; }if (batman_packet->tq ==0 ) {bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: originator packet with tq equal 0\n" ); -return ; + goto out; }/* avoid temporary routing loops */
@@ -718,7 +725,7 @@ void receive_bat_packet(struct ethhdr *ethhdr,bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: ignoring all rebroadcast packets that " "may make me loop (sender: %pM)\n" , ethhdr->h_source); -return ; + goto out; }/* if sender is a direct neighbor the sender mac equals
@@ -726,8 +733,8 @@ void receive_bat_packet(struct ethhdr *ethhdr, orig_neigh_node = (is_single_hop_neigh ? orig_node :get_orig_node (bat_priv, ethhdr->h_source)); -if (orig_neigh_node ==NULL ) -return ; +if (!orig_neigh_node) + goto out_neigh;/* drop packet if sender is not a direct neighbor and if we * don't route towards it */
@@ -735,7 +742,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, (orig_neigh_node->router == NULL)) {bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: OGM via unknown neighbor!\n" ); -return ; + goto out_neigh; } is_bidirectional = is_bidirectional_neigh(orig_node, orig_neigh_node,
@@ -763,26 +770,32 @@ void receive_bat_packet(struct ethhdr *ethhdr,bat_dbg (DBG_BATMAN , bat_priv,"Forwarding packet: " "rebroadcast neighbor packet with direct link flag\n" ); -return ; + goto out_neigh; }/* multihop originator */ if (!is_bidirectional) {bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: not received via bidirectional link\n" ); -return ; + goto out_neigh; }if (is_duplicate) {bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: duplicate packet received\n" ); -return ; + goto out_neigh; }bat_dbg (DBG_BATMAN , bat_priv,"Forwarding packet: rebroadcast originator packet\n" );schedule_forward_packet (orig_node, ethhdr, batman_packet,0 , hna_buff_len, if_incoming); + +out_neigh: +if (!is_single_hop_neigh) +kref_put (&orig_neigh_node->refcount, orig_node_free_ref); +out: +kref_put (&orig_node->refcount, orig_node_free_ref); }int recv_bat_packet (struct sk_buff *skb,struct batman_if *batman_if)
batman-adv/types.h +2 -0
@@ -86,6 +86,8 @@ struct orig_node {struct hlist_head neigh_list;struct list_head frag_list;spinlock_t neigh_list_lock;/* protects neighbor list */ +struct kref refcount; +struct bat_priv *bat_priv;unsigned long last_frag_packet;struct {uint8_t candidates;
Signature · 1 line
1.7.2.3
PATCH 7/9 batman-adv: replace orig_hash hash_iterate() with individual functions
In reply to Marek Lindner--- batman-adv/originator.c | 212 +++++++++++++++++++++++++++++++++-------------- batman-adv/routing.c | 32 ++++++-- batman-adv/vis.c | 157 ++++++++++++++++++++++------------ 3 files changed, 275 insertions(+), 126 deletions(-)
batman-adv/originator.c +150 -62
@@ -133,26 +133,44 @@ void orig_node_free_ref(struct kref *refcount)void originator_free (struct bat_priv *bat_priv) { -HASHIT (hashit); +struct hashtable_t *hash = bat_priv->orig_hash; +struct hlist_node *walk, *safe; +struct hlist_head *head;struct element_t *bucket; +spinlock_t *list_lock;struct orig_node *orig_node; +int i, ret; -if (!bat_priv->orig_hash) +if (!hash)return ;cancel_delayed_work_sync (&bat_priv->orig_work);spin_lock_bh (&bat_priv->orig_hash_lock); + bat_priv->orig_hash =NULL ; + +for (i =0 ; i < hash->size; i++) { +rcu_read_lock (); + ret =hlist_empty (&hash->table[i]); +rcu_read_unlock (); + +if (ret) +continue ; -while (hash_iterate (bat_priv->orig_hash, &hashit)) { - bucket = hlist_entry(hashit.walk, struct element_t, hlist); - orig_node = bucket->data; + head = &hash->table[i]; + list_lock = &hash->list_locks[i]; -hash_remove_bucket (bat_priv->orig_hash, &hashit); -kref_put (&orig_node->refcount, orig_node_free_ref); +spin_lock_bh (list_lock); +hlist_for_each_entry_safe (bucket, walk, safe, head, hlist) { +hlist_del_rcu (walk); + orig_node = bucket->data; +kref_put (&orig_node->refcount, orig_node_free_ref); +call_rcu (&bucket->rcu, bucket_free_rcu); + } +spin_unlock_bh (list_lock); } - bat_priv->orig_hash =NULL ; +hash_destroy (hash);spin_unlock_bh (&bat_priv->orig_hash_lock); }
@@ -307,27 +325,52 @@ static bool purge_orig_node(struct bat_priv *bat_priv,static void _purge_orig (struct bat_priv *bat_priv) { -HASHIT (hashit); +struct hashtable_t *hash = bat_priv->orig_hash; +struct hlist_node *walk, *safe; +struct hlist_head *head;struct element_t *bucket; +spinlock_t *list_lock;struct orig_node *orig_node; +int i, ret; + +if (!hash) +return ;spin_lock_bh (&bat_priv->orig_hash_lock);/* for all origins... */ -while (hash_iterate (bat_priv->orig_hash, &hashit)) { - bucket = hlist_entry(hashit.walk, struct element_t, hlist); - orig_node = bucket->data; - -if (purge_orig_node (bat_priv, orig_node)) { -if (orig_node->gw_flags) -gw_node_delete (bat_priv, orig_node); -hash_remove_bucket (bat_priv->orig_hash, &hashit); -kref_put (&orig_node->refcount, orig_node_free_ref); - } +for (i =0 ; i < hash->size; i++) { +rcu_read_lock (); + ret =hlist_empty (&hash->table[i]); +rcu_read_unlock (); + +if (ret) +continue ; -if (time_after (jiffies, (orig_node->last_frag_packet + + head = &hash->table[i]; + list_lock = &hash->list_locks[i]; + +spin_lock_bh (list_lock); +hlist_for_each_entry_safe (bucket, walk, safe, head, hlist) { + orig_node = bucket->data; + +if (purge_orig_node (bat_priv, orig_node)) { +if (orig_node->gw_flags) +gw_node_delete (bat_priv, orig_node); +hlist_del_rcu (walk); +kref_put (&orig_node->refcount, + orig_node_free_ref); +call_rcu (&bucket->rcu, bucket_free_rcu); + hash->elements--; +continue ; + } + +if (time_after (jiffies, (orig_node->last_frag_packet +msecs_to_jiffies (FRAG_TIMEOUT )))) -frag_list_free (&orig_node->frag_list); +frag_list_free (&orig_node->frag_list); + + } +spin_unlock_bh (list_lock); }spin_unlock_bh (&bat_priv->orig_hash_lock);
@@ -356,16 +399,18 @@ void purge_orig_ref(struct bat_priv *bat_priv)int orig_seq_print_text (struct seq_file *seq,void *offset) { -HASHIT (hashit); -struct hlist_node *node; -struct element_t *bucket;struct net_device *net_dev = (struct net_device *)seq->private;struct bat_priv *bat_priv =netdev_priv (net_dev); +struct hashtable_t *hash = bat_priv->orig_hash; +struct hlist_node *walk, *node; +struct hlist_head *head; +struct element_t *bucket;struct orig_node *orig_node;struct neigh_node *neigh_node;int batman_count =0 ;int last_seen_secs;int last_seen_msecs; +int i, ret;if ((!bat_priv->primary_if) || (bat_priv->primary_if->if_status !=IF_ACTIVE )) {
@@ -389,36 +434,48 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)spin_lock_bh (&bat_priv->orig_hash_lock); -while (hash_iterate (bat_priv->orig_hash, &hashit)) { - bucket = hlist_entry(hashit.walk, struct element_t, hlist); - orig_node = bucket->data; +for (i =0 ; i < hash->size; i++) { +rcu_read_lock (); + ret =hlist_empty (&hash->table[i]); +rcu_read_unlock (); -if (!orig_node->router) +if (ret)continue ; -if (orig_node->router->tq_avg ==0 ) -continue ; + head = &hash->table[i]; + +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { + orig_node = bucket->data; + +if (!orig_node->router) +continue ; - last_seen_secs =jiffies_to_msecs (jiffies - +if (orig_node->router->tq_avg ==0 ) +continue ; + + last_seen_secs =jiffies_to_msecs (jiffies - orig_node->last_valid) /1000 ; - last_seen_msecs =jiffies_to_msecs (jiffies - + last_seen_msecs =jiffies_to_msecs (jiffies - orig_node->last_valid) %1000 ; -seq_printf (seq,"%pM %4i.%03is (%3i) %pM [%10s]:" , - orig_node->orig, last_seen_secs, last_seen_msecs, - orig_node->router->tq_avg, orig_node->router->addr, - orig_node->router->if_incoming->net_dev->name); - -rcu_read_lock (); -hlist_for_each_entry (neigh_node, node, - &orig_node->neigh_list, list) { -seq_printf (seq," %pM (%3i)" , neigh_node->addr, - neigh_node->tq_avg); + neigh_node = orig_node->router; +seq_printf (seq,"%pM %4i.%03is (%3i) %pM [%10s]:" , + orig_node->orig, last_seen_secs, + last_seen_msecs, neigh_node->tq_avg, + neigh_node->addr, + neigh_node->if_incoming->net_dev->name); + +hlist_for_each_entry (neigh_node, node, + &orig_node->neigh_list, list) { +seq_printf (seq," %pM (%3i)" , neigh_node->addr, + neigh_node->tq_avg); + } + +seq_printf (seq,"\n" ); + batman_count++; }rcu_read_unlock (); - -seq_printf (seq,"\n" ); - batman_count++; }spin_unlock_bh (&bat_priv->orig_hash_lock);
@@ -462,26 +519,42 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)int orig_hash_add_if (struct batman_if *batman_if,int max_if_num) {struct bat_priv *bat_priv =netdev_priv (batman_if->soft_iface); -struct orig_node *orig_node; -HASHIT (hashit); +struct hashtable_t *hash = bat_priv->orig_hash; +struct hlist_node *walk; +struct hlist_head *head;struct element_t *bucket; +struct orig_node *orig_node; +int i, ret;/* resize all orig nodes because orig_node->bcast_own(_sum) depend on * if_num */ spin_lock_bh (&bat_priv->orig_hash_lock); -while (hash_iterate (bat_priv->orig_hash, &hashit)) { - bucket = hlist_entry(hashit.walk, struct element_t, hlist); - orig_node = bucket->data; +for (i =0 ; i < hash->size; i++) { +rcu_read_lock (); + ret =hlist_empty (&hash->table[i]); +rcu_read_unlock (); + +if (ret) +continue ; + + head = &hash->table[i]; -if (orig_node_add_if (orig_node, max_if_num) ==-1 ) - goto err; +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { + orig_node = bucket->data; + +if (orig_node_add_if (orig_node, max_if_num) ==-1 ) + goto err; + } +rcu_read_unlock (); }spin_unlock_bh (&bat_priv->orig_hash_lock);return 0 ; err: +rcu_read_unlock ();spin_unlock_bh (&bat_priv->orig_hash_lock);return -ENOMEM ; }
@@ -541,25 +614,39 @@ free_own_sum:int orig_hash_del_if (struct batman_if *batman_if,int max_if_num) {struct bat_priv *bat_priv =netdev_priv (batman_if->soft_iface); +struct hashtable_t *hash = bat_priv->orig_hash; +struct hlist_node *walk; +struct hlist_head *head; +struct element_t *bucket;struct batman_if *batman_if_tmp;struct orig_node *orig_node; -HASHIT (hashit); -struct element_t *bucket; -int ret; +int i, ret;/* resize all orig nodes because orig_node->bcast_own(_sum) depend on * if_num */ spin_lock_bh (&bat_priv->orig_hash_lock); -while (hash_iterate (bat_priv->orig_hash, &hashit)) { - bucket = hlist_entry(hashit.walk, struct element_t, hlist); - orig_node = bucket->data; +for (i =0 ; i < hash->size; i++) { +rcu_read_lock (); + ret =hlist_empty (&hash->table[i]); +rcu_read_unlock (); + +if (ret) +continue ; + + head = &hash->table[i]; + +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { + orig_node = bucket->data; - ret =orig_node_del_if (orig_node, max_if_num, - batman_if->if_num); + ret =orig_node_del_if (orig_node, max_if_num, + batman_if->if_num); -if (ret ==-1 ) - goto err; +if (ret ==-1 ) + goto err; + } +rcu_read_unlock (); }/* renumber remaining batman interfaces _inside_ of orig_hash_lock */
@@ -584,6 +671,7 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)return 0 ; err: +rcu_read_unlock ();spin_unlock_bh (&bat_priv->orig_hash_lock);return -ENOMEM ; }
batman-adv/routing.c +24 -8
@@ -39,21 +39,37 @@void slide_own_bcast_window (struct batman_if *batman_if) {struct bat_priv *bat_priv =netdev_priv (batman_if->soft_iface); -HASHIT (hashit); +struct hashtable_t *hash = bat_priv->orig_hash; +struct hlist_node *walk; +struct hlist_head *head;struct element_t *bucket;struct orig_node *orig_node;TYPE_OF_WORD *word; +int ret, i;spin_lock_bh (&bat_priv->orig_hash_lock); -while (hash_iterate (bat_priv->orig_hash, &hashit)) { - bucket = hlist_entry(hashit.walk, struct element_t, hlist); - orig_node = bucket->data; - word = &(orig_node->bcast_own[batman_if->if_num *NUM_WORDS ]); +for (i =0 ; i < hash->size; i++) { +rcu_read_lock (); + ret =hlist_empty (&hash->table[i]); +rcu_read_unlock (); + +if (ret) +continue ; + + head = &hash->table[i]; -bit_get_packet (bat_priv, word,1 ,0 ); - orig_node->bcast_own_sum[batman_if->if_num] = -bit_packet_count (word); +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { + orig_node = bucket->data; + word = &(orig_node->bcast_own[batman_if->if_num * +NUM_WORDS ]); + +bit_get_packet (bat_priv, word,1 ,0 ); + orig_node->bcast_own_sum[batman_if->if_num] = +bit_packet_count (word); + } +rcu_read_unlock (); }spin_unlock_bh (&bat_priv->orig_hash_lock);
batman-adv/vis.c +101 -56
221 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 8/9 batman-adv: protect ogm counter arrays with spinlock
In reply to Marek Lindner--- batman-adv/originator.c | 9 ++++++++- batman-adv/routing.c | 27 +++++++++++++++++++++++---- batman-adv/types.h | 1 + 3 files changed, 32 insertions(+), 5 deletions(-)
batman-adv/originator.c +8 -1
@@ -201,6 +201,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)return NULL ;INIT_HLIST_HEAD (&orig_node->neigh_list); +spin_lock_init (&orig_node->ogm_cnt_lock);spin_lock_init (&orig_node->neigh_list_lock);kref_init (&orig_node->refcount);
@@ -544,7 +545,11 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data; -if (orig_node_add_if (orig_node, max_if_num) ==-1 ) +spin_lock_bh (&orig_node->ogm_cnt_lock); + ret =orig_node_add_if (orig_node, max_if_num); +spin_unlock_bh (&orig_node->ogm_cnt_lock); + +if (ret ==-1 ) goto err; }rcu_read_unlock ();
@@ -640,8 +645,10 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data; +spin_lock_bh (&orig_node->ogm_cnt_lock); ret =orig_node_del_if (orig_node, max_if_num, batman_if->if_num); +spin_unlock_bh (&orig_node->ogm_cnt_lock);if (ret ==-1 ) goto err;
batman-adv/routing.c +23 -4
@@ -62,12 +62,14 @@ void slide_own_bcast_window(struct batman_if *batman_if)rcu_read_lock ();hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data; +spin_lock_bh (&orig_node->ogm_cnt_lock); word = &(orig_node->bcast_own[batman_if->if_num *NUM_WORDS ]);bit_get_packet (bat_priv, word,1 ,0 ); orig_node->bcast_own_sum[batman_if->if_num] =bit_packet_count (word); +spin_unlock_bh (&orig_node->ogm_cnt_lock); }rcu_read_unlock (); }
@@ -273,8 +275,10 @@ static void update_orig(struct bat_priv *bat_priv, char is_duplicate) {struct neigh_node *neigh_node =NULL , *tmp_neigh_node =NULL ; +struct orig_node *orig_node_tmp;struct hlist_node *node;int tmp_hna_buff_len; +uint8_t bcast_own_sum_orig, bcast_own_sum_neigh;bat_dbg (DBG_BATMAN , bat_priv,"update_originator(): " "Searching and updating originator entry of received packet\n" );
@@ -344,10 +348,22 @@ static void update_orig(struct bat_priv *bat_priv,/* if the TQ is the same and the link not more symetric we * won't consider it either */ if ((orig_node->router) && - ((neigh_node->tq_avg == orig_node->router->tq_avg) && - (orig_node->router->orig_node->bcast_own_sum[if_incoming->if_num] - >= neigh_node->orig_node->bcast_own_sum[if_incoming->if_num]))) - goto update_hna; + (neigh_node->tq_avg == orig_node->router->tq_avg)) { + orig_node_tmp = orig_node->router->orig_node; +spin_lock_bh (&orig_node_tmp->ogm_cnt_lock); + bcast_own_sum_orig = + orig_node_tmp->bcast_own_sum[if_incoming->if_num]; +spin_unlock_bh (&orig_node_tmp->ogm_cnt_lock); + + orig_node_tmp = neigh_node->orig_node; +spin_lock_bh (&orig_node_tmp->ogm_cnt_lock); + bcast_own_sum_neigh = + orig_node_tmp->bcast_own_sum[if_incoming->if_num]; +spin_unlock_bh (&orig_node_tmp->ogm_cnt_lock); + +if (bcast_own_sum_orig >= bcast_own_sum_neigh) + goto update_hna; + }update_routes (bat_priv, orig_node, neigh_node, hna_buff, tmp_hna_buff_len);
@@ -692,10 +708,13 @@ void receive_bat_packet(struct ethhdr *ethhdr, batman_packet->orig) && (batman_packet->seqno - if_incoming_seqno + 2 == 0)) { offset = if_incoming->if_num *NUM_WORDS ; + +spin_lock_bh (&orig_neigh_node->ogm_cnt_lock); word = &(orig_neigh_node->bcast_own[offset]);bit_mark (word,0 ); orig_neigh_node->bcast_own_sum[if_incoming->if_num] =bit_packet_count (word); +spin_unlock_bh (&orig_neigh_node->ogm_cnt_lock); } bat_dbg(DBG_BATMAN, bat_priv, "Drop packet: "
batman-adv/types.h +1 -0
@@ -89,6 +89,7 @@ struct orig_node {struct kref refcount;struct bat_priv *bat_priv;unsigned long last_frag_packet; +spinlock_t ogm_cnt_lock;/* protects ogm counter */ struct {uint8_t candidates;struct neigh_node *selected;
Signature · 1 line
1.7.2.3
PATCH 9/9 batman-adv: remove orig_hash spinlock
In reply to Marek Lindner--- batman-adv/icmp_socket.c | 35 +++-- batman-adv/main.c | 1 - batman-adv/originator.c | 21 --- batman-adv/routing.c | 316 ++++++++++++++++++++------------------- batman-adv/translation-table.c | 4 + batman-adv/types.h | 1 - batman-adv/unicast.c | 98 ++++++++----- batman-adv/vis.c | 58 ++++---- 8 files changed, 271 insertions(+), 263 deletions(-)
batman-adv/icmp_socket.c +18 -17
@@ -157,10 +157,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,struct sk_buff *skb;struct icmp_packet_rr *icmp_packet; -struct orig_node *orig_node; -struct batman_if *batman_if; +struct orig_node *orig_node =NULL ; +struct neigh_node *neigh_node =NULL ;size_t packet_len =sizeof (struct icmp_packet ); -uint8_t dstaddr[ETH_ALEN ];if (len <sizeof (struct icmp_packet )) { bat_dbg(DBG_BATMAN, bat_priv,
@@ -220,49 +219,51 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,if (atomic_read (&bat_priv->mesh_state) !=MESH_ACTIVE ) goto dst_unreach; -spin_lock_bh (&bat_priv->orig_hash_lock);rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->dst)); -rcu_read_unlock ();if (!orig_node) goto unlock; -if (!orig_node->router) - goto unlock; +kref_get (&orig_node->refcount); + neigh_node = orig_node->router; - batman_if = orig_node->router->if_incoming; -memcpy (dstaddr, orig_node->router->addr,ETH_ALEN ); +if (!neigh_node) + goto unlock; -spin_unlock_bh (&bat_priv->orig_hash_lock); +kref_get (&neigh_node->refcount); +rcu_read_unlock (); -if (!batman_if) +if (!neigh_node->if_incoming) goto dst_unreach; -if (batman_if->if_status !=IF_ACTIVE ) +if (neigh_node->if_incoming->if_status !=IF_ACTIVE ) goto dst_unreach;memcpy (icmp_packet->orig, bat_priv->primary_if->net_dev->dev_addr,ETH_ALEN );if (packet_len ==sizeof (struct icmp_packet_rr )) -memcpy (icmp_packet->rr, batman_if->net_dev->dev_addr,ETH_ALEN ); - - -send_skb_packet (skb, batman_if, dstaddr); +memcpy (icmp_packet->rr, + neigh_node->if_incoming->net_dev->dev_addr,ETH_ALEN ); +send_skb_packet (skb, neigh_node->if_incoming, neigh_node->addr); goto out; unlock: -spin_unlock_bh (&bat_priv->orig_hash_lock); +rcu_read_unlock (); dst_unreach: icmp_packet->msg_type =DESTINATION_UNREACHABLE ;bat_socket_add_packet (socket_client, icmp_packet, packet_len); free_skb:kfree_skb (skb); out: +if (neigh_node) +kref_put (&neigh_node->refcount, neigh_node_free_ref); +if (orig_node) +kref_put (&orig_node->refcount, orig_node_free_ref);return len; }
batman-adv/main.c +0 -1
@@ -80,7 +80,6 @@ int mesh_init(struct net_device *soft_iface) {struct bat_priv *bat_priv =netdev_priv (soft_iface); -spin_lock_init (&bat_priv->orig_hash_lock);spin_lock_init (&bat_priv->forw_bat_list_lock);spin_lock_init (&bat_priv->forw_bcast_list_lock);spin_lock_init (&bat_priv->hna_lhash_lock);
batman-adv/originator.c +0 -21
@@ -44,18 +44,15 @@ int originator_init(struct bat_priv *bat_priv)if (bat_priv->orig_hash)return 1 ; -spin_lock_bh (&bat_priv->orig_hash_lock); bat_priv->orig_hash =hash_new (1024 );if (!bat_priv->orig_hash) goto err; -spin_unlock_bh (&bat_priv->orig_hash_lock);start_purge_timer (bat_priv);return 1 ; err: -spin_unlock_bh (&bat_priv->orig_hash_lock);return 0 ; }
@@ -146,7 +143,6 @@ void originator_free(struct bat_priv *bat_priv)cancel_delayed_work_sync (&bat_priv->orig_work); -spin_lock_bh (&bat_priv->orig_hash_lock); bat_priv->orig_hash =NULL ;for (i =0 ; i < hash->size; i++) {
@@ -171,7 +167,6 @@ void originator_free(struct bat_priv *bat_priv) }hash_destroy (hash); -spin_unlock_bh (&bat_priv->orig_hash_lock); }/* this function finds or creates an originator entry for the given
@@ -337,8 +332,6 @@ static void _purge_orig(struct bat_priv *bat_priv)if (!hash)return ; -spin_lock_bh (&bat_priv->orig_hash_lock); -/* for all origins... */ for (i =0 ; i < hash->size; i++) {rcu_read_lock ();
@@ -374,8 +367,6 @@ static void _purge_orig(struct bat_priv *bat_priv)spin_unlock_bh (list_lock); } -spin_unlock_bh (&bat_priv->orig_hash_lock); -gw_node_purge (bat_priv);gw_election (bat_priv);
@@ -433,8 +424,6 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)"Originator" ,"last-seen" ,"#" ,TQ_MAX_VALUE ,"Nexthop" , "outgoingIF", "Potential nexthops"); -spin_lock_bh (&bat_priv->orig_hash_lock); -for (i =0 ; i < hash->size; i++) {rcu_read_lock (); ret =hlist_empty (&hash->table[i]);
@@ -479,8 +468,6 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)rcu_read_unlock (); } -spin_unlock_bh (&bat_priv->orig_hash_lock); -if ((batman_count ==0 ))seq_printf (seq,"No batman nodes in range ...\n" );
@@ -529,8 +516,6 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)/* resize all orig nodes because orig_node->bcast_own(_sum) depend on * if_num */ -spin_lock_bh (&bat_priv->orig_hash_lock); -for (i =0 ; i < hash->size; i++) {rcu_read_lock (); ret =hlist_empty (&hash->table[i]);
@@ -555,12 +540,10 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)rcu_read_unlock (); } -spin_unlock_bh (&bat_priv->orig_hash_lock);return 0 ; err:rcu_read_unlock (); -spin_unlock_bh (&bat_priv->orig_hash_lock);return -ENOMEM ; }
@@ -629,8 +612,6 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)/* resize all orig nodes because orig_node->bcast_own(_sum) depend on * if_num */ -spin_lock_bh (&bat_priv->orig_hash_lock); -for (i =0 ; i < hash->size; i++) {rcu_read_lock (); ret =hlist_empty (&hash->table[i]);
@@ -674,11 +655,9 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)rcu_read_unlock (); batman_if->if_num =-1 ; -spin_unlock_bh (&bat_priv->orig_hash_lock);return 0 ; err:rcu_read_unlock (); -spin_unlock_bh (&bat_priv->orig_hash_lock);return -ENOMEM ; }
batman-adv/routing.c +162 -154
566 lines not on this page · raw message
batman-adv/translation-table.c +4 -0
@@ -505,6 +505,10 @@ struct orig_node *transtable_search(struct bat_priv *bat_priv, uint8_t *addr) hna_global_entry = (struct hna_global_entry *)hash_find (bat_priv->hna_global_hash, compare_orig, choose_orig, addr); + +if (hna_global_entry) +kref_get (&hna_global_entry->orig_node->refcount); +rcu_read_unlock ();spin_unlock_bh (&bat_priv->hna_ghash_lock);
batman-adv/types.h +0 -1
@@ -157,7 +157,6 @@ struct bat_priv {struct hashtable_t *hna_local_hash;struct hashtable_t *hna_global_hash;struct hashtable_t *vis_hash; -spinlock_t orig_hash_lock;/* protects orig_hash */ spinlock_t forw_bat_list_lock;/* protects forw_bat_list */ spinlock_t forw_bcast_list_lock;/* protects */ spinlock_t hna_lhash_lock;/* protects hna_local_hash */
batman-adv/unicast.c +58 -40
149 lines not on this page · raw message
batman-adv/vis.c +29 -29
129 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Quoted 5 lines · Marek Lindner
Hi,
I continued improving the the performance patches which results in the first usable version. I tested it in a VM environment as well as on real hardware and did not encounter problematic behavior anymore.
I looked through your patches and have some small suggestions. First I would like to move the hashtable-functions related patches to the front. This would make it possible to send a new version of batman-adv to David S. Miller without adding to many changes (so maybe he doesn't get too angry this time).
Then you missed hashtable_t::elements of the hash implementation which are only needed for the resize implementation (now it is only a wom :) ). The hash_iterate function is also still there.... I would like to remove it completely. hash_remove only rcu locked the list - but we must spinlock here to prevent double frees. kref_put of data directly after call_rcu for bucket could lead to invalid memory access when a rcu protected region still accesses the bucket which isn't removed yet (but the data in the bucket was already removed). Unneeded(?) hlist_empty checks. Missing conversation of neigh_node hlist operations to _rcu. Missing rcu_read_unlock's. Missing correct refcnt for neigh_list
I would rework some of those parts and resend all patches again to the mailing list. This doesn't mean that I have checked everything.... some of the patches were just too "wirr" and this is a first try to get it in the right direction. It still needs a lot of cleanup and testing. For example neigh_list stuff and the kref_put after call_rcu is complete unfixed and I also didn't finish the complete patchset.... maybe will continue with it when the patchset is cleaned up.
Best regards,
Sven
PATCH 1/9 batman-adv: remove hash resize functions
From: Marek Lindner <[email protected]>
---
Removed hashtable_t::elements
batman-adv/hash.c | 3 --- batman-adv/hash.h | 40 ---------------------------------------- batman-adv/originator.c | 14 +------------- batman-adv/translation-table.c | 32 ++------------------------------ 4 files changed, 3 insertions(+), 86 deletions(-)
batman-adv/hash.c +0 -3
@@ -27,8 +27,6 @@ static void hash_init(struct hashtable_t *hash) {int i; - hash->elements =0 ; -for (i =0 ; i < hash->size; i++)INIT_HLIST_HEAD (&hash->table[i]); }
@@ -77,7 +75,6 @@ void *hash_remove_bucket(struct hashtable_t *hash, struct hash_it_t *hash_it_t)hlist_del (hash_it_t->walk);kfree (bucket); - hash->elements--;return data_save; }
batman-adv/hash.h +0 -40
@@ -53,7 +53,6 @@ struct hash_it_t {struct hashtable_t {struct hlist_head *table;/* the hashtable itself, with the buckets */ -int elements;/* number of elements registered */ int size;/* size of hashtable */ };
@@ -127,7 +126,6 @@ static inline int hash_add(struct hashtable_t *hash, bucket->data = data;hlist_add_head (&bucket->hlist, head); - hash->elements++;return 0 ; }
@@ -181,44 +179,6 @@ static inline void *hash_find(struct hashtable_t *hash,return NULL ; } -/* resize the hash, returns the pointer to the new hash or NULL on -* error. removes the old hash on success */ -static inline struct hashtable_t *hash_resize (struct hashtable_t *hash, -hashdata_choose_cb choose, -int size) -{ -struct hashtable_t *new_hash; -struct hlist_head *head, *new_head; -struct hlist_node *walk, *safe; -struct element_t *bucket; -int i, new_index; - -/* initialize a new hash with the new size */ - new_hash =hash_new (size); - -if (new_hash ==NULL ) -return NULL ; - -/* copy the elements */ -for (i =0 ; i < hash->size; i++) { - head = &hash->table[i]; - -hlist_for_each_safe (walk, safe, head) { - bucket = hlist_entry(walk, struct element_t, hlist); - - new_index =choose (bucket->data, size); - new_head = &new_hash->table[new_index]; - -hlist_del (walk); -hlist_add_head (walk, new_head); - } - } - -hash_destroy (hash); - -return new_hash; -} -/* iterate though the hash. First element is selected if an iterator * initialized with HASHIT() is supplied as iter. Use the returned * (or supplied) iterator to access the elements until hash_iterate returns
batman-adv/originator.c +1 -13
@@ -45,7 +45,7 @@ int originator_init(struct bat_priv *bat_priv)return 1 ;spin_lock_bh (&bat_priv->orig_hash_lock); - bat_priv->orig_hash =hash_new (128 ); + bat_priv->orig_hash =hash_new (1024 );if (!bat_priv->orig_hash) goto err;
@@ -124,7 +124,6 @@ void originator_free(struct bat_priv *bat_priv)struct orig_node *get_orig_node (struct bat_priv *bat_priv,uint8_t *addr) {struct orig_node *orig_node; -struct hashtable_t *swaphash;int size;int hash_added;
@@ -172,17 +171,6 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)if (hash_added <0 ) goto free_bcast_own_sum; -if (bat_priv->orig_hash->elements *4 > bat_priv->orig_hash->size) { - swaphash =hash_resize (bat_priv->orig_hash, choose_orig, - bat_priv->orig_hash->size *2 ); - -if (!swaphash) -bat_dbg (DBG_BATMAN , bat_priv, -"Couldn't resize orig hash table\n" ); -else - bat_priv->orig_hash = swaphash; - } -return orig_node; free_bcast_own_sum:kfree (orig_node->bcast_own_sum);
batman-adv/translation-table.c +2 -30
@@ -42,7 +42,7 @@ int hna_local_init(struct bat_priv *bat_priv)if (bat_priv->hna_local_hash)return 1 ; - bat_priv->hna_local_hash =hash_new (128 ); + bat_priv->hna_local_hash =hash_new (1024 );if (!bat_priv->hna_local_hash)return 0 ;
@@ -58,7 +58,6 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr)struct bat_priv *bat_priv =netdev_priv (soft_iface);struct hna_local_entry *hna_local_entry;struct hna_global_entry *hna_global_entry; -struct hashtable_t *swaphash;int required_bytes;spin_lock_bh (&bat_priv->hna_lhash_lock);
@@ -113,17 +112,6 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr) bat_priv->num_local_hna++;atomic_set (&bat_priv->hna_local_changed,1 ); -if (bat_priv->hna_local_hash->elements *4 > - bat_priv->hna_local_hash->size) { - swaphash =hash_resize (bat_priv->hna_local_hash, choose_orig, - bat_priv->hna_local_hash->size *2 ); - -if (!swaphash) -pr_err ("Couldn't resize local hna hash table\n" ); -else - bat_priv->hna_local_hash = swaphash; - } -spin_unlock_bh (&bat_priv->hna_lhash_lock);/* remove address from global hash if present */
@@ -302,7 +290,7 @@ int hna_global_init(struct bat_priv *bat_priv)if (bat_priv->hna_global_hash)return 1 ; - bat_priv->hna_global_hash =hash_new (128 ); + bat_priv->hna_global_hash =hash_new (1024 );if (!bat_priv->hna_global_hash)return 0 ;
@@ -316,7 +304,6 @@ void hna_global_add_orig(struct bat_priv *bat_priv, {struct hna_global_entry *hna_global_entry;struct hna_local_entry *hna_local_entry; -struct hashtable_t *swaphash;int hna_buff_count =0 ;unsigned char *hna_ptr;
@@ -382,21 +369,6 @@ void hna_global_add_orig(struct bat_priv *bat_priv, orig_node->hna_buff_len = hna_buff_len; } } - -spin_lock_bh (&bat_priv->hna_ghash_lock); - -if (bat_priv->hna_global_hash->elements *4 > - bat_priv->hna_global_hash->size) { - swaphash =hash_resize (bat_priv->hna_global_hash, choose_orig, - bat_priv->hna_global_hash->size *2 ); - -if (!swaphash) -pr_err ("Couldn't resize global hna hash table\n" ); -else - bat_priv->hna_global_hash = swaphash; - } - -spin_unlock_bh (&bat_priv->hna_ghash_lock); }int hna_global_seq_print_text (struct seq_file *seq,void *offset)
Signature · 1 line
1.7.2.3
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: remove hash resize functions
Quoted 1 line · On Saturday 04 December 2010 21:03:40 Sven Eckelmann wrote:
From: Marek Lindner <[email protected]>
Applied in revision 1887.
Regards,
Marek
PATCH 2/9 batman-adv: Remove hash_iterate
In reply to Sven Eckelmann---
Removed hash_iterate completely as promised to David. This should also help to create the later patches in a more cleaner way.
batman-adv/hash.c | 18 --- batman-adv/hash.h | 75 ++------- batman-adv/originator.c | 132 ++++++++++------ batman-adv/routing.c | 24 ++- batman-adv/translation-table.c | 110 +++++++++----- batman-adv/vis.c | 328 +++++++++++++++++++++++----------------- 6 files changed, 372 insertions(+), 315 deletions(-)
batman-adv/hash.c +0 -18
@@ -60,21 +60,3 @@ struct hashtable_t *hash_new(int size)return hash; } - -/* 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 *data_save; -struct element_t *bucket; - - bucket = hlist_entry(hash_it_t->walk, struct element_t, hlist); - data_save = bucket->data; - -hlist_del (hash_it_t->walk); -kfree (bucket); - -return data_save; -}
batman-adv/hash.h +16 -59
107 lines not on this page · raw message
batman-adv/originator.c +81 -51
201 lines not on this page · raw message
batman-adv/routing.c +16 -8
@@ -39,21 +39,29 @@void slide_own_bcast_window (struct batman_if *batman_if) {struct bat_priv *bat_priv =netdev_priv (batman_if->soft_iface); -HASHIT (hashit); +struct hashtable_t *hash = bat_priv->orig_hash; +struct hlist_node *walk; +struct hlist_head *head;struct element_t *bucket;struct orig_node *orig_node;TYPE_OF_WORD *word; +int i; +size_t word_index;spin_lock_bh (&bat_priv->orig_hash_lock); -while (hash_iterate (bat_priv->orig_hash, &hashit)) { - bucket = hlist_entry(hashit.walk, struct element_t, hlist); - orig_node = bucket->data; - word = &(orig_node->bcast_own[batman_if->if_num *NUM_WORDS ]); +for (i =0 ; i < hash->size; i++) { + head = &hash->table[i]; -bit_get_packet (bat_priv, word,1 ,0 ); - orig_node->bcast_own_sum[batman_if->if_num] = -bit_packet_count (word); +hlist_for_each_entry (bucket, walk, head, hlist) { + orig_node = bucket->data; + word_index = batman_if->if_num *NUM_WORDS ; + word = &(orig_node->bcast_own[word_index]); + +bit_get_packet (bat_priv, word,1 ,0 ); + orig_node->bcast_own_sum[batman_if->if_num] = +bit_packet_count (word); + } }spin_unlock_bh (&bat_priv->orig_hash_lock);
batman-adv/translation-table.c +72 -38
187 lines not on this page · raw message
batman-adv/vis.c +187 -141
447 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 2/9] batman-adv: Remove hash_iterate
Quoted 1 line · On Saturday 04 December 2010 21:03:41 Sven Eckelmann wrote:
Signed-off-by Sven Eckelmann <[email protected]>
Applied in revision 1888.
Thanks,
Marek
PATCH 3/9 batman-adv: protect neighbor nodes with reference counters
In reply to Sven EckelmannFrom: Marek Lindner <[email protected]>
--- batman-adv/originator.c | 20 +++++++++++++++----- batman-adv/originator.h | 8 +++++--- batman-adv/routing.c | 7 +++++++ batman-adv/types.h | 1 + 4 files changed, 28 insertions(+), 8 deletions(-)
batman-adv/originator.c +15 -5
@@ -59,9 +59,18 @@ err:return 0 ; } -struct neigh_node * -create_neighbor (struct orig_node *orig_node,struct orig_node *orig_neigh_node, -uint8_t *neigh,struct batman_if *if_incoming) +void neigh_node_free_ref (struct kref *refcount) +{ +struct neigh_node *neigh_node; + + neigh_node = container_of(refcount, struct neigh_node, refcount); +kfree (neigh_node); +} + +struct neigh_node *create_neighbor (struct orig_node *orig_node, +struct orig_node *orig_neigh_node, +uint8_t *neigh, +struct batman_if *if_incoming) {struct bat_priv *bat_priv =netdev_priv (if_incoming->soft_iface);struct neigh_node *neigh_node;
@@ -78,6 +87,7 @@ create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,memcpy (neigh_node->addr, neigh,ETH_ALEN ); neigh_node->orig_node = orig_neigh_node; neigh_node->if_incoming = if_incoming; +kref_init (&neigh_node->refcount);list_add_tail (&neigh_node->list, &orig_node->neigh_list);return neigh_node;
@@ -95,7 +105,7 @@ static void free_orig_node(void *data, void *arg) neigh_node = list_entry(list_pos, struct neigh_node, list);list_del (list_pos); -kfree (neigh_node); +kref_put (&neigh_node->refcount, neigh_node_free_ref); }frag_list_free (&orig_node->frag_list);
@@ -216,7 +226,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, neigh_purged = true;list_del (list_pos); -kfree (neigh_node); +kref_put (&neigh_node->refcount, neigh_node_free_ref); }else {if ((*best_neigh_node ==NULL ) || (neigh_node->tq_avg > (*best_neigh_node)->tq_avg))
batman-adv/originator.h +5 -3
@@ -26,9 +26,11 @@ int originator_init(struct bat_priv *bat_priv);void originator_free (struct bat_priv *bat_priv);void purge_orig_ref (struct bat_priv *bat_priv);struct orig_node *get_orig_node (struct bat_priv *bat_priv,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); +struct neigh_node *create_neighbor (struct orig_node *orig_node, +struct orig_node *orig_neigh_node, +uint8_t *neigh, +struct batman_if *if_incoming); +void neigh_node_free_ref (struct kref *refcount);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);
batman-adv/routing.c +7 -0
@@ -90,6 +90,8 @@ static void update_route(struct bat_priv *bat_priv,struct neigh_node *neigh_node, unsigned char *hna_buff, int hna_buff_len) { + struct neigh_node *neigh_node_tmp; +/* route deleted */ if ((orig_node->router !=NULL ) && (neigh_node ==NULL )) {
@@ -116,7 +118,12 @@ static void update_route(struct bat_priv *bat_priv, orig_node->router->addr); } +if (neigh_node) +kref_get (&neigh_node->refcount); + neigh_node_tmp = orig_node->router; orig_node->router = neigh_node; +if (neigh_node_tmp) +kref_put (&neigh_node_tmp->refcount, neigh_node_free_ref); }
batman-adv/types.h +1 -0
@@ -115,6 +115,7 @@ struct neigh_node {struct neigh_node *next_bond_candidate;unsigned long last_valid;TYPE_OF_WORD real_bits[NUM_WORDS ]; +struct kref refcount;struct orig_node *orig_node;struct batman_if *if_incoming; };
Signature · 1 line
1.7.2.3
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 3/9] batman-adv: protect neighbor nodes with reference counters
Quoted 1 line · On Saturday 04 December 2010 21:03:42 Sven Eckelmann wrote:
From: Marek Lindner <[email protected]>
Applied in revision 1890.
Regards,
Marek
PATCH 4/9 batman-adv: convert neighbor list to hlist
In reply to Sven EckelmannFrom: Marek Lindner <[email protected]>
--- batman-adv/originator.c | 30 +++++++++++++++--------------- batman-adv/routing.c | 29 ++++++++++++++++++----------- batman-adv/types.h | 4 ++-- 3 files changed, 35 insertions(+), 28 deletions(-)
batman-adv/originator.c +15 -15
@@ -82,29 +82,28 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node,if (!neigh_node)return NULL ; -INIT_LIST_HEAD (&neigh_node->list); +INIT_HLIST_NODE (&neigh_node->list);memcpy (neigh_node->addr, neigh,ETH_ALEN ); neigh_node->orig_node = orig_neigh_node; neigh_node->if_incoming = if_incoming;kref_init (&neigh_node->refcount); -list_add_tail (&neigh_node->list, &orig_node->neigh_list); +hlist_add_head (&neigh_node->list, &orig_node->neigh_list);return neigh_node; }static void free_orig_node (void *data,void *arg) { -struct list_head *list_pos, *list_pos_tmp; +struct hlist_node *node, *node_tmp;struct neigh_node *neigh_node;struct orig_node *orig_node = (struct orig_node *)data;struct bat_priv *bat_priv = (struct bat_priv *)arg;/* for all neighbors towards this originator ... */ -list_for_each_safe (list_pos, list_pos_tmp, &orig_node->neigh_list) { - neigh_node = list_entry(list_pos, struct neigh_node, list); - -list_del (list_pos); +hlist_for_each_entry_safe (neigh_node, node, node_tmp, + &orig_node->neigh_list, list) { +hlist_del (&neigh_node->list);kref_put (&neigh_node->refcount, neigh_node_free_ref); }
@@ -151,7 +150,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)if (!orig_node)return NULL ; -INIT_LIST_HEAD (&orig_node->neigh_list); +INIT_HLIST_HEAD (&orig_node->neigh_list);memcpy (orig_node->orig, addr,ETH_ALEN ); orig_node->router =NULL ;
@@ -195,15 +194,15 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,struct orig_node *orig_node, struct neigh_node **best_neigh_node) { - struct list_head *list_pos, *list_pos_tmp; + struct hlist_node *node, *node_tmp;struct neigh_node *neigh_node;bool neigh_purged = false; *best_neigh_node =NULL ;/* for all neighbors towards this originator ... */ -list_for_each_safe (list_pos, list_pos_tmp, &orig_node->neigh_list) { - neigh_node = list_entry(list_pos, struct neigh_node, list); +hlist_for_each_entry_safe (neigh_node, node, node_tmp, + &orig_node->neigh_list, list) { if ((time_after(jiffies, neigh_node->last_valid + PURGE_TIMEOUT * HZ)) ||
@@ -225,7 +224,8 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, (neigh_node->last_valid / HZ)); neigh_purged = true; -list_del (list_pos); + +hlist_del (&neigh_node->list);kref_put (&neigh_node->refcount, neigh_node_free_ref); }else { if ((*best_neigh_node == NULL) ||
@@ -328,7 +328,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)struct net_device *net_dev = (struct net_device *)seq->private;struct bat_priv *bat_priv =netdev_priv (net_dev);struct hashtable_t *hash = bat_priv->orig_hash; -struct hlist_node *walk; +struct hlist_node *walk, *node;struct hlist_head *head;struct element_t *bucket;struct orig_node *orig_node;
@@ -384,8 +384,8 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) neigh_node->addr, neigh_node->if_incoming->net_dev->name); -list_for_each_entry (neigh_node, &orig_node->neigh_list, - list) { +hlist_for_each_entry (neigh_node, node, + &orig_node->neigh_list, list) {seq_printf (seq," %pM (%3i)" , neigh_node->addr, neigh_node->tq_avg); }
batman-adv/routing.c +18 -11
@@ -150,12 +150,12 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, {struct bat_priv *bat_priv =netdev_priv (if_incoming->soft_iface);struct neigh_node *neigh_node =NULL , *tmp_neigh_node =NULL ; +struct hlist_node *node;unsigned char total_count;if (orig_node == orig_neigh_node) { -list_for_each_entry (tmp_neigh_node, - &orig_node->neigh_list, - list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_node->neigh_list, list) { if (compare_orig(tmp_neigh_node->addr, orig_neigh_node->orig) &&
@@ -175,8 +175,8 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, neigh_node->last_valid = jiffies; }else {/* find packet count of corresponding one hop neighbor */ -list_for_each_entry (tmp_neigh_node, - &orig_neigh_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_neigh_node->neigh_list, list) { if (compare_orig(tmp_neigh_node->addr, orig_neigh_node->orig) &&
@@ -261,12 +261,14 @@ static void update_orig(struct bat_priv *bat_priv, char is_duplicate) {struct neigh_node *neigh_node =NULL , *tmp_neigh_node =NULL ; +struct hlist_node *node;int tmp_hna_buff_len;bat_dbg (DBG_BATMAN , bat_priv,"update_originator(): " "Searching and updating originator entry of received packet\n" ); -list_for_each_entry (tmp_neigh_node, &orig_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_node->neigh_list, list) {if (compare_orig (tmp_neigh_node->addr, ethhdr->h_source) && (tmp_neigh_node->if_incoming == if_incoming)) { neigh_node = tmp_neigh_node;
@@ -392,6 +394,7 @@ static char count_real_packets(struct ethhdr *ethhdr,struct bat_priv *bat_priv =netdev_priv (if_incoming->soft_iface);struct orig_node *orig_node;struct neigh_node *tmp_neigh_node; +struct hlist_node *node;char is_duplicate =0 ;int32_t seq_diff;int need_update =0 ;
@@ -408,7 +411,8 @@ static char count_real_packets(struct ethhdr *ethhdr, &orig_node->batman_seqno_reset))return -1 ; -list_for_each_entry (tmp_neigh_node, &orig_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_node->neigh_list, list) { is_duplicate |= get_bit_status(tmp_neigh_node->real_bits, orig_node->last_real_seqno,
@@ -460,6 +464,7 @@ void update_bonding_candidates(struct bat_priv *bat_priv,int candidates;int interference_candidate;int best_tq; +struct hlist_node *node, *node2;struct neigh_node *tmp_neigh_node, *tmp_neigh_node2;struct neigh_node *first_candidate, *last_candidate;
@@ -479,13 +484,15 @@ void update_bonding_candidates(struct bat_priv *bat_priv,* as "bonding partner" */ /* first, zero the list */ -list_for_each_entry (tmp_neigh_node, &orig_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_node->neigh_list, list) { tmp_neigh_node->next_bond_candidate =NULL ; } first_candidate =NULL ; last_candidate =NULL ; -list_for_each_entry (tmp_neigh_node, &orig_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node, node, + &orig_node->neigh_list, list) {/* only consider if it has the same primary address ... */ if (memcmp(orig_node->orig,
@@ -502,8 +509,8 @@ void update_bonding_candidates(struct bat_priv *bat_priv,* select this candidate because of possible interference. */ interference_candidate =0 ; -list_for_each_entry (tmp_neigh_node2, - &orig_node->neigh_list, list) { +hlist_for_each_entry (tmp_neigh_node2, node2, + &orig_node->neigh_list, list) {if (tmp_neigh_node2 == tmp_neigh_node)continue ;
batman-adv/types.h +2 -2
@@ -83,7 +83,7 @@ struct orig_node {uint8_t last_ttl;TYPE_OF_WORD bcast_bits[NUM_WORDS ];uint32_t last_bcast_seqno; -struct list_head neigh_list; +struct hlist_head neigh_list;struct list_head frag_list;unsigned long last_frag_packet;struct {
@@ -105,7 +105,7 @@ struct gw_node {* @last_valid: when last packet via this neighbor was received */ struct neigh_node { -struct list_head list; +struct hlist_node list;uint8_t addr[ETH_ALEN ];uint8_t real_packet_count;uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE ];
Signature · 1 line
1.7.2.3
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 4/9] batman-adv: convert neighbor list to hlist
Quoted 1 line · On Saturday 04 December 2010 21:03:43 Sven Eckelmann wrote:
From: Marek Lindner <[email protected]>
Applied in revision 1891.
Regards,
Marek
PATCH 5/9 batman-adv: protect neighbor list with rcu locks
In reply to Sven EckelmannFrom: Marek Lindner <[email protected]>
---
Needed to add a lot of _rcu stuff here and I am sure many things are still wrong here.
batman-adv/originator.c | 35 ++++++++++++++++++++++++++++------- batman-adv/routing.c | 41 +++++++++++++++++++++++++++-------------- batman-adv/types.h | 2 ++ 3 files changed, 57 insertions(+), 21 deletions(-)
batman-adv/originator.c +28 -7
@@ -67,6 +67,14 @@ void neigh_node_free_ref(struct kref *refcount)kfree (neigh_node); } +static void neigh_node_free_rcu (struct rcu_head *rcu) +{ +struct neigh_node *neigh_node; + + neigh_node = container_of(rcu, struct neigh_node, rcu); +kref_put (&neigh_node->refcount, neigh_node_free_ref); +} + struct neigh_node *create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, uint8_t *neigh,
@@ -89,7 +97,9 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node, neigh_node->if_incoming = if_incoming;kref_init (&neigh_node->refcount); -hlist_add_head (&neigh_node->list, &orig_node->neigh_list); +spin_lock_bh (&orig_node->neigh_list_lock); +hlist_add_head_rcu (&neigh_node->list, &orig_node->neigh_list); +spin_unlock_bh (&orig_node->neigh_list_lock);return neigh_node; }
@@ -100,13 +110,17 @@ static void free_orig_node(void *data, void *arg)struct orig_node *orig_node = (struct orig_node *)data;struct bat_priv *bat_priv = (struct bat_priv *)arg; +spin_lock_bh (&orig_node->neigh_list_lock); +/* for all neighbors towards this originator ... */ hlist_for_each_entry_safe (neigh_node, node, node_tmp, &orig_node->neigh_list, list) { -hlist_del (&neigh_node->list); -kref_put (&neigh_node->refcount, neigh_node_free_ref); +hlist_del_rcu (&neigh_node->list); +call_rcu (&neigh_node->rcu, neigh_node_free_rcu); } +spin_unlock_bh (&orig_node->neigh_list_lock); +frag_list_free (&orig_node->frag_list);hna_global_del_orig (bat_priv, orig_node,"originator timed out" );
@@ -151,6 +165,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)return NULL ;INIT_HLIST_HEAD (&orig_node->neigh_list); +spin_lock_init (&orig_node->neigh_list_lock);memcpy (orig_node->orig, addr,ETH_ALEN ); orig_node->router =NULL ;
@@ -200,6 +215,8 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, *best_neigh_node =NULL ; +spin_lock_bh (&orig_node->neigh_list_lock); +/* for all neighbors towards this originator ... */ hlist_for_each_entry_safe (neigh_node, node, node_tmp, &orig_node->neigh_list, list) {
@@ -225,14 +242,16 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, neigh_purged = true; -hlist_del (&neigh_node->list); -kref_put (&neigh_node->refcount, neigh_node_free_ref); +hlist_del_rcu (&neigh_node->list); +call_rcu (&neigh_node->rcu, neigh_node_free_rcu); }else {if ((*best_neigh_node ==NULL ) || (neigh_node->tq_avg > (*best_neigh_node)->tq_avg)) *best_neigh_node = neigh_node; } } + +spin_unlock_bh (&orig_node->neigh_list_lock);return neigh_purged; }
@@ -384,11 +403,13 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) neigh_node->addr, neigh_node->if_incoming->net_dev->name); -hlist_for_each_entry (neigh_node, node, - &orig_node->neigh_list, list) { +rcu_read_lock (); +hlist_for_each_entry_rcu (neigh_node, node, + &orig_node->neigh_list, list) {seq_printf (seq," %pM (%3i)" , neigh_node->addr, neigh_node->tq_avg); } +rcu_read_unlock ();seq_printf (seq,"\n" ); batman_count++;
batman-adv/routing.c +27 -14
112 lines not on this page · raw message
batman-adv/types.h +2 -0
@@ -85,6 +85,7 @@ struct orig_node {uint32_t last_bcast_seqno;struct hlist_head neigh_list;struct list_head frag_list; +spinlock_t neigh_list_lock;/* protects neighbor list */ unsigned long last_frag_packet;struct {uint8_t candidates;
@@ -116,6 +117,7 @@ struct neigh_node {unsigned long last_valid;TYPE_OF_WORD real_bits[NUM_WORDS ];struct kref refcount; +struct rcu_head rcu;struct orig_node *orig_node;struct batman_if *if_incoming; };
Signature · 1 line
1.7.2.3
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 5/9] batman-adv: protect neighbor list with rcu locks
Quoted 1 line · On Saturday 04 December 2010 21:03:44 Sven Eckelmann wrote:
From: Marek Lindner <[email protected]>
Applied in revision 1892.
Regards,
Marek
PATCH 6/9 batman-adv: protect each hash row with rcu locks
In reply to Sven EckelmannFrom: Marek Lindner <[email protected]>
---
Could we move those '!= NULL' and ' == ' as an extra patch?
batman-adv/hash.c | 36 +++++++++++++----- batman-adv/hash.h | 77 ++++++++++++++++++++++++++------------- batman-adv/icmp_socket.c | 2 + batman-adv/originator.c | 27 ++++++++++---- batman-adv/routing.c | 16 ++++++++- batman-adv/translation-table.c | 14 +++++++ batman-adv/unicast.c | 7 +++- batman-adv/vis.c | 18 +++++++-- 8 files changed, 148 insertions(+), 49 deletions(-)
batman-adv/hash.c +26 -10
@@ -27,13 +27,16 @@ static void hash_init(struct hashtable_t *hash) {int i; -for (i =0 ; i < hash->size; i++) +for (i =0 ; i < hash->size; i++) {INIT_HLIST_HEAD (&hash->table[i]); +spin_lock_init (&hash->list_locks[i]); + } }/* free only the hashtable and the hash itself. */ void hash_destroy (struct hashtable_t *hash) { +kfree (hash->list_locks);kfree (hash->table);kfree (hash); }
@@ -43,20 +46,33 @@ struct hashtable_t *hash_new(int size) {struct hashtable_t *hash; - hash =kmalloc (sizeof (struct hashtable_t ) ,GFP_ATOMIC ); - -if (hash ==NULL ) + hash =kmalloc (sizeof (struct hashtable_t ),GFP_ATOMIC ); +if (!hash)return NULL ; - hash->size = size; hash->table =kmalloc (sizeof (struct element_t *) * size,GFP_ATOMIC ); +if (!hash->table) + goto free_hash; -if (hash->table ==NULL ) { -kfree (hash); -return NULL ; - } + hash->list_locks =kmalloc (sizeof (spinlock_t) * size,GFP_ATOMIC ); +if (!hash->list_locks) + goto free_table; + hash->size = size;hash_init (hash); -return hash; + +free_table: +kfree (hash->table); +free_hash: +kfree (hash); +return NULL ; +} + +void bucket_free_rcu (struct rcu_head *rcu) +{ +struct element_t *bucket; + + bucket = container_of(rcu, struct element_t, rcu); +kfree (bucket); }
batman-adv/hash.h +51 -26
159 lines not on this page · raw message
batman-adv/icmp_socket.c +2 -0
@@ -221,9 +221,11 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, goto dst_unreach;spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->dst)); +rcu_read_unlock ();if (!orig_node) goto unlock;
batman-adv/originator.c +20 -7
@@ -150,9 +150,11 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)int size;int hash_added; +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, addr)); +rcu_read_unlock ();if (orig_node)return orig_node;
@@ -289,6 +291,7 @@ static void _purge_orig(struct bat_priv *bat_priv)struct hlist_node *walk, *safe;struct hlist_head *head;struct element_t *bucket; +spinlock_t *list_lock;struct orig_node *orig_node;int i;
@@ -300,22 +303,26 @@ static void _purge_orig(struct bat_priv *bat_priv)/* for all origins... */ for (i =0 ; i < hash->size; i++) { head = &hash->table[i]; + list_lock = &hash->list_locks[i]; +spin_lock_bh (list_lock);hlist_for_each_entry_safe (bucket, walk, safe, head, hlist) { orig_node = bucket->data;if (purge_orig_node (bat_priv, orig_node)) {if (orig_node->gw_flags)gw_node_delete (bat_priv, orig_node); -hlist_del (walk); -kfree (bucket); +hlist_del_rcu (walk); +call_rcu (&bucket->rcu, bucket_free_rcu);free_orig_node (orig_node, bat_priv); +continue ; }if (time_after (jiffies, orig_node->last_frag_packet +msecs_to_jiffies (FRAG_TIMEOUT )))frag_list_free (&orig_node->frag_list); } +spin_unlock_bh (list_lock); }spin_unlock_bh (&bat_priv->orig_hash_lock);
@@ -382,7 +389,8 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)for (i =0 ; i < hash->size; i++) { head = &hash->table[i]; -hlist_for_each_entry (bucket, walk, head, hlist) { +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data;if (!orig_node->router)
@@ -403,17 +411,16 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) neigh_node->addr, neigh_node->if_incoming->net_dev->name); -rcu_read_lock ();hlist_for_each_entry_rcu (neigh_node, node, &orig_node->neigh_list, list) {seq_printf (seq," %pM (%3i)" , neigh_node->addr, neigh_node->tq_avg); } -rcu_read_unlock ();seq_printf (seq,"\n" ); batman_count++; } +rcu_read_unlock (); }spin_unlock_bh (&bat_priv->orig_hash_lock);
@@ -471,18 +478,21 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)for (i =0 ; i < hash->size; i++) { head = &hash->table[i]; -hlist_for_each_entry (bucket, walk, head, hlist) { +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data;if (orig_node_add_if (orig_node, max_if_num) ==-1 ) goto err; } +rcu_read_unlock (); }spin_unlock_bh (&bat_priv->orig_hash_lock);return 0 ; err: +rcu_read_unlock ();spin_unlock_bh (&bat_priv->orig_hash_lock);return -ENOMEM ; }
@@ -557,7 +567,8 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)for (i =0 ; i < hash->size; i++) { head = &hash->table[i]; -hlist_for_each_entry (bucket, walk, head, hlist) { +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data; ret = orig_node_del_if(orig_node, max_if_num,
@@ -566,6 +577,7 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)if (ret ==-1 ) goto err; } +rcu_read_unlock (); }/* renumber remaining batman interfaces _inside_ of orig_hash_lock */
@@ -590,6 +602,7 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)return 0 ; err: +rcu_read_unlock ();spin_unlock_bh (&bat_priv->orig_hash_lock);return -ENOMEM ; }
batman-adv/routing.c +15 -1
@@ -53,7 +53,8 @@ void slide_own_bcast_window(struct batman_if *batman_if)for (i =0 ; i < hash->size; i++) { head = &hash->table[i]; -hlist_for_each_entry (bucket, walk, head, hlist) { +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data; word_index = batman_if->if_num *NUM_WORDS ; word = &(orig_node->bcast_own[word_index]);
@@ -62,6 +63,7 @@ void slide_own_bcast_window(struct batman_if *batman_if) orig_node->bcast_own_sum[batman_if->if_num] =bit_packet_count (word); } +rcu_read_unlock (); }spin_unlock_bh (&bat_priv->orig_hash_lock);
@@ -858,9 +860,11 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,/* answer echo request (ping) */ /* get routing information */ spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->orig)); +rcu_read_unlock (); ret =NET_RX_DROP ; if ((orig_node != NULL) &&
@@ -920,9 +924,11 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,/* get routing information */ spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->orig)); +rcu_read_unlock (); ret =NET_RX_DROP ; if ((orig_node != NULL) &&
@@ -1014,9 +1020,11 @@ int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if)/* get routing information */ spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->dst)); +rcu_read_unlock ();if ((orig_node !=NULL ) && (orig_node->router !=NULL )) {
@@ -1087,9 +1095,11 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, router_orig->orig, ETH_ALEN) == 0) { primary_orig_node = router_orig; } else { +rcu_read_lock (); primary_orig_node =hash_find (bat_priv->orig_hash, compare_orig, choose_orig, router_orig->primary_addr); +rcu_read_unlock ();if (!primary_orig_node)return orig_node->router;
@@ -1192,9 +1202,11 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if,/* get routing information */ spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, unicast_packet->dest)); +rcu_read_unlock (); router =find_router (bat_priv, orig_node, recv_if);
@@ -1338,9 +1350,11 @@ int recv_bcast_packet(struct sk_buff *skb, struct batman_if *recv_if)return NET_RX_DROP ;spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, bcast_packet->orig)); +rcu_read_unlock ();if (orig_node ==NULL ) {spin_unlock_bh (&bat_priv->orig_hash_lock);
batman-adv/translation-table.c +14 -0
@@ -61,10 +61,12 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr)int required_bytes;spin_lock_bh (&bat_priv->hna_lhash_lock); +rcu_read_lock (); hna_local_entry = ((struct hna_local_entry *)hash_find (bat_priv->hna_local_hash, compare_orig, choose_orig, addr)); +rcu_read_unlock ();spin_unlock_bh (&bat_priv->hna_lhash_lock);if (hna_local_entry) {
@@ -117,9 +119,11 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr)/* remove address from global hash if present */ spin_lock_bh (&bat_priv->hna_ghash_lock); +rcu_read_lock (); hna_global_entry = ((struct hna_global_entry *)hash_find (bat_priv->hna_global_hash, compare_orig, choose_orig, addr)); +rcu_read_unlock ();if (hna_global_entry) _hna_global_del_orig(bat_priv, hna_global_entry,
@@ -253,9 +257,11 @@ void hna_local_remove(struct bat_priv *bat_priv,spin_lock_bh (&bat_priv->hna_lhash_lock); +rcu_read_lock (); hna_local_entry = (struct hna_local_entry *)hash_find (bat_priv->hna_local_hash, compare_orig, choose_orig, addr); +rcu_read_unlock ();if (hna_local_entry)hna_local_del (bat_priv, hna_local_entry, message);
@@ -335,9 +341,11 @@ void hna_global_add_orig(struct bat_priv *bat_priv,spin_lock_bh (&bat_priv->hna_ghash_lock); hna_ptr = hna_buff + (hna_buff_count *ETH_ALEN ); +rcu_read_lock (); hna_global_entry = (struct hna_global_entry *)hash_find (bat_priv->hna_global_hash, compare_orig, choose_orig, hna_ptr); +rcu_read_unlock ();if (!hna_global_entry) {spin_unlock_bh (&bat_priv->hna_ghash_lock);
@@ -369,9 +377,11 @@ void hna_global_add_orig(struct bat_priv *bat_priv,spin_lock_bh (&bat_priv->hna_lhash_lock); hna_ptr = hna_buff + (hna_buff_count *ETH_ALEN ); +rcu_read_lock (); hna_local_entry = (struct hna_local_entry *)hash_find (bat_priv->hna_local_hash, compare_orig, choose_orig, hna_ptr); +rcu_read_unlock ();if (hna_local_entry) hna_local_del(bat_priv, hna_local_entry,
@@ -484,9 +494,11 @@ void hna_global_del_orig(struct bat_priv *bat_priv,while ((hna_buff_count +1 ) *ETH_ALEN <= orig_node->hna_buff_len) { hna_ptr = orig_node->hna_buff + (hna_buff_count *ETH_ALEN ); +rcu_read_lock (); hna_global_entry = (struct hna_global_entry *)hash_find (bat_priv->hna_global_hash, compare_orig, choose_orig, hna_ptr); +rcu_read_unlock ();if ((hna_global_entry) && (hna_global_entry->orig_node == orig_node))
@@ -522,9 +534,11 @@ struct orig_node *transtable_search(struct bat_priv *bat_priv, uint8_t *addr)struct hna_global_entry *hna_global_entry;spin_lock_bh (&bat_priv->hna_ghash_lock); +rcu_read_lock (); hna_global_entry = (struct hna_global_entry *)hash_find (bat_priv->hna_global_hash, compare_orig, choose_orig, addr); +rcu_read_unlock ();spin_unlock_bh (&bat_priv->hna_ghash_lock);if (!hna_global_entry)
batman-adv/unicast.c +6 -1
@@ -179,9 +179,11 @@ int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, *new_skb =NULL ;spin_lock_bh (&bat_priv->orig_hash_lock); +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, unicast_packet->orig)); +rcu_read_unlock ();if (!orig_node) {pr_debug ("couldn't find originator in orig_hash\n" );
@@ -285,11 +287,14 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)/* get routing information */ if (is_multicast_ether_addr (ethhdr->h_dest)) orig_node = (struct orig_node *)gw_get_selected (bat_priv); -else +else { +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, ethhdr->h_dest)); +rcu_read_unlock (); + }/* check for hna host */ if (!orig_node)
batman-adv/vis.c +14 -4
@@ -380,8 +380,10 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, sizeof(struct vis_packet));memcpy (search_packet->vis_orig, vis_packet->vis_orig,ETH_ALEN ); +rcu_read_lock (); old_info =hash_find (bat_priv->vis_hash, vis_info_cmp, vis_info_choose, &search_elem); +rcu_read_unlock ();kfree_skb (search_elem.skb_packet);if (old_info !=NULL ) {
@@ -540,7 +542,8 @@ static int find_best_vis_server(struct bat_priv *bat_priv,for (i =0 ; i < hash->size; i++) { head = &hash->table[i]; -hlist_for_each_entry (bucket, walk, head, hlist) { +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data; if ((orig_node) && (orig_node->router) && (orig_node->flags & VIS_SERVER) &&
@@ -550,6 +553,7 @@ static int find_best_vis_server(struct bat_priv *bat_priv, ETH_ALEN); } } +rcu_read_unlock (); }return best_tq;
@@ -605,7 +609,8 @@ static int generate_vis_packet(struct bat_priv *bat_priv)for (i =0 ; i < hash->size; i++) { head = &hash->table[i]; -hlist_for_each_entry (bucket, walk, head, hlist) { +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data; neigh_node = orig_node->router;
@@ -632,10 +637,12 @@ static int generate_vis_packet(struct bat_priv *bat_priv) packet->entries++;if (vis_packet_full (info)) { +rcu_read_unlock ();spin_unlock_bh (&bat_priv->orig_hash_lock);return 0 ; } } +rcu_read_unlock (); }spin_unlock_bh (&bat_priv->orig_hash_lock);
@@ -721,7 +728,8 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv,for (i =0 ; i < hash->size; i++) { head = &hash->table[i]; -hlist_for_each_entry (bucket, walk, head, hlist) { +rcu_read_lock (); +hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data;/* if it's a vis server and reachable, send it. */
@@ -746,7 +754,7 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv,spin_lock_bh (&bat_priv->orig_hash_lock); } - +rcu_read_unlock (); }spin_unlock_bh (&bat_priv->orig_hash_lock);
@@ -763,9 +771,11 @@ static void unicast_vis_packet(struct bat_priv *bat_priv,spin_lock_bh (&bat_priv->orig_hash_lock); packet = (struct vis_packet *)info->skb_packet->data; +rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, packet->target_orig)); +rcu_read_unlock ();if ((!orig_node) || (!orig_node->router)) goto out;
Signature · 1 line
1.7.2.3
PATCH 7/9 batman-adv: protect originator nodes with reference counters
In reply to Sven EckelmannFrom: Marek Lindner <[email protected]>
---
Here is a great patch to see the call_rcu and kref_put problem
batman-adv/originator.c | 49 +++++++++++++++++++++++++++++++++++++++------- batman-adv/originator.h | 1 + batman-adv/routing.c | 39 ++++++++++++++++++++++++------------ batman-adv/types.h | 2 + 4 files changed, 70 insertions(+), 21 deletions(-)
batman-adv/originator.c +41 -8
@@ -103,12 +103,13 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node,return neigh_node; } -static void free_orig_node (void *data,void *arg) +void orig_node_free_ref (struct kref *refcount) {struct hlist_node *node, *node_tmp;struct neigh_node *neigh_node; -struct orig_node *orig_node = (struct orig_node *)data; -struct bat_priv *bat_priv = (struct bat_priv *)arg; +struct orig_node *orig_node; + + orig_node = container_of(refcount, struct orig_node, refcount);spin_lock_bh (&orig_node->neigh_list_lock);
@@ -122,7 +123,8 @@ static void free_orig_node(void *data, void *arg)spin_unlock_bh (&orig_node->neigh_list_lock);frag_list_free (&orig_node->frag_list); -hna_global_del_orig (bat_priv, orig_node,"originator timed out" ); +hna_global_del_orig (orig_node->bat_priv, orig_node, +"originator timed out" );kfree (orig_node->bcast_own);kfree (orig_node->bcast_own_sum);
@@ -131,14 +133,38 @@ static void free_orig_node(void *data, void *arg)void originator_free (struct bat_priv *bat_priv) { -if (!bat_priv->orig_hash) +struct hashtable_t *hash = bat_priv->orig_hash; +struct hlist_node *walk, *safe; +struct hlist_head *head; +struct element_t *bucket; +spinlock_t *list_lock; +struct orig_node *orig_node; +int i; + +if (!hash)return ;cancel_delayed_work_sync (&bat_priv->orig_work);spin_lock_bh (&bat_priv->orig_hash_lock); -hash_delete (bat_priv->orig_hash, free_orig_node, bat_priv); bat_priv->orig_hash =NULL ; + +for (i =0 ; i < hash->size; i++) { + head = &hash->table[i]; + list_lock = &hash->list_locks[i]; + +spin_lock_bh (list_lock); +hlist_for_each_entry_safe (bucket, walk, safe, head, hlist) { + orig_node = bucket->data; + +hlist_del_rcu (walk); +call_rcu (&bucket->rcu, bucket_free_rcu); +kref_put (&orig_node->refcount, orig_node_free_ref); + } +spin_unlock_bh (list_lock); + } + +hash_destroy (hash);spin_unlock_bh (&bat_priv->orig_hash_lock); }
@@ -156,8 +182,10 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) addr));rcu_read_unlock (); -if (orig_node) +if (orig_node) { +kref_get (&orig_node->refcount);return orig_node; + }bat_dbg (DBG_BATMAN , bat_priv,"Creating new originator: %pM\n" , addr);
@@ -168,7 +196,9 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)INIT_HLIST_HEAD (&orig_node->neigh_list);spin_lock_init (&orig_node->neigh_list_lock); +kref_init (&orig_node->refcount); + orig_node->bat_priv = bat_priv;memcpy (orig_node->orig, addr,ETH_ALEN ); orig_node->router =NULL ; orig_node->hna_buff =NULL ;
@@ -197,6 +227,8 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)if (hash_added <0 ) goto free_bcast_own_sum; +/* extra reference for return */ +kref_get (&orig_node->refcount);return orig_node; free_bcast_own_sum:kfree (orig_node->bcast_own_sum);
@@ -313,8 +345,9 @@ static void _purge_orig(struct bat_priv *bat_priv)if (orig_node->gw_flags)gw_node_delete (bat_priv, orig_node);hlist_del_rcu (walk); +kref_put (&orig_node->refcount, + orig_node_free_ref);call_rcu (&bucket->rcu, bucket_free_rcu); -free_orig_node (orig_node, bat_priv);continue ; }
batman-adv/originator.h +1 -0
@@ -25,6 +25,7 @@int originator_init (struct bat_priv *bat_priv);void originator_free (struct bat_priv *bat_priv);void purge_orig_ref (struct bat_priv *bat_priv); +void orig_node_free_ref (struct kref *refcount);struct orig_node *get_orig_node (struct bat_priv *bat_priv,uint8_t *addr); struct neigh_node *create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
batman-adv/routing.c +26 -13
@@ -301,6 +301,8 @@ static void update_orig(struct bat_priv *bat_priv, neigh_node =create_neighbor (orig_node, orig_tmp, ethhdr->h_source, if_incoming); + +kref_put (&orig_tmp->refcount, orig_node_free_ref);if (!neigh_node)return ; }else
@@ -409,7 +411,7 @@ static char count_real_packets(struct ethhdr *ethhdr,int set_mark; orig_node =get_orig_node (bat_priv, batman_packet->orig); -if (orig_node ==NULL ) +if (!orig_node)return 0 ; seq_diff = batman_packet->seqno - orig_node->last_real_seqno;
@@ -417,7 +419,7 @@ static char count_real_packets(struct ethhdr *ethhdr,/* signalize caller that the packet is to be dropped. */ if (window_protected (bat_priv, seq_diff, &orig_node->batman_seqno_reset)) -return -1 ; + goto err;rcu_read_lock (); hlist_for_each_entry_rcu(tmp_neigh_node, node,
@@ -450,7 +452,12 @@ static char count_real_packets(struct ethhdr *ethhdr, orig_node->last_real_seqno = batman_packet->seqno; } +kref_put (&orig_node->refcount, orig_node_free_ref);return is_duplicate; + +err: +kref_put (&orig_node->refcount, orig_node_free_ref); +return -1 ; }/* copy primary address for bonding */
@@ -667,7 +674,6 @@ void receive_bat_packet(struct ethhdr *ethhdr,int offset; orig_neigh_node =get_orig_node (bat_priv, ethhdr->h_source); -if (!orig_neigh_node)return ;
@@ -688,6 +694,7 @@ void receive_bat_packet(struct ethhdr *ethhdr,bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: " "originator packet from myself (via neighbor)\n" ); +kref_put (&orig_neigh_node->refcount, orig_node_free_ref);return ; }
@@ -699,7 +706,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, } orig_node =get_orig_node (bat_priv, batman_packet->orig); -if (orig_node ==NULL ) +if (!orig_node)return ; is_duplicate =count_real_packets (ethhdr, batman_packet, if_incoming);
@@ -708,13 +715,13 @@ void receive_bat_packet(struct ethhdr *ethhdr,bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: packet within seqno protection time " "(sender: %pM)\n" , ethhdr->h_source); -return ; + goto out; }if (batman_packet->tq ==0 ) {bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: originator packet with tq equal 0\n" ); -return ; + goto out; }/* avoid temporary routing loops */
@@ -728,7 +735,7 @@ void receive_bat_packet(struct ethhdr *ethhdr,bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: ignoring all rebroadcast packets that " "may make me loop (sender: %pM)\n" , ethhdr->h_source); -return ; + goto out; }/* if sender is a direct neighbor the sender mac equals
@@ -736,8 +743,8 @@ void receive_bat_packet(struct ethhdr *ethhdr, orig_neigh_node = (is_single_hop_neigh ? orig_node :get_orig_node (bat_priv, ethhdr->h_source)); -if (orig_neigh_node ==NULL ) -return ; +if (!orig_neigh_node) + goto out_neigh;/* drop packet if sender is not a direct neighbor and if we * don't route towards it */
@@ -745,7 +752,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, (orig_neigh_node->router == NULL)) {bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: OGM via unknown neighbor!\n" ); -return ; + goto out_neigh; } is_bidirectional = is_bidirectional_neigh(orig_node, orig_neigh_node,
@@ -773,26 +780,32 @@ void receive_bat_packet(struct ethhdr *ethhdr,bat_dbg (DBG_BATMAN , bat_priv,"Forwarding packet: " "rebroadcast neighbor packet with direct link flag\n" ); -return ; + goto out_neigh; }/* multihop originator */ if (!is_bidirectional) {bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: not received via bidirectional link\n" ); -return ; + goto out_neigh; }if (is_duplicate) {bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: duplicate packet received\n" ); -return ; + goto out_neigh; }bat_dbg (DBG_BATMAN , bat_priv,"Forwarding packet: rebroadcast originator packet\n" );schedule_forward_packet (orig_node, ethhdr, batman_packet,0 , hna_buff_len, if_incoming); + +out_neigh: +if (!is_single_hop_neigh) +kref_put (&orig_neigh_node->refcount, orig_node_free_ref); +out: +kref_put (&orig_node->refcount, orig_node_free_ref); }int recv_bat_packet (struct sk_buff *skb,struct batman_if *batman_if)
batman-adv/types.h +2 -0
@@ -86,6 +86,8 @@ struct orig_node {struct hlist_head neigh_list;struct list_head frag_list;spinlock_t neigh_list_lock;/* protects neighbor list */ +struct kref refcount; +struct bat_priv *bat_priv;unsigned long last_frag_packet;struct {uint8_t candidates;
Signature · 1 line
1.7.2.3
PATCH 8/9 batman-adv: protect ogm counter arrays with spinlock
In reply to Sven EckelmannFrom: Marek Lindner <[email protected]>
--- batman-adv/originator.c | 11 +++++++++-- batman-adv/routing.c | 27 +++++++++++++++++++++++---- batman-adv/types.h | 1 + 3 files changed, 33 insertions(+), 6 deletions(-)
batman-adv/originator.c +9 -2
@@ -195,6 +195,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)return NULL ;INIT_HLIST_HEAD (&orig_node->neigh_list); +spin_lock_init (&orig_node->ogm_cnt_lock);spin_lock_init (&orig_node->neigh_list_lock);kref_init (&orig_node->refcount);
@@ -502,7 +503,7 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)struct hlist_head *head;struct element_t *bucket;struct orig_node *orig_node; -int i; +int i, ret;/* resize all orig nodes because orig_node->bcast_own(_sum) depend on * if_num */
@@ -515,7 +516,11 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data; -if (orig_node_add_if (orig_node, max_if_num) ==-1 ) +spin_lock_bh (&orig_node->ogm_cnt_lock); + ret =orig_node_add_if (orig_node, max_if_num); +spin_unlock_bh (&orig_node->ogm_cnt_lock); + +if (ret ==-1 ) goto err; }rcu_read_unlock ();
@@ -604,8 +609,10 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data; +spin_lock_bh (&orig_node->ogm_cnt_lock); ret =orig_node_del_if (orig_node, max_if_num, batman_if->if_num); +spin_unlock_bh (&orig_node->ogm_cnt_lock);if (ret ==-1 ) goto err;
batman-adv/routing.c +23 -4
@@ -56,12 +56,14 @@ void slide_own_bcast_window(struct batman_if *batman_if)rcu_read_lock ();hlist_for_each_entry_rcu (bucket, walk, head, hlist) { orig_node = bucket->data; +spin_lock_bh (&orig_node->ogm_cnt_lock); word_index = batman_if->if_num *NUM_WORDS ; word = &(orig_node->bcast_own[word_index]);bit_get_packet (bat_priv, word,1 ,0 ); orig_node->bcast_own_sum[batman_if->if_num] =bit_packet_count (word); +spin_unlock_bh (&orig_node->ogm_cnt_lock); }rcu_read_unlock (); }
@@ -267,8 +269,10 @@ static void update_orig(struct bat_priv *bat_priv, char is_duplicate) {struct neigh_node *neigh_node =NULL , *tmp_neigh_node =NULL ; +struct orig_node *orig_node_tmp;struct hlist_node *node;int tmp_hna_buff_len; +uint8_t bcast_own_sum_orig, bcast_own_sum_neigh;bat_dbg (DBG_BATMAN , bat_priv,"update_originator(): " "Searching and updating originator entry of received packet\n" );
@@ -338,10 +342,22 @@ static void update_orig(struct bat_priv *bat_priv,/* if the TQ is the same and the link not more symetric we * won't consider it either */ if ((orig_node->router) && - ((neigh_node->tq_avg == orig_node->router->tq_avg) && - (orig_node->router->orig_node->bcast_own_sum[if_incoming->if_num] - >= neigh_node->orig_node->bcast_own_sum[if_incoming->if_num]))) - goto update_hna; + (neigh_node->tq_avg == orig_node->router->tq_avg)) { + orig_node_tmp = orig_node->router->orig_node; +spin_lock_bh (&orig_node_tmp->ogm_cnt_lock); + bcast_own_sum_orig = + orig_node_tmp->bcast_own_sum[if_incoming->if_num]; +spin_unlock_bh (&orig_node_tmp->ogm_cnt_lock); + + orig_node_tmp = neigh_node->orig_node; +spin_lock_bh (&orig_node_tmp->ogm_cnt_lock); + bcast_own_sum_neigh = + orig_node_tmp->bcast_own_sum[if_incoming->if_num]; +spin_unlock_bh (&orig_node_tmp->ogm_cnt_lock); + +if (bcast_own_sum_orig >= bcast_own_sum_neigh) + goto update_hna; + }update_routes (bat_priv, orig_node, neigh_node, hna_buff, tmp_hna_buff_len);
@@ -686,10 +702,13 @@ void receive_bat_packet(struct ethhdr *ethhdr, batman_packet->orig) && (batman_packet->seqno - if_incoming_seqno + 2 == 0)) { offset = if_incoming->if_num *NUM_WORDS ; + +spin_lock_bh (&orig_neigh_node->ogm_cnt_lock); word = &(orig_neigh_node->bcast_own[offset]);bit_mark (word,0 ); orig_neigh_node->bcast_own_sum[if_incoming->if_num] =bit_packet_count (word); +spin_unlock_bh (&orig_neigh_node->ogm_cnt_lock); } bat_dbg(DBG_BATMAN, bat_priv, "Drop packet: "
batman-adv/types.h +1 -0
@@ -89,6 +89,7 @@ struct orig_node {struct kref refcount;struct bat_priv *bat_priv;unsigned long last_frag_packet; +spinlock_t ogm_cnt_lock;/* protects ogm counter */ struct {uint8_t candidates;struct neigh_node *selected;
Signature · 1 line
1.7.2.3
PATCH 9/9 batman-adv: remove orig_hash spinlock
In reply to Sven EckelmannFrom: Marek Lindner <[email protected]>
---
This patch doesn't make sense for me. Shouldn't we only remove the spin_locks here and fixing the rest we rest earlier?
batman-adv/icmp_socket.c | 35 +++-- batman-adv/main.c | 1 - batman-adv/originator.c | 21 --- batman-adv/routing.c | 322 ++++++++++++++++++++------------------- batman-adv/translation-table.c | 4 + batman-adv/types.h | 1 - batman-adv/unicast.c | 96 +++++++----- batman-adv/vis.c | 61 ++++---- 8 files changed, 274 insertions(+), 267 deletions(-)
batman-adv/icmp_socket.c +18 -17
@@ -157,10 +157,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,struct sk_buff *skb;struct icmp_packet_rr *icmp_packet; -struct orig_node *orig_node; -struct batman_if *batman_if; +struct orig_node *orig_node =NULL ; +struct neigh_node *neigh_node =NULL ;size_t packet_len =sizeof (struct icmp_packet ); -uint8_t dstaddr[ETH_ALEN ];if (len <sizeof (struct icmp_packet )) { bat_dbg(DBG_BATMAN, bat_priv,
@@ -220,49 +219,51 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,if (atomic_read (&bat_priv->mesh_state) !=MESH_ACTIVE ) goto dst_unreach; -spin_lock_bh (&bat_priv->orig_hash_lock);rcu_read_lock (); orig_node = ((struct orig_node *)hash_find (bat_priv->orig_hash, compare_orig, choose_orig, icmp_packet->dst)); -rcu_read_unlock ();if (!orig_node) goto unlock; -if (!orig_node->router) +kref_get (&orig_node->refcount); + neigh_node = orig_node->router; + +if (!neigh_node) goto unlock; - batman_if = orig_node->router->if_incoming; -memcpy (dstaddr, orig_node->router->addr,ETH_ALEN ); +kref_get (&neigh_node->refcount); +rcu_read_unlock (); -spin_unlock_bh (&bat_priv->orig_hash_lock); - -if (!batman_if) +if (!neigh_node->if_incoming) goto dst_unreach; -if (batman_if->if_status !=IF_ACTIVE ) +if (neigh_node->if_incoming->if_status !=IF_ACTIVE ) goto dst_unreach;memcpy (icmp_packet->orig, bat_priv->primary_if->net_dev->dev_addr,ETH_ALEN );if (packet_len ==sizeof (struct icmp_packet_rr )) -memcpy (icmp_packet->rr, batman_if->net_dev->dev_addr,ETH_ALEN ); - - -send_skb_packet (skb, batman_if, dstaddr); +memcpy (icmp_packet->rr, + neigh_node->if_incoming->net_dev->dev_addr,ETH_ALEN ); +send_skb_packet (skb, neigh_node->if_incoming, neigh_node->addr); goto out; unlock: -spin_unlock_bh (&bat_priv->orig_hash_lock); +rcu_read_unlock (); dst_unreach: icmp_packet->msg_type =DESTINATION_UNREACHABLE ;bat_socket_add_packet (socket_client, icmp_packet, packet_len); free_skb:kfree_skb (skb); out: +if (neigh_node) +kref_put (&neigh_node->refcount, neigh_node_free_ref); +if (orig_node) +kref_put (&orig_node->refcount, orig_node_free_ref);return len; }
batman-adv/main.c +0 -1
@@ -80,7 +80,6 @@ int mesh_init(struct net_device *soft_iface) {struct bat_priv *bat_priv =netdev_priv (soft_iface); -spin_lock_init (&bat_priv->orig_hash_lock);spin_lock_init (&bat_priv->forw_bat_list_lock);spin_lock_init (&bat_priv->forw_bcast_list_lock);spin_lock_init (&bat_priv->hna_lhash_lock);
batman-adv/originator.c +0 -21
@@ -44,18 +44,15 @@ int originator_init(struct bat_priv *bat_priv)if (bat_priv->orig_hash)return 1 ; -spin_lock_bh (&bat_priv->orig_hash_lock); bat_priv->orig_hash =hash_new (1024 );if (!bat_priv->orig_hash) goto err; -spin_unlock_bh (&bat_priv->orig_hash_lock);start_purge_timer (bat_priv);return 1 ; err: -spin_unlock_bh (&bat_priv->orig_hash_lock);return 0 ; }
@@ -146,7 +143,6 @@ void originator_free(struct bat_priv *bat_priv)cancel_delayed_work_sync (&bat_priv->orig_work); -spin_lock_bh (&bat_priv->orig_hash_lock); bat_priv->orig_hash =NULL ;for (i =0 ; i < hash->size; i++) {
@@ -165,7 +161,6 @@ void originator_free(struct bat_priv *bat_priv) }hash_destroy (hash); -spin_unlock_bh (&bat_priv->orig_hash_lock); }/* this function finds or creates an originator entry for the given
@@ -331,8 +326,6 @@ static void _purge_orig(struct bat_priv *bat_priv)if (!hash)return ; -spin_lock_bh (&bat_priv->orig_hash_lock); -/* for all origins... */ for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
@@ -359,8 +352,6 @@ static void _purge_orig(struct bat_priv *bat_priv)spin_unlock_bh (list_lock); } -spin_unlock_bh (&bat_priv->orig_hash_lock); -gw_node_purge (bat_priv);gw_election (bat_priv);
@@ -418,8 +409,6 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)"Originator" ,"last-seen" ,"#" ,TQ_MAX_VALUE ,"Nexthop" , "outgoingIF", "Potential nexthops"); -spin_lock_bh (&bat_priv->orig_hash_lock); -for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
@@ -457,8 +446,6 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)rcu_read_unlock (); } -spin_unlock_bh (&bat_priv->orig_hash_lock); -if ((batman_count ==0 ))seq_printf (seq,"No batman nodes in range ...\n" );
@@ -507,8 +494,6 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)/* resize all orig nodes because orig_node->bcast_own(_sum) depend on * if_num */ -spin_lock_bh (&bat_priv->orig_hash_lock); -for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
@@ -526,12 +511,10 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)rcu_read_unlock (); } -spin_unlock_bh (&bat_priv->orig_hash_lock);return 0 ; err:rcu_read_unlock (); -spin_unlock_bh (&bat_priv->orig_hash_lock);return -ENOMEM ; }
@@ -600,8 +583,6 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)/* resize all orig nodes because orig_node->bcast_own(_sum) depend on * if_num */ -spin_lock_bh (&bat_priv->orig_hash_lock); -for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
@@ -638,11 +619,9 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)rcu_read_unlock (); batman_if->if_num =-1 ; -spin_unlock_bh (&bat_priv->orig_hash_lock);return 0 ; err:rcu_read_unlock (); -spin_unlock_bh (&bat_priv->orig_hash_lock);return -ENOMEM ; }
batman-adv/routing.c +165 -157
569 lines not on this page · raw message
batman-adv/translation-table.c +4 -0
@@ -538,6 +538,10 @@ struct orig_node *transtable_search(struct bat_priv *bat_priv, uint8_t *addr) hna_global_entry = (struct hna_global_entry *)hash_find (bat_priv->hna_global_hash, compare_orig, choose_orig, addr); + +if (hna_global_entry) +kref_get (&hna_global_entry->orig_node->refcount); +rcu_read_unlock ();spin_unlock_bh (&bat_priv->hna_ghash_lock);
batman-adv/types.h +0 -1
@@ -157,7 +157,6 @@ struct bat_priv {struct hashtable_t *hna_local_hash;struct hashtable_t *hna_global_hash;struct hashtable_t *vis_hash; -spinlock_t orig_hash_lock;/* protects orig_hash */ spinlock_t forw_bat_list_lock;/* protects forw_bat_list */ spinlock_t forw_bcast_list_lock;/* protects */ spinlock_t hna_lhash_lock;/* protects hna_local_hash */
batman-adv/unicast.c +57 -39
148 lines not on this page · raw message
batman-adv/vis.c +30 -31
131 lines not on this page · raw message
Signature · 1 line
1.7.2.3