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/originator.c | |
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/originator.c')
-rw-r--r-- | net/batman-adv/originator.c | 30 |
1 files changed, 15 insertions, 15 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 | } |