diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2010-12-12 16:57:11 -0500 |
---|---|---|
committer | Marek Lindner <lindner_marek@yahoo.de> | 2011-03-05 06:49:53 -0500 |
commit | 9591a79f280ede740e44aeb8ad93a6692d482dce (patch) | |
tree | 4472796690f19a55f56a1974537a120965978903 /net/batman-adv | |
parent | a8e7f4bc38c4a90ee308cd7f1f8604f71db59d05 (diff) |
batman-adv: convert neighbor list to hlist
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/originator.c | 30 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 29 | ||||
-rw-r--r-- | net/batman-adv/types.h | 4 |
3 files changed, 35 insertions, 28 deletions
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index b1b1773afa0b..68b04e77f4d7 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -82,29 +82,28 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node, | |||
82 | if (!neigh_node) | 82 | if (!neigh_node) |
83 | return NULL; | 83 | return NULL; |
84 | 84 | ||
85 | INIT_LIST_HEAD(&neigh_node->list); | 85 | INIT_HLIST_NODE(&neigh_node->list); |
86 | 86 | ||
87 | memcpy(neigh_node->addr, neigh, ETH_ALEN); | 87 | memcpy(neigh_node->addr, neigh, ETH_ALEN); |
88 | neigh_node->orig_node = orig_neigh_node; | 88 | neigh_node->orig_node = orig_neigh_node; |
89 | neigh_node->if_incoming = if_incoming; | 89 | neigh_node->if_incoming = if_incoming; |
90 | kref_init(&neigh_node->refcount); | 90 | kref_init(&neigh_node->refcount); |
91 | 91 | ||
92 | list_add_tail(&neigh_node->list, &orig_node->neigh_list); | 92 | hlist_add_head(&neigh_node->list, &orig_node->neigh_list); |
93 | return neigh_node; | 93 | return neigh_node; |
94 | } | 94 | } |
95 | 95 | ||
96 | static void free_orig_node(void *data, void *arg) | 96 | static void free_orig_node(void *data, void *arg) |
97 | { | 97 | { |
98 | struct list_head *list_pos, *list_pos_tmp; | 98 | struct hlist_node *node, *node_tmp; |
99 | struct neigh_node *neigh_node; | 99 | struct neigh_node *neigh_node; |
100 | struct orig_node *orig_node = (struct orig_node *)data; | 100 | struct orig_node *orig_node = (struct orig_node *)data; |
101 | struct bat_priv *bat_priv = (struct bat_priv *)arg; | 101 | struct bat_priv *bat_priv = (struct bat_priv *)arg; |
102 | 102 | ||
103 | /* for all neighbors towards this originator ... */ | 103 | /* for all neighbors towards this originator ... */ |
104 | list_for_each_safe(list_pos, list_pos_tmp, &orig_node->neigh_list) { | 104 | hlist_for_each_entry_safe(neigh_node, node, node_tmp, |
105 | neigh_node = list_entry(list_pos, struct neigh_node, list); | 105 | &orig_node->neigh_list, list) { |
106 | 106 | hlist_del(&neigh_node->list); | |
107 | list_del(list_pos); | ||
108 | kref_put(&neigh_node->refcount, neigh_node_free_ref); | 107 | kref_put(&neigh_node->refcount, neigh_node_free_ref); |
109 | } | 108 | } |
110 | 109 | ||
@@ -151,7 +150,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) | |||
151 | if (!orig_node) | 150 | if (!orig_node) |
152 | return NULL; | 151 | return NULL; |
153 | 152 | ||
154 | INIT_LIST_HEAD(&orig_node->neigh_list); | 153 | INIT_HLIST_HEAD(&orig_node->neigh_list); |
155 | 154 | ||
156 | memcpy(orig_node->orig, addr, ETH_ALEN); | 155 | memcpy(orig_node->orig, addr, ETH_ALEN); |
157 | orig_node->router = NULL; | 156 | orig_node->router = NULL; |
@@ -195,15 +194,15 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, | |||
195 | struct orig_node *orig_node, | 194 | struct orig_node *orig_node, |
196 | struct neigh_node **best_neigh_node) | 195 | struct neigh_node **best_neigh_node) |
197 | { | 196 | { |
198 | struct list_head *list_pos, *list_pos_tmp; | 197 | struct hlist_node *node, *node_tmp; |
199 | struct neigh_node *neigh_node; | 198 | struct neigh_node *neigh_node; |
200 | bool neigh_purged = false; | 199 | bool neigh_purged = false; |
201 | 200 | ||
202 | *best_neigh_node = NULL; | 201 | *best_neigh_node = NULL; |
203 | 202 | ||
204 | /* for all neighbors towards this originator ... */ | 203 | /* for all neighbors towards this originator ... */ |
205 | list_for_each_safe(list_pos, list_pos_tmp, &orig_node->neigh_list) { | 204 | hlist_for_each_entry_safe(neigh_node, node, node_tmp, |
206 | neigh_node = list_entry(list_pos, struct neigh_node, list); | 205 | &orig_node->neigh_list, list) { |
207 | 206 | ||
208 | if ((time_after(jiffies, | 207 | if ((time_after(jiffies, |
209 | neigh_node->last_valid + PURGE_TIMEOUT * HZ)) || | 208 | neigh_node->last_valid + PURGE_TIMEOUT * HZ)) || |
@@ -225,7 +224,8 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, | |||
225 | (neigh_node->last_valid / HZ)); | 224 | (neigh_node->last_valid / HZ)); |
226 | 225 | ||
227 | neigh_purged = true; | 226 | neigh_purged = true; |
228 | list_del(list_pos); | 227 | |
228 | hlist_del(&neigh_node->list); | ||
229 | kref_put(&neigh_node->refcount, neigh_node_free_ref); | 229 | kref_put(&neigh_node->refcount, neigh_node_free_ref); |
230 | } else { | 230 | } else { |
231 | if ((!*best_neigh_node) || | 231 | if ((!*best_neigh_node) || |
@@ -328,7 +328,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) | |||
328 | struct net_device *net_dev = (struct net_device *)seq->private; | 328 | struct net_device *net_dev = (struct net_device *)seq->private; |
329 | struct bat_priv *bat_priv = netdev_priv(net_dev); | 329 | struct bat_priv *bat_priv = netdev_priv(net_dev); |
330 | struct hashtable_t *hash = bat_priv->orig_hash; | 330 | struct hashtable_t *hash = bat_priv->orig_hash; |
331 | struct hlist_node *walk; | 331 | struct hlist_node *walk, *node; |
332 | struct hlist_head *head; | 332 | struct hlist_head *head; |
333 | struct element_t *bucket; | 333 | struct element_t *bucket; |
334 | struct orig_node *orig_node; | 334 | struct orig_node *orig_node; |
@@ -384,8 +384,8 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) | |||
384 | neigh_node->addr, | 384 | neigh_node->addr, |
385 | neigh_node->if_incoming->net_dev->name); | 385 | neigh_node->if_incoming->net_dev->name); |
386 | 386 | ||
387 | list_for_each_entry(neigh_node, &orig_node->neigh_list, | 387 | hlist_for_each_entry(neigh_node, node, |
388 | list) { | 388 | &orig_node->neigh_list, list) { |
389 | seq_printf(seq, " %pM (%3i)", neigh_node->addr, | 389 | seq_printf(seq, " %pM (%3i)", neigh_node->addr, |
390 | neigh_node->tq_avg); | 390 | neigh_node->tq_avg); |
391 | } | 391 | } |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 36351d374f28..e8379ba25e95 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -149,12 +149,12 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, | |||
149 | { | 149 | { |
150 | struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); | 150 | struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); |
151 | struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; | 151 | struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; |
152 | struct hlist_node *node; | ||
152 | unsigned char total_count; | 153 | unsigned char total_count; |
153 | 154 | ||
154 | if (orig_node == orig_neigh_node) { | 155 | if (orig_node == orig_neigh_node) { |
155 | list_for_each_entry(tmp_neigh_node, | 156 | hlist_for_each_entry(tmp_neigh_node, node, |
156 | &orig_node->neigh_list, | 157 | &orig_node->neigh_list, list) { |
157 | list) { | ||
158 | 158 | ||
159 | if (compare_orig(tmp_neigh_node->addr, | 159 | if (compare_orig(tmp_neigh_node->addr, |
160 | orig_neigh_node->orig) && | 160 | orig_neigh_node->orig) && |
@@ -174,8 +174,8 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, | |||
174 | neigh_node->last_valid = jiffies; | 174 | neigh_node->last_valid = jiffies; |
175 | } else { | 175 | } else { |
176 | /* find packet count of corresponding one hop neighbor */ | 176 | /* find packet count of corresponding one hop neighbor */ |
177 | list_for_each_entry(tmp_neigh_node, | 177 | hlist_for_each_entry(tmp_neigh_node, node, |
178 | &orig_neigh_node->neigh_list, list) { | 178 | &orig_neigh_node->neigh_list, list) { |
179 | 179 | ||
180 | if (compare_orig(tmp_neigh_node->addr, | 180 | if (compare_orig(tmp_neigh_node->addr, |
181 | orig_neigh_node->orig) && | 181 | orig_neigh_node->orig) && |
@@ -260,12 +260,14 @@ static void update_orig(struct bat_priv *bat_priv, | |||
260 | char is_duplicate) | 260 | char is_duplicate) |
261 | { | 261 | { |
262 | struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; | 262 | struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; |
263 | struct hlist_node *node; | ||
263 | int tmp_hna_buff_len; | 264 | int tmp_hna_buff_len; |
264 | 265 | ||
265 | bat_dbg(DBG_BATMAN, bat_priv, "update_originator(): " | 266 | bat_dbg(DBG_BATMAN, bat_priv, "update_originator(): " |
266 | "Searching and updating originator entry of received packet\n"); | 267 | "Searching and updating originator entry of received packet\n"); |
267 | 268 | ||
268 | list_for_each_entry(tmp_neigh_node, &orig_node->neigh_list, list) { | 269 | hlist_for_each_entry(tmp_neigh_node, node, |
270 | &orig_node->neigh_list, list) { | ||
269 | if (compare_orig(tmp_neigh_node->addr, ethhdr->h_source) && | 271 | if (compare_orig(tmp_neigh_node->addr, ethhdr->h_source) && |
270 | (tmp_neigh_node->if_incoming == if_incoming)) { | 272 | (tmp_neigh_node->if_incoming == if_incoming)) { |
271 | neigh_node = tmp_neigh_node; | 273 | neigh_node = tmp_neigh_node; |
@@ -391,6 +393,7 @@ static char count_real_packets(struct ethhdr *ethhdr, | |||
391 | struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); | 393 | struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); |
392 | struct orig_node *orig_node; | 394 | struct orig_node *orig_node; |
393 | struct neigh_node *tmp_neigh_node; | 395 | struct neigh_node *tmp_neigh_node; |
396 | struct hlist_node *node; | ||
394 | char is_duplicate = 0; | 397 | char is_duplicate = 0; |
395 | int32_t seq_diff; | 398 | int32_t seq_diff; |
396 | int need_update = 0; | 399 | int need_update = 0; |
@@ -407,7 +410,8 @@ static char count_real_packets(struct ethhdr *ethhdr, | |||
407 | &orig_node->batman_seqno_reset)) | 410 | &orig_node->batman_seqno_reset)) |
408 | return -1; | 411 | return -1; |
409 | 412 | ||
410 | list_for_each_entry(tmp_neigh_node, &orig_node->neigh_list, list) { | 413 | hlist_for_each_entry(tmp_neigh_node, node, |
414 | &orig_node->neigh_list, list) { | ||
411 | 415 | ||
412 | is_duplicate |= get_bit_status(tmp_neigh_node->real_bits, | 416 | is_duplicate |= get_bit_status(tmp_neigh_node->real_bits, |
413 | orig_node->last_real_seqno, | 417 | orig_node->last_real_seqno, |
@@ -457,6 +461,7 @@ void update_bonding_candidates(struct orig_node *orig_node) | |||
457 | int candidates; | 461 | int candidates; |
458 | int interference_candidate; | 462 | int interference_candidate; |
459 | int best_tq; | 463 | int best_tq; |
464 | struct hlist_node *node, *node2; | ||
460 | struct neigh_node *tmp_neigh_node, *tmp_neigh_node2; | 465 | struct neigh_node *tmp_neigh_node, *tmp_neigh_node2; |
461 | struct neigh_node *first_candidate, *last_candidate; | 466 | struct neigh_node *first_candidate, *last_candidate; |
462 | 467 | ||
@@ -476,13 +481,15 @@ void update_bonding_candidates(struct orig_node *orig_node) | |||
476 | * as "bonding partner" */ | 481 | * as "bonding partner" */ |
477 | 482 | ||
478 | /* first, zero the list */ | 483 | /* first, zero the list */ |
479 | list_for_each_entry(tmp_neigh_node, &orig_node->neigh_list, list) { | 484 | hlist_for_each_entry(tmp_neigh_node, node, |
485 | &orig_node->neigh_list, list) { | ||
480 | tmp_neigh_node->next_bond_candidate = NULL; | 486 | tmp_neigh_node->next_bond_candidate = NULL; |
481 | } | 487 | } |
482 | 488 | ||
483 | first_candidate = NULL; | 489 | first_candidate = NULL; |
484 | last_candidate = NULL; | 490 | last_candidate = NULL; |
485 | list_for_each_entry(tmp_neigh_node, &orig_node->neigh_list, list) { | 491 | hlist_for_each_entry(tmp_neigh_node, node, |
492 | &orig_node->neigh_list, list) { | ||
486 | 493 | ||
487 | /* only consider if it has the same primary address ... */ | 494 | /* only consider if it has the same primary address ... */ |
488 | if (memcmp(orig_node->orig, | 495 | if (memcmp(orig_node->orig, |
@@ -499,8 +506,8 @@ void update_bonding_candidates(struct orig_node *orig_node) | |||
499 | * select this candidate because of possible interference. */ | 506 | * select this candidate because of possible interference. */ |
500 | 507 | ||
501 | interference_candidate = 0; | 508 | interference_candidate = 0; |
502 | list_for_each_entry(tmp_neigh_node2, | 509 | hlist_for_each_entry(tmp_neigh_node2, node2, |
503 | &orig_node->neigh_list, list) { | 510 | &orig_node->neigh_list, list) { |
504 | 511 | ||
505 | if (tmp_neigh_node2 == tmp_neigh_node) | 512 | if (tmp_neigh_node2 == tmp_neigh_node) |
506 | continue; | 513 | continue; |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index f9217d5dad8e..779c5c30bd04 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
@@ -83,7 +83,7 @@ struct orig_node { | |||
83 | uint8_t last_ttl; | 83 | uint8_t last_ttl; |
84 | unsigned long bcast_bits[NUM_WORDS]; | 84 | unsigned long bcast_bits[NUM_WORDS]; |
85 | uint32_t last_bcast_seqno; | 85 | uint32_t last_bcast_seqno; |
86 | struct list_head neigh_list; | 86 | struct hlist_head neigh_list; |
87 | struct list_head frag_list; | 87 | struct list_head frag_list; |
88 | unsigned long last_frag_packet; | 88 | unsigned long last_frag_packet; |
89 | struct { | 89 | struct { |
@@ -105,7 +105,7 @@ struct gw_node { | |||
105 | * @last_valid: when last packet via this neighbor was received | 105 | * @last_valid: when last packet via this neighbor was received |
106 | */ | 106 | */ |
107 | struct neigh_node { | 107 | struct neigh_node { |
108 | struct list_head list; | 108 | struct hlist_node list; |
109 | uint8_t addr[ETH_ALEN]; | 109 | uint8_t addr[ETH_ALEN]; |
110 | uint8_t real_packet_count; | 110 | uint8_t real_packet_count; |
111 | uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE]; | 111 | uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE]; |