diff options
Diffstat (limited to 'net/batman-adv/originator.c')
-rw-r--r-- | net/batman-adv/originator.c | 250 |
1 files changed, 128 insertions, 122 deletions
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 41147942ba53..f04f591f4668 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* | 1 | /* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: |
2 | * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: | ||
3 | * | 2 | * |
4 | * Marek Lindner, Simon Wunderlich | 3 | * Marek Lindner, Simon Wunderlich |
5 | * | 4 | * |
@@ -16,7 +15,6 @@ | |||
16 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
18 | * 02110-1301, USA | 17 | * 02110-1301, USA |
19 | * | ||
20 | */ | 18 | */ |
21 | 19 | ||
22 | #include "main.h" | 20 | #include "main.h" |
@@ -30,48 +28,48 @@ | |||
30 | #include "soft-interface.h" | 28 | #include "soft-interface.h" |
31 | #include "bridge_loop_avoidance.h" | 29 | #include "bridge_loop_avoidance.h" |
32 | 30 | ||
33 | static void purge_orig(struct work_struct *work); | 31 | static void batadv_purge_orig(struct work_struct *work); |
34 | 32 | ||
35 | static void start_purge_timer(struct bat_priv *bat_priv) | 33 | static void batadv_start_purge_timer(struct bat_priv *bat_priv) |
36 | { | 34 | { |
37 | INIT_DELAYED_WORK(&bat_priv->orig_work, purge_orig); | 35 | INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig); |
38 | queue_delayed_work(bat_event_workqueue, | 36 | queue_delayed_work(batadv_event_workqueue, |
39 | &bat_priv->orig_work, msecs_to_jiffies(1000)); | 37 | &bat_priv->orig_work, msecs_to_jiffies(1000)); |
40 | } | 38 | } |
41 | 39 | ||
42 | /* returns 1 if they are the same originator */ | 40 | /* returns 1 if they are the same originator */ |
43 | static int compare_orig(const struct hlist_node *node, const void *data2) | 41 | static int batadv_compare_orig(const struct hlist_node *node, const void *data2) |
44 | { | 42 | { |
45 | const void *data1 = container_of(node, struct orig_node, hash_entry); | 43 | const void *data1 = container_of(node, struct orig_node, hash_entry); |
46 | 44 | ||
47 | return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); | 45 | return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); |
48 | } | 46 | } |
49 | 47 | ||
50 | int originator_init(struct bat_priv *bat_priv) | 48 | int batadv_originator_init(struct bat_priv *bat_priv) |
51 | { | 49 | { |
52 | if (bat_priv->orig_hash) | 50 | if (bat_priv->orig_hash) |
53 | return 1; | 51 | return 0; |
54 | 52 | ||
55 | bat_priv->orig_hash = hash_new(1024); | 53 | bat_priv->orig_hash = batadv_hash_new(1024); |
56 | 54 | ||
57 | if (!bat_priv->orig_hash) | 55 | if (!bat_priv->orig_hash) |
58 | goto err; | 56 | goto err; |
59 | 57 | ||
60 | start_purge_timer(bat_priv); | 58 | batadv_start_purge_timer(bat_priv); |
61 | return 1; | 59 | return 0; |
62 | 60 | ||
63 | err: | 61 | err: |
64 | return 0; | 62 | return -ENOMEM; |
65 | } | 63 | } |
66 | 64 | ||
67 | void neigh_node_free_ref(struct neigh_node *neigh_node) | 65 | void batadv_neigh_node_free_ref(struct neigh_node *neigh_node) |
68 | { | 66 | { |
69 | if (atomic_dec_and_test(&neigh_node->refcount)) | 67 | if (atomic_dec_and_test(&neigh_node->refcount)) |
70 | kfree_rcu(neigh_node, rcu); | 68 | kfree_rcu(neigh_node, rcu); |
71 | } | 69 | } |
72 | 70 | ||
73 | /* increases the refcounter of a found router */ | 71 | /* increases the refcounter of a found router */ |
74 | struct neigh_node *orig_node_get_router(struct orig_node *orig_node) | 72 | struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node) |
75 | { | 73 | { |
76 | struct neigh_node *router; | 74 | struct neigh_node *router; |
77 | 75 | ||
@@ -104,15 +102,15 @@ struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, | |||
104 | /* extra reference for return */ | 102 | /* extra reference for return */ |
105 | atomic_set(&neigh_node->refcount, 2); | 103 | atomic_set(&neigh_node->refcount, 2); |
106 | 104 | ||
107 | bat_dbg(DBG_BATMAN, bat_priv, | 105 | batadv_dbg(DBG_BATMAN, bat_priv, |
108 | "Creating new neighbor %pM, initial seqno %d\n", | 106 | "Creating new neighbor %pM, initial seqno %d\n", |
109 | neigh_addr, seqno); | 107 | neigh_addr, seqno); |
110 | 108 | ||
111 | out: | 109 | out: |
112 | return neigh_node; | 110 | return neigh_node; |
113 | } | 111 | } |
114 | 112 | ||
115 | static void orig_node_free_rcu(struct rcu_head *rcu) | 113 | static void batadv_orig_node_free_rcu(struct rcu_head *rcu) |
116 | { | 114 | { |
117 | struct hlist_node *node, *node_tmp; | 115 | struct hlist_node *node, *node_tmp; |
118 | struct neigh_node *neigh_node, *tmp_neigh_node; | 116 | struct neigh_node *neigh_node, *tmp_neigh_node; |
@@ -126,21 +124,21 @@ static void orig_node_free_rcu(struct rcu_head *rcu) | |||
126 | list_for_each_entry_safe(neigh_node, tmp_neigh_node, | 124 | list_for_each_entry_safe(neigh_node, tmp_neigh_node, |
127 | &orig_node->bond_list, bonding_list) { | 125 | &orig_node->bond_list, bonding_list) { |
128 | list_del_rcu(&neigh_node->bonding_list); | 126 | list_del_rcu(&neigh_node->bonding_list); |
129 | neigh_node_free_ref(neigh_node); | 127 | batadv_neigh_node_free_ref(neigh_node); |
130 | } | 128 | } |
131 | 129 | ||
132 | /* for all neighbors towards this originator ... */ | 130 | /* for all neighbors towards this originator ... */ |
133 | hlist_for_each_entry_safe(neigh_node, node, node_tmp, | 131 | hlist_for_each_entry_safe(neigh_node, node, node_tmp, |
134 | &orig_node->neigh_list, list) { | 132 | &orig_node->neigh_list, list) { |
135 | hlist_del_rcu(&neigh_node->list); | 133 | hlist_del_rcu(&neigh_node->list); |
136 | neigh_node_free_ref(neigh_node); | 134 | batadv_neigh_node_free_ref(neigh_node); |
137 | } | 135 | } |
138 | 136 | ||
139 | spin_unlock_bh(&orig_node->neigh_list_lock); | 137 | spin_unlock_bh(&orig_node->neigh_list_lock); |
140 | 138 | ||
141 | frag_list_free(&orig_node->frag_list); | 139 | batadv_frag_list_free(&orig_node->frag_list); |
142 | tt_global_del_orig(orig_node->bat_priv, orig_node, | 140 | batadv_tt_global_del_orig(orig_node->bat_priv, orig_node, |
143 | "originator timed out"); | 141 | "originator timed out"); |
144 | 142 | ||
145 | kfree(orig_node->tt_buff); | 143 | kfree(orig_node->tt_buff); |
146 | kfree(orig_node->bcast_own); | 144 | kfree(orig_node->bcast_own); |
@@ -148,13 +146,13 @@ static void orig_node_free_rcu(struct rcu_head *rcu) | |||
148 | kfree(orig_node); | 146 | kfree(orig_node); |
149 | } | 147 | } |
150 | 148 | ||
151 | void orig_node_free_ref(struct orig_node *orig_node) | 149 | void batadv_orig_node_free_ref(struct orig_node *orig_node) |
152 | { | 150 | { |
153 | if (atomic_dec_and_test(&orig_node->refcount)) | 151 | if (atomic_dec_and_test(&orig_node->refcount)) |
154 | call_rcu(&orig_node->rcu, orig_node_free_rcu); | 152 | call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu); |
155 | } | 153 | } |
156 | 154 | ||
157 | void originator_free(struct bat_priv *bat_priv) | 155 | void batadv_originator_free(struct bat_priv *bat_priv) |
158 | { | 156 | { |
159 | struct hashtable_t *hash = bat_priv->orig_hash; | 157 | struct hashtable_t *hash = bat_priv->orig_hash; |
160 | struct hlist_node *node, *node_tmp; | 158 | struct hlist_node *node, *node_tmp; |
@@ -179,28 +177,31 @@ void originator_free(struct bat_priv *bat_priv) | |||
179 | head, hash_entry) { | 177 | head, hash_entry) { |
180 | 178 | ||
181 | hlist_del_rcu(node); | 179 | hlist_del_rcu(node); |
182 | orig_node_free_ref(orig_node); | 180 | batadv_orig_node_free_ref(orig_node); |
183 | } | 181 | } |
184 | spin_unlock_bh(list_lock); | 182 | spin_unlock_bh(list_lock); |
185 | } | 183 | } |
186 | 184 | ||
187 | hash_destroy(hash); | 185 | batadv_hash_destroy(hash); |
188 | } | 186 | } |
189 | 187 | ||
190 | /* this function finds or creates an originator entry for the given | 188 | /* this function finds or creates an originator entry for the given |
191 | * address if it does not exits */ | 189 | * address if it does not exits |
192 | struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr) | 190 | */ |
191 | struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, | ||
192 | const uint8_t *addr) | ||
193 | { | 193 | { |
194 | struct orig_node *orig_node; | 194 | struct orig_node *orig_node; |
195 | int size; | 195 | int size; |
196 | int hash_added; | 196 | int hash_added; |
197 | unsigned long reset_time; | ||
197 | 198 | ||
198 | orig_node = orig_hash_find(bat_priv, addr); | 199 | orig_node = batadv_orig_hash_find(bat_priv, addr); |
199 | if (orig_node) | 200 | if (orig_node) |
200 | return orig_node; | 201 | return orig_node; |
201 | 202 | ||
202 | bat_dbg(DBG_BATMAN, bat_priv, | 203 | batadv_dbg(DBG_BATMAN, bat_priv, "Creating new originator: %pM\n", |
203 | "Creating new originator: %pM\n", addr); | 204 | addr); |
204 | 205 | ||
205 | orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC); | 206 | orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC); |
206 | if (!orig_node) | 207 | if (!orig_node) |
@@ -226,14 +227,13 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr) | |||
226 | orig_node->tt_buff = NULL; | 227 | orig_node->tt_buff = NULL; |
227 | orig_node->tt_buff_len = 0; | 228 | orig_node->tt_buff_len = 0; |
228 | atomic_set(&orig_node->tt_size, 0); | 229 | atomic_set(&orig_node->tt_size, 0); |
229 | orig_node->bcast_seqno_reset = jiffies - 1 | 230 | reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); |
230 | - msecs_to_jiffies(RESET_PROTECTION_MS); | 231 | orig_node->bcast_seqno_reset = reset_time; |
231 | orig_node->batman_seqno_reset = jiffies - 1 | 232 | orig_node->batman_seqno_reset = reset_time; |
232 | - msecs_to_jiffies(RESET_PROTECTION_MS); | ||
233 | 233 | ||
234 | atomic_set(&orig_node->bond_candidates, 0); | 234 | atomic_set(&orig_node->bond_candidates, 0); |
235 | 235 | ||
236 | size = bat_priv->num_ifaces * sizeof(unsigned long) * NUM_WORDS; | 236 | size = bat_priv->num_ifaces * sizeof(unsigned long) * BATADV_NUM_WORDS; |
237 | 237 | ||
238 | orig_node->bcast_own = kzalloc(size, GFP_ATOMIC); | 238 | orig_node->bcast_own = kzalloc(size, GFP_ATOMIC); |
239 | if (!orig_node->bcast_own) | 239 | if (!orig_node->bcast_own) |
@@ -248,8 +248,9 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr) | |||
248 | if (!orig_node->bcast_own_sum) | 248 | if (!orig_node->bcast_own_sum) |
249 | goto free_bcast_own; | 249 | goto free_bcast_own; |
250 | 250 | ||
251 | hash_added = hash_add(bat_priv->orig_hash, compare_orig, | 251 | hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig, |
252 | choose_orig, orig_node, &orig_node->hash_entry); | 252 | batadv_choose_orig, orig_node, |
253 | &orig_node->hash_entry); | ||
253 | if (hash_added != 0) | 254 | if (hash_added != 0) |
254 | goto free_bcast_own_sum; | 255 | goto free_bcast_own_sum; |
255 | 256 | ||
@@ -263,14 +264,15 @@ free_orig_node: | |||
263 | return NULL; | 264 | return NULL; |
264 | } | 265 | } |
265 | 266 | ||
266 | static bool purge_orig_neighbors(struct bat_priv *bat_priv, | 267 | static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv, |
267 | struct orig_node *orig_node, | 268 | struct orig_node *orig_node, |
268 | struct neigh_node **best_neigh_node) | 269 | struct neigh_node **best_neigh_node) |
269 | { | 270 | { |
270 | struct hlist_node *node, *node_tmp; | 271 | struct hlist_node *node, *node_tmp; |
271 | struct neigh_node *neigh_node; | 272 | struct neigh_node *neigh_node; |
272 | bool neigh_purged = false; | 273 | bool neigh_purged = false; |
273 | unsigned long last_seen; | 274 | unsigned long last_seen; |
275 | struct hard_iface *if_incoming; | ||
274 | 276 | ||
275 | *best_neigh_node = NULL; | 277 | *best_neigh_node = NULL; |
276 | 278 | ||
@@ -280,34 +282,32 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, | |||
280 | hlist_for_each_entry_safe(neigh_node, node, node_tmp, | 282 | hlist_for_each_entry_safe(neigh_node, node, node_tmp, |
281 | &orig_node->neigh_list, list) { | 283 | &orig_node->neigh_list, list) { |
282 | 284 | ||
283 | if ((has_timed_out(neigh_node->last_seen, PURGE_TIMEOUT)) || | 285 | last_seen = neigh_node->last_seen; |
284 | (neigh_node->if_incoming->if_status == IF_INACTIVE) || | 286 | if_incoming = neigh_node->if_incoming; |
285 | (neigh_node->if_incoming->if_status == IF_NOT_IN_USE) || | 287 | |
286 | (neigh_node->if_incoming->if_status == IF_TO_BE_REMOVED)) { | 288 | if ((batadv_has_timed_out(last_seen, BATADV_PURGE_TIMEOUT)) || |
287 | 289 | (if_incoming->if_status == IF_INACTIVE) || | |
288 | last_seen = neigh_node->last_seen; | 290 | (if_incoming->if_status == IF_NOT_IN_USE) || |
289 | 291 | (if_incoming->if_status == IF_TO_BE_REMOVED)) { | |
290 | if ((neigh_node->if_incoming->if_status == | 292 | |
291 | IF_INACTIVE) || | 293 | if ((if_incoming->if_status == IF_INACTIVE) || |
292 | (neigh_node->if_incoming->if_status == | 294 | (if_incoming->if_status == IF_NOT_IN_USE) || |
293 | IF_NOT_IN_USE) || | 295 | (if_incoming->if_status == IF_TO_BE_REMOVED)) |
294 | (neigh_node->if_incoming->if_status == | 296 | batadv_dbg(DBG_BATMAN, bat_priv, |
295 | IF_TO_BE_REMOVED)) | 297 | "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n", |
296 | bat_dbg(DBG_BATMAN, bat_priv, | 298 | orig_node->orig, neigh_node->addr, |
297 | "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n", | 299 | if_incoming->net_dev->name); |
298 | orig_node->orig, neigh_node->addr, | ||
299 | neigh_node->if_incoming->net_dev->name); | ||
300 | else | 300 | else |
301 | bat_dbg(DBG_BATMAN, bat_priv, | 301 | batadv_dbg(DBG_BATMAN, bat_priv, |
302 | "neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n", | 302 | "neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n", |
303 | orig_node->orig, neigh_node->addr, | 303 | orig_node->orig, neigh_node->addr, |
304 | jiffies_to_msecs(last_seen)); | 304 | jiffies_to_msecs(last_seen)); |
305 | 305 | ||
306 | neigh_purged = true; | 306 | neigh_purged = true; |
307 | 307 | ||
308 | hlist_del_rcu(&neigh_node->list); | 308 | hlist_del_rcu(&neigh_node->list); |
309 | bonding_candidate_del(orig_node, neigh_node); | 309 | batadv_bonding_candidate_del(orig_node, neigh_node); |
310 | neigh_node_free_ref(neigh_node); | 310 | batadv_neigh_node_free_ref(neigh_node); |
311 | } else { | 311 | } else { |
312 | if ((!*best_neigh_node) || | 312 | if ((!*best_neigh_node) || |
313 | (neigh_node->tq_avg > (*best_neigh_node)->tq_avg)) | 313 | (neigh_node->tq_avg > (*best_neigh_node)->tq_avg)) |
@@ -319,27 +319,29 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, | |||
319 | return neigh_purged; | 319 | return neigh_purged; |
320 | } | 320 | } |
321 | 321 | ||
322 | static bool purge_orig_node(struct bat_priv *bat_priv, | 322 | static bool batadv_purge_orig_node(struct bat_priv *bat_priv, |
323 | struct orig_node *orig_node) | 323 | struct orig_node *orig_node) |
324 | { | 324 | { |
325 | struct neigh_node *best_neigh_node; | 325 | struct neigh_node *best_neigh_node; |
326 | 326 | ||
327 | if (has_timed_out(orig_node->last_seen, 2 * PURGE_TIMEOUT)) { | 327 | if (batadv_has_timed_out(orig_node->last_seen, |
328 | bat_dbg(DBG_BATMAN, bat_priv, | 328 | 2 * BATADV_PURGE_TIMEOUT)) { |
329 | "Originator timeout: originator %pM, last_seen %u\n", | 329 | batadv_dbg(DBG_BATMAN, bat_priv, |
330 | orig_node->orig, | 330 | "Originator timeout: originator %pM, last_seen %u\n", |
331 | jiffies_to_msecs(orig_node->last_seen)); | 331 | orig_node->orig, |
332 | jiffies_to_msecs(orig_node->last_seen)); | ||
332 | return true; | 333 | return true; |
333 | } else { | 334 | } else { |
334 | if (purge_orig_neighbors(bat_priv, orig_node, | 335 | if (batadv_purge_orig_neighbors(bat_priv, orig_node, |
335 | &best_neigh_node)) | 336 | &best_neigh_node)) |
336 | update_route(bat_priv, orig_node, best_neigh_node); | 337 | batadv_update_route(bat_priv, orig_node, |
338 | best_neigh_node); | ||
337 | } | 339 | } |
338 | 340 | ||
339 | return false; | 341 | return false; |
340 | } | 342 | } |
341 | 343 | ||
342 | static void _purge_orig(struct bat_priv *bat_priv) | 344 | static void _batadv_purge_orig(struct bat_priv *bat_priv) |
343 | { | 345 | { |
344 | struct hashtable_t *hash = bat_priv->orig_hash; | 346 | struct hashtable_t *hash = bat_priv->orig_hash; |
345 | struct hlist_node *node, *node_tmp; | 347 | struct hlist_node *node, *node_tmp; |
@@ -359,42 +361,43 @@ static void _purge_orig(struct bat_priv *bat_priv) | |||
359 | spin_lock_bh(list_lock); | 361 | spin_lock_bh(list_lock); |
360 | hlist_for_each_entry_safe(orig_node, node, node_tmp, | 362 | hlist_for_each_entry_safe(orig_node, node, node_tmp, |
361 | head, hash_entry) { | 363 | head, hash_entry) { |
362 | if (purge_orig_node(bat_priv, orig_node)) { | 364 | if (batadv_purge_orig_node(bat_priv, orig_node)) { |
363 | if (orig_node->gw_flags) | 365 | if (orig_node->gw_flags) |
364 | gw_node_delete(bat_priv, orig_node); | 366 | batadv_gw_node_delete(bat_priv, |
367 | orig_node); | ||
365 | hlist_del_rcu(node); | 368 | hlist_del_rcu(node); |
366 | orig_node_free_ref(orig_node); | 369 | batadv_orig_node_free_ref(orig_node); |
367 | continue; | 370 | continue; |
368 | } | 371 | } |
369 | 372 | ||
370 | if (has_timed_out(orig_node->last_frag_packet, | 373 | if (batadv_has_timed_out(orig_node->last_frag_packet, |
371 | FRAG_TIMEOUT)) | 374 | BATADV_FRAG_TIMEOUT)) |
372 | frag_list_free(&orig_node->frag_list); | 375 | batadv_frag_list_free(&orig_node->frag_list); |
373 | } | 376 | } |
374 | spin_unlock_bh(list_lock); | 377 | spin_unlock_bh(list_lock); |
375 | } | 378 | } |
376 | 379 | ||
377 | gw_node_purge(bat_priv); | 380 | batadv_gw_node_purge(bat_priv); |
378 | gw_election(bat_priv); | 381 | batadv_gw_election(bat_priv); |
379 | } | 382 | } |
380 | 383 | ||
381 | static void purge_orig(struct work_struct *work) | 384 | static void batadv_purge_orig(struct work_struct *work) |
382 | { | 385 | { |
383 | struct delayed_work *delayed_work = | 386 | struct delayed_work *delayed_work = |
384 | container_of(work, struct delayed_work, work); | 387 | container_of(work, struct delayed_work, work); |
385 | struct bat_priv *bat_priv = | 388 | struct bat_priv *bat_priv = |
386 | container_of(delayed_work, struct bat_priv, orig_work); | 389 | container_of(delayed_work, struct bat_priv, orig_work); |
387 | 390 | ||
388 | _purge_orig(bat_priv); | 391 | _batadv_purge_orig(bat_priv); |
389 | start_purge_timer(bat_priv); | 392 | batadv_start_purge_timer(bat_priv); |
390 | } | 393 | } |
391 | 394 | ||
392 | void purge_orig_ref(struct bat_priv *bat_priv) | 395 | void batadv_purge_orig_ref(struct bat_priv *bat_priv) |
393 | { | 396 | { |
394 | _purge_orig(bat_priv); | 397 | _batadv_purge_orig(bat_priv); |
395 | } | 398 | } |
396 | 399 | ||
397 | int orig_seq_print_text(struct seq_file *seq, void *offset) | 400 | int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) |
398 | { | 401 | { |
399 | struct net_device *net_dev = (struct net_device *)seq->private; | 402 | struct net_device *net_dev = (struct net_device *)seq->private; |
400 | struct bat_priv *bat_priv = netdev_priv(net_dev); | 403 | struct bat_priv *bat_priv = netdev_priv(net_dev); |
@@ -410,7 +413,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) | |||
410 | uint32_t i; | 413 | uint32_t i; |
411 | int ret = 0; | 414 | int ret = 0; |
412 | 415 | ||
413 | primary_if = primary_if_get_selected(bat_priv); | 416 | primary_if = batadv_primary_if_get_selected(bat_priv); |
414 | 417 | ||
415 | if (!primary_if) { | 418 | if (!primary_if) { |
416 | ret = seq_printf(seq, | 419 | ret = seq_printf(seq, |
@@ -427,18 +430,18 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) | |||
427 | } | 430 | } |
428 | 431 | ||
429 | seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", | 432 | seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", |
430 | SOURCE_VERSION, primary_if->net_dev->name, | 433 | BATADV_SOURCE_VERSION, primary_if->net_dev->name, |
431 | primary_if->net_dev->dev_addr, net_dev->name); | 434 | primary_if->net_dev->dev_addr, net_dev->name); |
432 | seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", | 435 | seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", |
433 | "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop", | 436 | "Originator", "last-seen", "#", BATADV_TQ_MAX_VALUE, |
434 | "outgoingIF", "Potential nexthops"); | 437 | "Nexthop", "outgoingIF", "Potential nexthops"); |
435 | 438 | ||
436 | for (i = 0; i < hash->size; i++) { | 439 | for (i = 0; i < hash->size; i++) { |
437 | head = &hash->table[i]; | 440 | head = &hash->table[i]; |
438 | 441 | ||
439 | rcu_read_lock(); | 442 | rcu_read_lock(); |
440 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { | 443 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { |
441 | neigh_node = orig_node_get_router(orig_node); | 444 | neigh_node = batadv_orig_node_get_router(orig_node); |
442 | if (!neigh_node) | 445 | if (!neigh_node) |
443 | continue; | 446 | continue; |
444 | 447 | ||
@@ -467,7 +470,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) | |||
467 | batman_count++; | 470 | batman_count++; |
468 | 471 | ||
469 | next: | 472 | next: |
470 | neigh_node_free_ref(neigh_node); | 473 | batadv_neigh_node_free_ref(neigh_node); |
471 | } | 474 | } |
472 | rcu_read_unlock(); | 475 | rcu_read_unlock(); |
473 | } | 476 | } |
@@ -477,27 +480,28 @@ next: | |||
477 | 480 | ||
478 | out: | 481 | out: |
479 | if (primary_if) | 482 | if (primary_if) |
480 | hardif_free_ref(primary_if); | 483 | batadv_hardif_free_ref(primary_if); |
481 | return ret; | 484 | return ret; |
482 | } | 485 | } |
483 | 486 | ||
484 | static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) | 487 | static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num) |
485 | { | 488 | { |
486 | void *data_ptr; | 489 | void *data_ptr; |
490 | size_t data_size, old_size; | ||
487 | 491 | ||
488 | data_ptr = kmalloc(max_if_num * sizeof(unsigned long) * NUM_WORDS, | 492 | data_size = max_if_num * sizeof(unsigned long) * BATADV_NUM_WORDS; |
489 | GFP_ATOMIC); | 493 | old_size = (max_if_num - 1) * sizeof(unsigned long) * BATADV_NUM_WORDS; |
494 | data_ptr = kmalloc(data_size, GFP_ATOMIC); | ||
490 | if (!data_ptr) | 495 | if (!data_ptr) |
491 | return -1; | 496 | return -ENOMEM; |
492 | 497 | ||
493 | memcpy(data_ptr, orig_node->bcast_own, | 498 | memcpy(data_ptr, orig_node->bcast_own, old_size); |
494 | (max_if_num - 1) * sizeof(unsigned long) * NUM_WORDS); | ||
495 | kfree(orig_node->bcast_own); | 499 | kfree(orig_node->bcast_own); |
496 | orig_node->bcast_own = data_ptr; | 500 | orig_node->bcast_own = data_ptr; |
497 | 501 | ||
498 | data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); | 502 | data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); |
499 | if (!data_ptr) | 503 | if (!data_ptr) |
500 | return -1; | 504 | return -ENOMEM; |
501 | 505 | ||
502 | memcpy(data_ptr, orig_node->bcast_own_sum, | 506 | memcpy(data_ptr, orig_node->bcast_own_sum, |
503 | (max_if_num - 1) * sizeof(uint8_t)); | 507 | (max_if_num - 1) * sizeof(uint8_t)); |
@@ -507,7 +511,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) | |||
507 | return 0; | 511 | return 0; |
508 | } | 512 | } |
509 | 513 | ||
510 | int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num) | 514 | int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num) |
511 | { | 515 | { |
512 | struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); | 516 | struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); |
513 | struct hashtable_t *hash = bat_priv->orig_hash; | 517 | struct hashtable_t *hash = bat_priv->orig_hash; |
@@ -518,17 +522,18 @@ int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num) | |||
518 | int ret; | 522 | int ret; |
519 | 523 | ||
520 | /* resize all orig nodes because orig_node->bcast_own(_sum) depend on | 524 | /* resize all orig nodes because orig_node->bcast_own(_sum) depend on |
521 | * if_num */ | 525 | * if_num |
526 | */ | ||
522 | for (i = 0; i < hash->size; i++) { | 527 | for (i = 0; i < hash->size; i++) { |
523 | head = &hash->table[i]; | 528 | head = &hash->table[i]; |
524 | 529 | ||
525 | rcu_read_lock(); | 530 | rcu_read_lock(); |
526 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { | 531 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { |
527 | spin_lock_bh(&orig_node->ogm_cnt_lock); | 532 | spin_lock_bh(&orig_node->ogm_cnt_lock); |
528 | ret = orig_node_add_if(orig_node, max_if_num); | 533 | ret = batadv_orig_node_add_if(orig_node, max_if_num); |
529 | spin_unlock_bh(&orig_node->ogm_cnt_lock); | 534 | spin_unlock_bh(&orig_node->ogm_cnt_lock); |
530 | 535 | ||
531 | if (ret == -1) | 536 | if (ret == -ENOMEM) |
532 | goto err; | 537 | goto err; |
533 | } | 538 | } |
534 | rcu_read_unlock(); | 539 | rcu_read_unlock(); |
@@ -541,8 +546,8 @@ err: | |||
541 | return -ENOMEM; | 546 | return -ENOMEM; |
542 | } | 547 | } |
543 | 548 | ||
544 | static int orig_node_del_if(struct orig_node *orig_node, | 549 | static int batadv_orig_node_del_if(struct orig_node *orig_node, |
545 | int max_if_num, int del_if_num) | 550 | int max_if_num, int del_if_num) |
546 | { | 551 | { |
547 | void *data_ptr = NULL; | 552 | void *data_ptr = NULL; |
548 | int chunk_size; | 553 | int chunk_size; |
@@ -551,10 +556,10 @@ static int orig_node_del_if(struct orig_node *orig_node, | |||
551 | if (max_if_num == 0) | 556 | if (max_if_num == 0) |
552 | goto free_bcast_own; | 557 | goto free_bcast_own; |
553 | 558 | ||
554 | chunk_size = sizeof(unsigned long) * NUM_WORDS; | 559 | chunk_size = sizeof(unsigned long) * BATADV_NUM_WORDS; |
555 | data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); | 560 | data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); |
556 | if (!data_ptr) | 561 | if (!data_ptr) |
557 | return -1; | 562 | return -ENOMEM; |
558 | 563 | ||
559 | /* copy first part */ | 564 | /* copy first part */ |
560 | memcpy(data_ptr, orig_node->bcast_own, del_if_num * chunk_size); | 565 | memcpy(data_ptr, orig_node->bcast_own, del_if_num * chunk_size); |
@@ -573,7 +578,7 @@ free_bcast_own: | |||
573 | 578 | ||
574 | data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); | 579 | data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); |
575 | if (!data_ptr) | 580 | if (!data_ptr) |
576 | return -1; | 581 | return -ENOMEM; |
577 | 582 | ||
578 | memcpy(data_ptr, orig_node->bcast_own_sum, | 583 | memcpy(data_ptr, orig_node->bcast_own_sum, |
579 | del_if_num * sizeof(uint8_t)); | 584 | del_if_num * sizeof(uint8_t)); |
@@ -589,7 +594,7 @@ free_own_sum: | |||
589 | return 0; | 594 | return 0; |
590 | } | 595 | } |
591 | 596 | ||
592 | int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) | 597 | int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) |
593 | { | 598 | { |
594 | struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); | 599 | struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); |
595 | struct hashtable_t *hash = bat_priv->orig_hash; | 600 | struct hashtable_t *hash = bat_priv->orig_hash; |
@@ -601,18 +606,19 @@ int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) | |||
601 | int ret; | 606 | int ret; |
602 | 607 | ||
603 | /* resize all orig nodes because orig_node->bcast_own(_sum) depend on | 608 | /* resize all orig nodes because orig_node->bcast_own(_sum) depend on |
604 | * if_num */ | 609 | * if_num |
610 | */ | ||
605 | for (i = 0; i < hash->size; i++) { | 611 | for (i = 0; i < hash->size; i++) { |
606 | head = &hash->table[i]; | 612 | head = &hash->table[i]; |
607 | 613 | ||
608 | rcu_read_lock(); | 614 | rcu_read_lock(); |
609 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { | 615 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { |
610 | spin_lock_bh(&orig_node->ogm_cnt_lock); | 616 | spin_lock_bh(&orig_node->ogm_cnt_lock); |
611 | ret = orig_node_del_if(orig_node, max_if_num, | 617 | ret = batadv_orig_node_del_if(orig_node, max_if_num, |
612 | hard_iface->if_num); | 618 | hard_iface->if_num); |
613 | spin_unlock_bh(&orig_node->ogm_cnt_lock); | 619 | spin_unlock_bh(&orig_node->ogm_cnt_lock); |
614 | 620 | ||
615 | if (ret == -1) | 621 | if (ret == -ENOMEM) |
616 | goto err; | 622 | goto err; |
617 | } | 623 | } |
618 | rcu_read_unlock(); | 624 | rcu_read_unlock(); |
@@ -620,7 +626,7 @@ int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) | |||
620 | 626 | ||
621 | /* renumber remaining batman interfaces _inside_ of orig_hash_lock */ | 627 | /* renumber remaining batman interfaces _inside_ of orig_hash_lock */ |
622 | rcu_read_lock(); | 628 | rcu_read_lock(); |
623 | list_for_each_entry_rcu(hard_iface_tmp, &hardif_list, list) { | 629 | list_for_each_entry_rcu(hard_iface_tmp, &batadv_hardif_list, list) { |
624 | if (hard_iface_tmp->if_status == IF_NOT_IN_USE) | 630 | if (hard_iface_tmp->if_status == IF_NOT_IN_USE) |
625 | continue; | 631 | continue; |
626 | 632 | ||