diff options
author | Sven Eckelmann <sven@narfation.org> | 2012-05-16 14:23:16 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-06-25 02:21:50 -0400 |
commit | a513088d022c8f59cebe17c567797c220563b517 (patch) | |
tree | db0545ed9e4f59bba9d85feeebc668388b258e44 | |
parent | 0294ca0d92c6539ec6e37edf65a0a5b033dd6d78 (diff) |
batman-adv: Prefix translation-table local static functions with batadv_
All non-static symbols of batman-adv were prefixed with batadv_ to avoid
collisions with other symbols of the kernel. Other symbols of batman-adv
should use the same prefix to keep the naming scheme consistent.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
-rw-r--r-- | net/batman-adv/translation-table.c | 540 |
1 files changed, 282 insertions, 258 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 2eff22f9fdaa..f7a615261f4e 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -29,13 +29,14 @@ | |||
29 | 29 | ||
30 | #include <linux/crc16.h> | 30 | #include <linux/crc16.h> |
31 | 31 | ||
32 | static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, | 32 | static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, |
33 | struct orig_node *orig_node); | 33 | struct orig_node *orig_node); |
34 | static void tt_purge(struct work_struct *work); | 34 | static void batadv_tt_purge(struct work_struct *work); |
35 | static void tt_global_del_orig_list(struct tt_global_entry *tt_global_entry); | 35 | static void |
36 | batadv_tt_global_del_orig_list(struct tt_global_entry *tt_global_entry); | ||
36 | 37 | ||
37 | /* returns 1 if they are the same mac addr */ | 38 | /* returns 1 if they are the same mac addr */ |
38 | static int compare_tt(const struct hlist_node *node, const void *data2) | 39 | static int batadv_compare_tt(const struct hlist_node *node, const void *data2) |
39 | { | 40 | { |
40 | const void *data1 = container_of(node, struct tt_common_entry, | 41 | const void *data1 = container_of(node, struct tt_common_entry, |
41 | hash_entry); | 42 | hash_entry); |
@@ -43,15 +44,15 @@ static int compare_tt(const struct hlist_node *node, const void *data2) | |||
43 | return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); | 44 | return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); |
44 | } | 45 | } |
45 | 46 | ||
46 | static void tt_start_timer(struct bat_priv *bat_priv) | 47 | static void batadv_tt_start_timer(struct bat_priv *bat_priv) |
47 | { | 48 | { |
48 | INIT_DELAYED_WORK(&bat_priv->tt_work, tt_purge); | 49 | INIT_DELAYED_WORK(&bat_priv->tt_work, batadv_tt_purge); |
49 | queue_delayed_work(batadv_event_workqueue, &bat_priv->tt_work, | 50 | queue_delayed_work(batadv_event_workqueue, &bat_priv->tt_work, |
50 | msecs_to_jiffies(5000)); | 51 | msecs_to_jiffies(5000)); |
51 | } | 52 | } |
52 | 53 | ||
53 | static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash, | 54 | static struct tt_common_entry *batadv_tt_hash_find(struct hashtable_t *hash, |
54 | const void *data) | 55 | const void *data) |
55 | { | 56 | { |
56 | struct hlist_head *head; | 57 | struct hlist_head *head; |
57 | struct hlist_node *node; | 58 | struct hlist_node *node; |
@@ -80,26 +81,26 @@ static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash, | |||
80 | return tt_common_entry_tmp; | 81 | return tt_common_entry_tmp; |
81 | } | 82 | } |
82 | 83 | ||
83 | static struct tt_local_entry *tt_local_hash_find(struct bat_priv *bat_priv, | 84 | static struct tt_local_entry * |
84 | const void *data) | 85 | batadv_tt_local_hash_find(struct bat_priv *bat_priv, const void *data) |
85 | { | 86 | { |
86 | struct tt_common_entry *tt_common_entry; | 87 | struct tt_common_entry *tt_common_entry; |
87 | struct tt_local_entry *tt_local_entry = NULL; | 88 | struct tt_local_entry *tt_local_entry = NULL; |
88 | 89 | ||
89 | tt_common_entry = tt_hash_find(bat_priv->tt_local_hash, data); | 90 | tt_common_entry = batadv_tt_hash_find(bat_priv->tt_local_hash, data); |
90 | if (tt_common_entry) | 91 | if (tt_common_entry) |
91 | tt_local_entry = container_of(tt_common_entry, | 92 | tt_local_entry = container_of(tt_common_entry, |
92 | struct tt_local_entry, common); | 93 | struct tt_local_entry, common); |
93 | return tt_local_entry; | 94 | return tt_local_entry; |
94 | } | 95 | } |
95 | 96 | ||
96 | static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv, | 97 | static struct tt_global_entry * |
97 | const void *data) | 98 | batadv_tt_global_hash_find(struct bat_priv *bat_priv, const void *data) |
98 | { | 99 | { |
99 | struct tt_common_entry *tt_common_entry; | 100 | struct tt_common_entry *tt_common_entry; |
100 | struct tt_global_entry *tt_global_entry = NULL; | 101 | struct tt_global_entry *tt_global_entry = NULL; |
101 | 102 | ||
102 | tt_common_entry = tt_hash_find(bat_priv->tt_global_hash, data); | 103 | tt_common_entry = batadv_tt_hash_find(bat_priv->tt_global_hash, data); |
103 | if (tt_common_entry) | 104 | if (tt_common_entry) |
104 | tt_global_entry = container_of(tt_common_entry, | 105 | tt_global_entry = container_of(tt_common_entry, |
105 | struct tt_global_entry, common); | 106 | struct tt_global_entry, common); |
@@ -107,13 +108,14 @@ static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv, | |||
107 | 108 | ||
108 | } | 109 | } |
109 | 110 | ||
110 | static void tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry) | 111 | static void |
112 | batadv_tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry) | ||
111 | { | 113 | { |
112 | if (atomic_dec_and_test(&tt_local_entry->common.refcount)) | 114 | if (atomic_dec_and_test(&tt_local_entry->common.refcount)) |
113 | kfree_rcu(tt_local_entry, common.rcu); | 115 | kfree_rcu(tt_local_entry, common.rcu); |
114 | } | 116 | } |
115 | 117 | ||
116 | static void tt_global_entry_free_rcu(struct rcu_head *rcu) | 118 | static void batadv_tt_global_entry_free_rcu(struct rcu_head *rcu) |
117 | { | 119 | { |
118 | struct tt_common_entry *tt_common_entry; | 120 | struct tt_common_entry *tt_common_entry; |
119 | struct tt_global_entry *tt_global_entry; | 121 | struct tt_global_entry *tt_global_entry; |
@@ -125,16 +127,17 @@ static void tt_global_entry_free_rcu(struct rcu_head *rcu) | |||
125 | kfree(tt_global_entry); | 127 | kfree(tt_global_entry); |
126 | } | 128 | } |
127 | 129 | ||
128 | static void tt_global_entry_free_ref(struct tt_global_entry *tt_global_entry) | 130 | static void |
131 | batadv_tt_global_entry_free_ref(struct tt_global_entry *tt_global_entry) | ||
129 | { | 132 | { |
130 | if (atomic_dec_and_test(&tt_global_entry->common.refcount)) { | 133 | if (atomic_dec_and_test(&tt_global_entry->common.refcount)) { |
131 | tt_global_del_orig_list(tt_global_entry); | 134 | batadv_tt_global_del_orig_list(tt_global_entry); |
132 | call_rcu(&tt_global_entry->common.rcu, | 135 | call_rcu(&tt_global_entry->common.rcu, |
133 | tt_global_entry_free_rcu); | 136 | batadv_tt_global_entry_free_rcu); |
134 | } | 137 | } |
135 | } | 138 | } |
136 | 139 | ||
137 | static void tt_orig_list_entry_free_rcu(struct rcu_head *rcu) | 140 | static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu) |
138 | { | 141 | { |
139 | struct tt_orig_list_entry *orig_entry; | 142 | struct tt_orig_list_entry *orig_entry; |
140 | 143 | ||
@@ -144,13 +147,14 @@ static void tt_orig_list_entry_free_rcu(struct rcu_head *rcu) | |||
144 | kfree(orig_entry); | 147 | kfree(orig_entry); |
145 | } | 148 | } |
146 | 149 | ||
147 | static void tt_orig_list_entry_free_ref(struct tt_orig_list_entry *orig_entry) | 150 | static void |
151 | batadv_tt_orig_list_entry_free_ref(struct tt_orig_list_entry *orig_entry) | ||
148 | { | 152 | { |
149 | call_rcu(&orig_entry->rcu, tt_orig_list_entry_free_rcu); | 153 | call_rcu(&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu); |
150 | } | 154 | } |
151 | 155 | ||
152 | static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr, | 156 | static void batadv_tt_local_event(struct bat_priv *bat_priv, |
153 | uint8_t flags) | 157 | const uint8_t *addr, uint8_t flags) |
154 | { | 158 | { |
155 | struct tt_change_node *tt_change_node; | 159 | struct tt_change_node *tt_change_node; |
156 | 160 | ||
@@ -176,7 +180,7 @@ int batadv_tt_len(int changes_num) | |||
176 | return changes_num * sizeof(struct tt_change); | 180 | return changes_num * sizeof(struct tt_change); |
177 | } | 181 | } |
178 | 182 | ||
179 | static int tt_local_init(struct bat_priv *bat_priv) | 183 | static int batadv_tt_local_init(struct bat_priv *bat_priv) |
180 | { | 184 | { |
181 | if (bat_priv->tt_local_hash) | 185 | if (bat_priv->tt_local_hash) |
182 | return 0; | 186 | return 0; |
@@ -200,7 +204,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, | |||
200 | struct tt_orig_list_entry *orig_entry; | 204 | struct tt_orig_list_entry *orig_entry; |
201 | int hash_added; | 205 | int hash_added; |
202 | 206 | ||
203 | tt_local_entry = tt_local_hash_find(bat_priv, addr); | 207 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); |
204 | 208 | ||
205 | if (tt_local_entry) { | 209 | if (tt_local_entry) { |
206 | tt_local_entry->last_seen = jiffies; | 210 | tt_local_entry->last_seen = jiffies; |
@@ -234,21 +238,21 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, | |||
234 | */ | 238 | */ |
235 | tt_local_entry->common.flags |= TT_CLIENT_NEW; | 239 | tt_local_entry->common.flags |= TT_CLIENT_NEW; |
236 | 240 | ||
237 | hash_added = batadv_hash_add(bat_priv->tt_local_hash, compare_tt, | 241 | hash_added = batadv_hash_add(bat_priv->tt_local_hash, batadv_compare_tt, |
238 | batadv_choose_orig, | 242 | batadv_choose_orig, |
239 | &tt_local_entry->common, | 243 | &tt_local_entry->common, |
240 | &tt_local_entry->common.hash_entry); | 244 | &tt_local_entry->common.hash_entry); |
241 | 245 | ||
242 | if (unlikely(hash_added != 0)) { | 246 | if (unlikely(hash_added != 0)) { |
243 | /* remove the reference for the hash */ | 247 | /* remove the reference for the hash */ |
244 | tt_local_entry_free_ref(tt_local_entry); | 248 | batadv_tt_local_entry_free_ref(tt_local_entry); |
245 | goto out; | 249 | goto out; |
246 | } | 250 | } |
247 | 251 | ||
248 | tt_local_event(bat_priv, addr, tt_local_entry->common.flags); | 252 | batadv_tt_local_event(bat_priv, addr, tt_local_entry->common.flags); |
249 | 253 | ||
250 | /* remove address from global hash if present */ | 254 | /* remove address from global hash if present */ |
251 | tt_global_entry = tt_global_hash_find(bat_priv, addr); | 255 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr); |
252 | 256 | ||
253 | /* Check whether it is a roaming! */ | 257 | /* Check whether it is a roaming! */ |
254 | if (tt_global_entry) { | 258 | if (tt_global_entry) { |
@@ -258,8 +262,9 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, | |||
258 | hlist_for_each_entry_rcu(orig_entry, node, head, list) { | 262 | hlist_for_each_entry_rcu(orig_entry, node, head, list) { |
259 | orig_entry->orig_node->tt_poss_change = true; | 263 | orig_entry->orig_node->tt_poss_change = true; |
260 | 264 | ||
261 | send_roam_adv(bat_priv, tt_global_entry->common.addr, | 265 | batadv_send_roam_adv(bat_priv, |
262 | orig_entry->orig_node); | 266 | tt_global_entry->common.addr, |
267 | orig_entry->orig_node); | ||
263 | } | 268 | } |
264 | rcu_read_unlock(); | 269 | rcu_read_unlock(); |
265 | /* The global entry has to be marked as ROAMING and | 270 | /* The global entry has to be marked as ROAMING and |
@@ -270,14 +275,15 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, | |||
270 | } | 275 | } |
271 | out: | 276 | out: |
272 | if (tt_local_entry) | 277 | if (tt_local_entry) |
273 | tt_local_entry_free_ref(tt_local_entry); | 278 | batadv_tt_local_entry_free_ref(tt_local_entry); |
274 | if (tt_global_entry) | 279 | if (tt_global_entry) |
275 | tt_global_entry_free_ref(tt_global_entry); | 280 | batadv_tt_global_entry_free_ref(tt_global_entry); |
276 | } | 281 | } |
277 | 282 | ||
278 | static void tt_realloc_packet_buff(unsigned char **packet_buff, | 283 | static void batadv_tt_realloc_packet_buff(unsigned char **packet_buff, |
279 | int *packet_buff_len, int min_packet_len, | 284 | int *packet_buff_len, |
280 | int new_packet_len) | 285 | int min_packet_len, |
286 | int new_packet_len) | ||
281 | { | 287 | { |
282 | unsigned char *new_buff; | 288 | unsigned char *new_buff; |
283 | 289 | ||
@@ -292,9 +298,10 @@ static void tt_realloc_packet_buff(unsigned char **packet_buff, | |||
292 | } | 298 | } |
293 | } | 299 | } |
294 | 300 | ||
295 | static void tt_prepare_packet_buff(struct bat_priv *bat_priv, | 301 | static void batadv_tt_prepare_packet_buff(struct bat_priv *bat_priv, |
296 | unsigned char **packet_buff, | 302 | unsigned char **packet_buff, |
297 | int *packet_buff_len, int min_packet_len) | 303 | int *packet_buff_len, |
304 | int min_packet_len) | ||
298 | { | 305 | { |
299 | struct hard_iface *primary_if; | 306 | struct hard_iface *primary_if; |
300 | int req_len; | 307 | int req_len; |
@@ -310,23 +317,24 @@ static void tt_prepare_packet_buff(struct bat_priv *bat_priv, | |||
310 | if ((!primary_if) || (req_len > primary_if->soft_iface->mtu)) | 317 | if ((!primary_if) || (req_len > primary_if->soft_iface->mtu)) |
311 | req_len = min_packet_len; | 318 | req_len = min_packet_len; |
312 | 319 | ||
313 | tt_realloc_packet_buff(packet_buff, packet_buff_len, | 320 | batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len, |
314 | min_packet_len, req_len); | 321 | min_packet_len, req_len); |
315 | 322 | ||
316 | if (primary_if) | 323 | if (primary_if) |
317 | batadv_hardif_free_ref(primary_if); | 324 | batadv_hardif_free_ref(primary_if); |
318 | } | 325 | } |
319 | 326 | ||
320 | static int tt_changes_fill_buff(struct bat_priv *bat_priv, | 327 | static int batadv_tt_changes_fill_buff(struct bat_priv *bat_priv, |
321 | unsigned char **packet_buff, | 328 | unsigned char **packet_buff, |
322 | int *packet_buff_len, int min_packet_len) | 329 | int *packet_buff_len, |
330 | int min_packet_len) | ||
323 | { | 331 | { |
324 | struct tt_change_node *entry, *safe; | 332 | struct tt_change_node *entry, *safe; |
325 | int count = 0, tot_changes = 0, new_len; | 333 | int count = 0, tot_changes = 0, new_len; |
326 | unsigned char *tt_buff; | 334 | unsigned char *tt_buff; |
327 | 335 | ||
328 | tt_prepare_packet_buff(bat_priv, packet_buff, | 336 | batadv_tt_prepare_packet_buff(bat_priv, packet_buff, |
329 | packet_buff_len, min_packet_len); | 337 | packet_buff_len, min_packet_len); |
330 | 338 | ||
331 | new_len = *packet_buff_len - min_packet_len; | 339 | new_len = *packet_buff_len - min_packet_len; |
332 | tt_buff = *packet_buff + min_packet_len; | 340 | tt_buff = *packet_buff + min_packet_len; |
@@ -428,12 +436,12 @@ out: | |||
428 | return ret; | 436 | return ret; |
429 | } | 437 | } |
430 | 438 | ||
431 | static void tt_local_set_pending(struct bat_priv *bat_priv, | 439 | static void batadv_tt_local_set_pending(struct bat_priv *bat_priv, |
432 | struct tt_local_entry *tt_local_entry, | 440 | struct tt_local_entry *tt_local_entry, |
433 | uint16_t flags, const char *message) | 441 | uint16_t flags, const char *message) |
434 | { | 442 | { |
435 | tt_local_event(bat_priv, tt_local_entry->common.addr, | 443 | batadv_tt_local_event(bat_priv, tt_local_entry->common.addr, |
436 | tt_local_entry->common.flags | flags); | 444 | tt_local_entry->common.flags | flags); |
437 | 445 | ||
438 | /* The local client has to be marked as "pending to be removed" but has | 446 | /* The local client has to be marked as "pending to be removed" but has |
439 | * to be kept in the table in order to send it in a full table | 447 | * to be kept in the table in order to send it in a full table |
@@ -451,18 +459,19 @@ void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, | |||
451 | { | 459 | { |
452 | struct tt_local_entry *tt_local_entry = NULL; | 460 | struct tt_local_entry *tt_local_entry = NULL; |
453 | 461 | ||
454 | tt_local_entry = tt_local_hash_find(bat_priv, addr); | 462 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); |
455 | if (!tt_local_entry) | 463 | if (!tt_local_entry) |
456 | goto out; | 464 | goto out; |
457 | 465 | ||
458 | tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL | | 466 | batadv_tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL | |
459 | (roaming ? TT_CLIENT_ROAM : NO_FLAGS), message); | 467 | (roaming ? TT_CLIENT_ROAM : NO_FLAGS), |
468 | message); | ||
460 | out: | 469 | out: |
461 | if (tt_local_entry) | 470 | if (tt_local_entry) |
462 | tt_local_entry_free_ref(tt_local_entry); | 471 | batadv_tt_local_entry_free_ref(tt_local_entry); |
463 | } | 472 | } |
464 | 473 | ||
465 | static void tt_local_purge(struct bat_priv *bat_priv) | 474 | static void batadv_tt_local_purge(struct bat_priv *bat_priv) |
466 | { | 475 | { |
467 | struct hashtable_t *hash = bat_priv->tt_local_hash; | 476 | struct hashtable_t *hash = bat_priv->tt_local_hash; |
468 | struct tt_local_entry *tt_local_entry; | 477 | struct tt_local_entry *tt_local_entry; |
@@ -493,15 +502,15 @@ static void tt_local_purge(struct bat_priv *bat_priv) | |||
493 | TT_LOCAL_TIMEOUT)) | 502 | TT_LOCAL_TIMEOUT)) |
494 | continue; | 503 | continue; |
495 | 504 | ||
496 | tt_local_set_pending(bat_priv, tt_local_entry, | 505 | batadv_tt_local_set_pending(bat_priv, tt_local_entry, |
497 | TT_CLIENT_DEL, "timed out"); | 506 | TT_CLIENT_DEL, "timed out"); |
498 | } | 507 | } |
499 | spin_unlock_bh(list_lock); | 508 | spin_unlock_bh(list_lock); |
500 | } | 509 | } |
501 | 510 | ||
502 | } | 511 | } |
503 | 512 | ||
504 | static void tt_local_table_free(struct bat_priv *bat_priv) | 513 | static void batadv_tt_local_table_free(struct bat_priv *bat_priv) |
505 | { | 514 | { |
506 | struct hashtable_t *hash; | 515 | struct hashtable_t *hash; |
507 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 516 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
@@ -527,7 +536,7 @@ static void tt_local_table_free(struct bat_priv *bat_priv) | |||
527 | tt_local_entry = container_of(tt_common_entry, | 536 | tt_local_entry = container_of(tt_common_entry, |
528 | struct tt_local_entry, | 537 | struct tt_local_entry, |
529 | common); | 538 | common); |
530 | tt_local_entry_free_ref(tt_local_entry); | 539 | batadv_tt_local_entry_free_ref(tt_local_entry); |
531 | } | 540 | } |
532 | spin_unlock_bh(list_lock); | 541 | spin_unlock_bh(list_lock); |
533 | } | 542 | } |
@@ -537,7 +546,7 @@ static void tt_local_table_free(struct bat_priv *bat_priv) | |||
537 | bat_priv->tt_local_hash = NULL; | 546 | bat_priv->tt_local_hash = NULL; |
538 | } | 547 | } |
539 | 548 | ||
540 | static int tt_global_init(struct bat_priv *bat_priv) | 549 | static int batadv_tt_global_init(struct bat_priv *bat_priv) |
541 | { | 550 | { |
542 | if (bat_priv->tt_global_hash) | 551 | if (bat_priv->tt_global_hash) |
543 | return 0; | 552 | return 0; |
@@ -550,7 +559,7 @@ static int tt_global_init(struct bat_priv *bat_priv) | |||
550 | return 0; | 559 | return 0; |
551 | } | 560 | } |
552 | 561 | ||
553 | static void tt_changes_list_free(struct bat_priv *bat_priv) | 562 | static void batadv_tt_changes_list_free(struct bat_priv *bat_priv) |
554 | { | 563 | { |
555 | struct tt_change_node *entry, *safe; | 564 | struct tt_change_node *entry, *safe; |
556 | 565 | ||
@@ -569,8 +578,8 @@ static void tt_changes_list_free(struct bat_priv *bat_priv) | |||
569 | /* find out if an orig_node is already in the list of a tt_global_entry. | 578 | /* find out if an orig_node is already in the list of a tt_global_entry. |
570 | * returns 1 if found, 0 otherwise | 579 | * returns 1 if found, 0 otherwise |
571 | */ | 580 | */ |
572 | static bool tt_global_entry_has_orig(const struct tt_global_entry *entry, | 581 | static bool batadv_tt_global_entry_has_orig(const struct tt_global_entry *entry, |
573 | const struct orig_node *orig_node) | 582 | const struct orig_node *orig_node) |
574 | { | 583 | { |
575 | struct tt_orig_list_entry *tmp_orig_entry; | 584 | struct tt_orig_list_entry *tmp_orig_entry; |
576 | const struct hlist_head *head; | 585 | const struct hlist_head *head; |
@@ -589,9 +598,9 @@ static bool tt_global_entry_has_orig(const struct tt_global_entry *entry, | |||
589 | return found; | 598 | return found; |
590 | } | 599 | } |
591 | 600 | ||
592 | static void tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry, | 601 | static void |
593 | struct orig_node *orig_node, | 602 | batadv_tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry, |
594 | int ttvn) | 603 | struct orig_node *orig_node, int ttvn) |
595 | { | 604 | { |
596 | struct tt_orig_list_entry *orig_entry; | 605 | struct tt_orig_list_entry *orig_entry; |
597 | 606 | ||
@@ -621,7 +630,7 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, | |||
621 | int hash_added; | 630 | int hash_added; |
622 | struct tt_common_entry *common; | 631 | struct tt_common_entry *common; |
623 | 632 | ||
624 | tt_global_entry = tt_global_hash_find(bat_priv, tt_addr); | 633 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr); |
625 | 634 | ||
626 | if (!tt_global_entry) { | 635 | if (!tt_global_entry) { |
627 | tt_global_entry = kzalloc(sizeof(*tt_global_entry), | 636 | tt_global_entry = kzalloc(sizeof(*tt_global_entry), |
@@ -640,16 +649,18 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, | |||
640 | spin_lock_init(&tt_global_entry->list_lock); | 649 | spin_lock_init(&tt_global_entry->list_lock); |
641 | 650 | ||
642 | hash_added = batadv_hash_add(bat_priv->tt_global_hash, | 651 | hash_added = batadv_hash_add(bat_priv->tt_global_hash, |
643 | compare_tt, batadv_choose_orig, | 652 | batadv_compare_tt, |
644 | common, &common->hash_entry); | 653 | batadv_choose_orig, common, |
654 | &common->hash_entry); | ||
645 | 655 | ||
646 | if (unlikely(hash_added != 0)) { | 656 | if (unlikely(hash_added != 0)) { |
647 | /* remove the reference for the hash */ | 657 | /* remove the reference for the hash */ |
648 | tt_global_entry_free_ref(tt_global_entry); | 658 | batadv_tt_global_entry_free_ref(tt_global_entry); |
649 | goto out_remove; | 659 | goto out_remove; |
650 | } | 660 | } |
651 | 661 | ||
652 | tt_global_add_orig_entry(tt_global_entry, orig_node, ttvn); | 662 | batadv_tt_global_add_orig_entry(tt_global_entry, orig_node, |
663 | ttvn); | ||
653 | } else { | 664 | } else { |
654 | /* there is already a global entry, use this one. */ | 665 | /* there is already a global entry, use this one. */ |
655 | 666 | ||
@@ -661,14 +672,15 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, | |||
661 | * new one. | 672 | * new one. |
662 | */ | 673 | */ |
663 | if (tt_global_entry->common.flags & TT_CLIENT_ROAM) { | 674 | if (tt_global_entry->common.flags & TT_CLIENT_ROAM) { |
664 | tt_global_del_orig_list(tt_global_entry); | 675 | batadv_tt_global_del_orig_list(tt_global_entry); |
665 | tt_global_entry->common.flags &= ~TT_CLIENT_ROAM; | 676 | tt_global_entry->common.flags &= ~TT_CLIENT_ROAM; |
666 | tt_global_entry->roam_at = 0; | 677 | tt_global_entry->roam_at = 0; |
667 | } | 678 | } |
668 | 679 | ||
669 | if (!tt_global_entry_has_orig(tt_global_entry, orig_node)) | 680 | if (!batadv_tt_global_entry_has_orig(tt_global_entry, |
670 | tt_global_add_orig_entry(tt_global_entry, orig_node, | 681 | orig_node)) |
671 | ttvn); | 682 | batadv_tt_global_add_orig_entry(tt_global_entry, |
683 | orig_node, ttvn); | ||
672 | } | 684 | } |
673 | 685 | ||
674 | if (wifi) | 686 | if (wifi) |
@@ -685,15 +697,16 @@ out_remove: | |||
685 | ret = 1; | 697 | ret = 1; |
686 | out: | 698 | out: |
687 | if (tt_global_entry) | 699 | if (tt_global_entry) |
688 | tt_global_entry_free_ref(tt_global_entry); | 700 | batadv_tt_global_entry_free_ref(tt_global_entry); |
689 | return ret; | 701 | return ret; |
690 | } | 702 | } |
691 | 703 | ||
692 | /* print all orig nodes who announce the address for this global entry. | 704 | /* print all orig nodes who announce the address for this global entry. |
693 | * it is assumed that the caller holds rcu_read_lock(); | 705 | * it is assumed that the caller holds rcu_read_lock(); |
694 | */ | 706 | */ |
695 | static void tt_global_print_entry(struct tt_global_entry *tt_global_entry, | 707 | static void |
696 | struct seq_file *seq) | 708 | batadv_tt_global_print_entry(struct tt_global_entry *tt_global_entry, |
709 | struct seq_file *seq) | ||
697 | { | 710 | { |
698 | struct hlist_head *head; | 711 | struct hlist_head *head; |
699 | struct hlist_node *node; | 712 | struct hlist_node *node; |
@@ -760,7 +773,7 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) | |||
760 | tt_global_entry = container_of(tt_common_entry, | 773 | tt_global_entry = container_of(tt_common_entry, |
761 | struct tt_global_entry, | 774 | struct tt_global_entry, |
762 | common); | 775 | common); |
763 | tt_global_print_entry(tt_global_entry, seq); | 776 | batadv_tt_global_print_entry(tt_global_entry, seq); |
764 | } | 777 | } |
765 | rcu_read_unlock(); | 778 | rcu_read_unlock(); |
766 | } | 779 | } |
@@ -771,7 +784,8 @@ out: | |||
771 | } | 784 | } |
772 | 785 | ||
773 | /* deletes the orig list of a tt_global_entry */ | 786 | /* deletes the orig list of a tt_global_entry */ |
774 | static void tt_global_del_orig_list(struct tt_global_entry *tt_global_entry) | 787 | static void |
788 | batadv_tt_global_del_orig_list(struct tt_global_entry *tt_global_entry) | ||
775 | { | 789 | { |
776 | struct hlist_head *head; | 790 | struct hlist_head *head; |
777 | struct hlist_node *node, *safe; | 791 | struct hlist_node *node, *safe; |
@@ -781,16 +795,17 @@ static void tt_global_del_orig_list(struct tt_global_entry *tt_global_entry) | |||
781 | head = &tt_global_entry->orig_list; | 795 | head = &tt_global_entry->orig_list; |
782 | hlist_for_each_entry_safe(orig_entry, node, safe, head, list) { | 796 | hlist_for_each_entry_safe(orig_entry, node, safe, head, list) { |
783 | hlist_del_rcu(node); | 797 | hlist_del_rcu(node); |
784 | tt_orig_list_entry_free_ref(orig_entry); | 798 | batadv_tt_orig_list_entry_free_ref(orig_entry); |
785 | } | 799 | } |
786 | spin_unlock_bh(&tt_global_entry->list_lock); | 800 | spin_unlock_bh(&tt_global_entry->list_lock); |
787 | 801 | ||
788 | } | 802 | } |
789 | 803 | ||
790 | static void tt_global_del_orig_entry(struct bat_priv *bat_priv, | 804 | static void |
791 | struct tt_global_entry *tt_global_entry, | 805 | batadv_tt_global_del_orig_entry(struct bat_priv *bat_priv, |
792 | struct orig_node *orig_node, | 806 | struct tt_global_entry *tt_global_entry, |
793 | const char *message) | 807 | struct orig_node *orig_node, |
808 | const char *message) | ||
794 | { | 809 | { |
795 | struct hlist_head *head; | 810 | struct hlist_head *head; |
796 | struct hlist_node *node, *safe; | 811 | struct hlist_node *node, *safe; |
@@ -805,22 +820,22 @@ static void tt_global_del_orig_entry(struct bat_priv *bat_priv, | |||
805 | orig_node->orig, | 820 | orig_node->orig, |
806 | tt_global_entry->common.addr, message); | 821 | tt_global_entry->common.addr, message); |
807 | hlist_del_rcu(node); | 822 | hlist_del_rcu(node); |
808 | tt_orig_list_entry_free_ref(orig_entry); | 823 | batadv_tt_orig_list_entry_free_ref(orig_entry); |
809 | } | 824 | } |
810 | } | 825 | } |
811 | spin_unlock_bh(&tt_global_entry->list_lock); | 826 | spin_unlock_bh(&tt_global_entry->list_lock); |
812 | } | 827 | } |
813 | 828 | ||
814 | static void tt_global_del_struct(struct bat_priv *bat_priv, | 829 | static void batadv_tt_global_del_struct(struct bat_priv *bat_priv, |
815 | struct tt_global_entry *tt_global_entry, | 830 | struct tt_global_entry *tt_global_entry, |
816 | const char *message) | 831 | const char *message) |
817 | { | 832 | { |
818 | batadv_dbg(DBG_TT, bat_priv, "Deleting global tt entry %pM: %s\n", | 833 | batadv_dbg(DBG_TT, bat_priv, "Deleting global tt entry %pM: %s\n", |
819 | tt_global_entry->common.addr, message); | 834 | tt_global_entry->common.addr, message); |
820 | 835 | ||
821 | batadv_hash_remove(bat_priv->tt_global_hash, compare_tt, | 836 | batadv_hash_remove(bat_priv->tt_global_hash, batadv_compare_tt, |
822 | batadv_choose_orig, tt_global_entry->common.addr); | 837 | batadv_choose_orig, tt_global_entry->common.addr); |
823 | tt_global_entry_free_ref(tt_global_entry); | 838 | batadv_tt_global_entry_free_ref(tt_global_entry); |
824 | 839 | ||
825 | } | 840 | } |
826 | 841 | ||
@@ -828,10 +843,10 @@ static void tt_global_del_struct(struct bat_priv *bat_priv, | |||
828 | * within tt_global entry. If yes, we set the TT_CLIENT_ROAM flag and the timer, | 843 | * within tt_global entry. If yes, we set the TT_CLIENT_ROAM flag and the timer, |
829 | * otherwise we simply remove the originator scheduled for deletion. | 844 | * otherwise we simply remove the originator scheduled for deletion. |
830 | */ | 845 | */ |
831 | static void tt_global_del_roaming(struct bat_priv *bat_priv, | 846 | static void |
832 | struct tt_global_entry *tt_global_entry, | 847 | batadv_tt_global_del_roaming(struct bat_priv *bat_priv, |
833 | struct orig_node *orig_node, | 848 | struct tt_global_entry *tt_global_entry, |
834 | const char *message) | 849 | struct orig_node *orig_node, const char *message) |
835 | { | 850 | { |
836 | bool last_entry = true; | 851 | bool last_entry = true; |
837 | struct hlist_head *head; | 852 | struct hlist_head *head; |
@@ -860,31 +875,31 @@ static void tt_global_del_roaming(struct bat_priv *bat_priv, | |||
860 | /* there is another entry, we can simply delete this | 875 | /* there is another entry, we can simply delete this |
861 | * one and can still use the other one. | 876 | * one and can still use the other one. |
862 | */ | 877 | */ |
863 | tt_global_del_orig_entry(bat_priv, tt_global_entry, | 878 | batadv_tt_global_del_orig_entry(bat_priv, tt_global_entry, |
864 | orig_node, message); | 879 | orig_node, message); |
865 | } | 880 | } |
866 | 881 | ||
867 | 882 | ||
868 | 883 | ||
869 | static void tt_global_del(struct bat_priv *bat_priv, | 884 | static void batadv_tt_global_del(struct bat_priv *bat_priv, |
870 | struct orig_node *orig_node, | 885 | struct orig_node *orig_node, |
871 | const unsigned char *addr, | 886 | const unsigned char *addr, |
872 | const char *message, bool roaming) | 887 | const char *message, bool roaming) |
873 | { | 888 | { |
874 | struct tt_global_entry *tt_global_entry = NULL; | 889 | struct tt_global_entry *tt_global_entry = NULL; |
875 | struct tt_local_entry *tt_local_entry = NULL; | 890 | struct tt_local_entry *local_entry = NULL; |
876 | 891 | ||
877 | tt_global_entry = tt_global_hash_find(bat_priv, addr); | 892 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr); |
878 | if (!tt_global_entry) | 893 | if (!tt_global_entry) |
879 | goto out; | 894 | goto out; |
880 | 895 | ||
881 | if (!roaming) { | 896 | if (!roaming) { |
882 | tt_global_del_orig_entry(bat_priv, tt_global_entry, orig_node, | 897 | batadv_tt_global_del_orig_entry(bat_priv, tt_global_entry, |
883 | message); | 898 | orig_node, message); |
884 | 899 | ||
885 | if (hlist_empty(&tt_global_entry->orig_list)) | 900 | if (hlist_empty(&tt_global_entry->orig_list)) |
886 | tt_global_del_struct(bat_priv, tt_global_entry, | 901 | batadv_tt_global_del_struct(bat_priv, tt_global_entry, |
887 | message); | 902 | message); |
888 | 903 | ||
889 | goto out; | 904 | goto out; |
890 | } | 905 | } |
@@ -902,29 +917,29 @@ static void tt_global_del(struct bat_priv *bat_priv, | |||
902 | * 2) the client roamed to us => we can directly delete | 917 | * 2) the client roamed to us => we can directly delete |
903 | * the global entry, since it is useless now. | 918 | * the global entry, since it is useless now. |
904 | */ | 919 | */ |
905 | tt_local_entry = tt_local_hash_find(bat_priv, | 920 | local_entry = batadv_tt_local_hash_find(bat_priv, |
906 | tt_global_entry->common.addr); | 921 | tt_global_entry->common.addr); |
907 | if (tt_local_entry) { | 922 | if (local_entry) { |
908 | /* local entry exists, case 2: client roamed to us. */ | 923 | /* local entry exists, case 2: client roamed to us. */ |
909 | tt_global_del_orig_list(tt_global_entry); | 924 | batadv_tt_global_del_orig_list(tt_global_entry); |
910 | tt_global_del_struct(bat_priv, tt_global_entry, message); | 925 | batadv_tt_global_del_struct(bat_priv, tt_global_entry, message); |
911 | } else | 926 | } else |
912 | /* no local entry exists, case 1: check for roaming */ | 927 | /* no local entry exists, case 1: check for roaming */ |
913 | tt_global_del_roaming(bat_priv, tt_global_entry, orig_node, | 928 | batadv_tt_global_del_roaming(bat_priv, tt_global_entry, |
914 | message); | 929 | orig_node, message); |
915 | 930 | ||
916 | 931 | ||
917 | out: | 932 | out: |
918 | if (tt_global_entry) | 933 | if (tt_global_entry) |
919 | tt_global_entry_free_ref(tt_global_entry); | 934 | batadv_tt_global_entry_free_ref(tt_global_entry); |
920 | if (tt_local_entry) | 935 | if (local_entry) |
921 | tt_local_entry_free_ref(tt_local_entry); | 936 | batadv_tt_local_entry_free_ref(local_entry); |
922 | } | 937 | } |
923 | 938 | ||
924 | void batadv_tt_global_del_orig(struct bat_priv *bat_priv, | 939 | void batadv_tt_global_del_orig(struct bat_priv *bat_priv, |
925 | struct orig_node *orig_node, const char *message) | 940 | struct orig_node *orig_node, const char *message) |
926 | { | 941 | { |
927 | struct tt_global_entry *tt_global_entry; | 942 | struct tt_global_entry *global_entry; |
928 | struct tt_common_entry *tt_common_entry; | 943 | struct tt_common_entry *tt_common_entry; |
929 | uint32_t i; | 944 | uint32_t i; |
930 | struct hashtable_t *hash = bat_priv->tt_global_hash; | 945 | struct hashtable_t *hash = bat_priv->tt_global_hash; |
@@ -942,20 +957,19 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv, | |||
942 | spin_lock_bh(list_lock); | 957 | spin_lock_bh(list_lock); |
943 | hlist_for_each_entry_safe(tt_common_entry, node, safe, | 958 | hlist_for_each_entry_safe(tt_common_entry, node, safe, |
944 | head, hash_entry) { | 959 | head, hash_entry) { |
945 | tt_global_entry = container_of(tt_common_entry, | 960 | global_entry = container_of(tt_common_entry, |
946 | struct tt_global_entry, | 961 | struct tt_global_entry, |
947 | common); | 962 | common); |
948 | 963 | ||
949 | tt_global_del_orig_entry(bat_priv, tt_global_entry, | 964 | batadv_tt_global_del_orig_entry(bat_priv, global_entry, |
950 | orig_node, message); | 965 | orig_node, message); |
951 | 966 | ||
952 | if (hlist_empty(&tt_global_entry->orig_list)) { | 967 | if (hlist_empty(&global_entry->orig_list)) { |
953 | batadv_dbg(DBG_TT, bat_priv, | 968 | batadv_dbg(DBG_TT, bat_priv, |
954 | "Deleting global tt entry %pM: %s\n", | 969 | "Deleting global tt entry %pM: %s\n", |
955 | tt_global_entry->common.addr, | 970 | global_entry->common.addr, message); |
956 | message); | ||
957 | hlist_del_rcu(node); | 971 | hlist_del_rcu(node); |
958 | tt_global_entry_free_ref(tt_global_entry); | 972 | batadv_tt_global_entry_free_ref(global_entry); |
959 | } | 973 | } |
960 | } | 974 | } |
961 | spin_unlock_bh(list_lock); | 975 | spin_unlock_bh(list_lock); |
@@ -964,7 +978,7 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv, | |||
964 | orig_node->tt_initialised = false; | 978 | orig_node->tt_initialised = false; |
965 | } | 979 | } |
966 | 980 | ||
967 | static void tt_global_roam_purge(struct bat_priv *bat_priv) | 981 | static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv) |
968 | { | 982 | { |
969 | struct hashtable_t *hash = bat_priv->tt_global_hash; | 983 | struct hashtable_t *hash = bat_priv->tt_global_hash; |
970 | struct tt_common_entry *tt_common_entry; | 984 | struct tt_common_entry *tt_common_entry; |
@@ -995,14 +1009,14 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv) | |||
995 | tt_global_entry->common.addr); | 1009 | tt_global_entry->common.addr); |
996 | 1010 | ||
997 | hlist_del_rcu(node); | 1011 | hlist_del_rcu(node); |
998 | tt_global_entry_free_ref(tt_global_entry); | 1012 | batadv_tt_global_entry_free_ref(tt_global_entry); |
999 | } | 1013 | } |
1000 | spin_unlock_bh(list_lock); | 1014 | spin_unlock_bh(list_lock); |
1001 | } | 1015 | } |
1002 | 1016 | ||
1003 | } | 1017 | } |
1004 | 1018 | ||
1005 | static void tt_global_table_free(struct bat_priv *bat_priv) | 1019 | static void batadv_tt_global_table_free(struct bat_priv *bat_priv) |
1006 | { | 1020 | { |
1007 | struct hashtable_t *hash; | 1021 | struct hashtable_t *hash; |
1008 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 1022 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
@@ -1028,7 +1042,7 @@ static void tt_global_table_free(struct bat_priv *bat_priv) | |||
1028 | tt_global_entry = container_of(tt_common_entry, | 1042 | tt_global_entry = container_of(tt_common_entry, |
1029 | struct tt_global_entry, | 1043 | struct tt_global_entry, |
1030 | common); | 1044 | common); |
1031 | tt_global_entry_free_ref(tt_global_entry); | 1045 | batadv_tt_global_entry_free_ref(tt_global_entry); |
1032 | } | 1046 | } |
1033 | spin_unlock_bh(list_lock); | 1047 | spin_unlock_bh(list_lock); |
1034 | } | 1048 | } |
@@ -1038,8 +1052,8 @@ static void tt_global_table_free(struct bat_priv *bat_priv) | |||
1038 | bat_priv->tt_global_hash = NULL; | 1052 | bat_priv->tt_global_hash = NULL; |
1039 | } | 1053 | } |
1040 | 1054 | ||
1041 | static bool _is_ap_isolated(struct tt_local_entry *tt_local_entry, | 1055 | static bool _batadv_is_ap_isolated(struct tt_local_entry *tt_local_entry, |
1042 | struct tt_global_entry *tt_global_entry) | 1056 | struct tt_global_entry *tt_global_entry) |
1043 | { | 1057 | { |
1044 | bool ret = false; | 1058 | bool ret = false; |
1045 | 1059 | ||
@@ -1064,19 +1078,20 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv, | |||
1064 | int best_tq; | 1078 | int best_tq; |
1065 | 1079 | ||
1066 | if (src && atomic_read(&bat_priv->ap_isolation)) { | 1080 | if (src && atomic_read(&bat_priv->ap_isolation)) { |
1067 | tt_local_entry = tt_local_hash_find(bat_priv, src); | 1081 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, src); |
1068 | if (!tt_local_entry) | 1082 | if (!tt_local_entry) |
1069 | goto out; | 1083 | goto out; |
1070 | } | 1084 | } |
1071 | 1085 | ||
1072 | tt_global_entry = tt_global_hash_find(bat_priv, addr); | 1086 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr); |
1073 | if (!tt_global_entry) | 1087 | if (!tt_global_entry) |
1074 | goto out; | 1088 | goto out; |
1075 | 1089 | ||
1076 | /* check whether the clients should not communicate due to AP | 1090 | /* check whether the clients should not communicate due to AP |
1077 | * isolation | 1091 | * isolation |
1078 | */ | 1092 | */ |
1079 | if (tt_local_entry && _is_ap_isolated(tt_local_entry, tt_global_entry)) | 1093 | if (tt_local_entry && |
1094 | _batadv_is_ap_isolated(tt_local_entry, tt_global_entry)) | ||
1080 | goto out; | 1095 | goto out; |
1081 | 1096 | ||
1082 | best_tq = 0; | 1097 | best_tq = 0; |
@@ -1100,16 +1115,16 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv, | |||
1100 | rcu_read_unlock(); | 1115 | rcu_read_unlock(); |
1101 | out: | 1116 | out: |
1102 | if (tt_global_entry) | 1117 | if (tt_global_entry) |
1103 | tt_global_entry_free_ref(tt_global_entry); | 1118 | batadv_tt_global_entry_free_ref(tt_global_entry); |
1104 | if (tt_local_entry) | 1119 | if (tt_local_entry) |
1105 | tt_local_entry_free_ref(tt_local_entry); | 1120 | batadv_tt_local_entry_free_ref(tt_local_entry); |
1106 | 1121 | ||
1107 | return orig_node; | 1122 | return orig_node; |
1108 | } | 1123 | } |
1109 | 1124 | ||
1110 | /* Calculates the checksum of the local table of a given orig_node */ | 1125 | /* Calculates the checksum of the local table of a given orig_node */ |
1111 | static uint16_t tt_global_crc(struct bat_priv *bat_priv, | 1126 | static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv, |
1112 | struct orig_node *orig_node) | 1127 | struct orig_node *orig_node) |
1113 | { | 1128 | { |
1114 | uint16_t total = 0, total_one; | 1129 | uint16_t total = 0, total_one; |
1115 | struct hashtable_t *hash = bat_priv->tt_global_hash; | 1130 | struct hashtable_t *hash = bat_priv->tt_global_hash; |
@@ -1140,8 +1155,8 @@ static uint16_t tt_global_crc(struct bat_priv *bat_priv, | |||
1140 | /* find out if this global entry is announced by this | 1155 | /* find out if this global entry is announced by this |
1141 | * originator | 1156 | * originator |
1142 | */ | 1157 | */ |
1143 | if (!tt_global_entry_has_orig(tt_global_entry, | 1158 | if (!batadv_tt_global_entry_has_orig(tt_global_entry, |
1144 | orig_node)) | 1159 | orig_node)) |
1145 | continue; | 1160 | continue; |
1146 | 1161 | ||
1147 | total_one = 0; | 1162 | total_one = 0; |
@@ -1190,7 +1205,7 @@ static uint16_t batadv_tt_local_crc(struct bat_priv *bat_priv) | |||
1190 | return total; | 1205 | return total; |
1191 | } | 1206 | } |
1192 | 1207 | ||
1193 | static void tt_req_list_free(struct bat_priv *bat_priv) | 1208 | static void batadv_tt_req_list_free(struct bat_priv *bat_priv) |
1194 | { | 1209 | { |
1195 | struct tt_req_node *node, *safe; | 1210 | struct tt_req_node *node, *safe; |
1196 | 1211 | ||
@@ -1204,10 +1219,10 @@ static void tt_req_list_free(struct bat_priv *bat_priv) | |||
1204 | spin_unlock_bh(&bat_priv->tt_req_list_lock); | 1219 | spin_unlock_bh(&bat_priv->tt_req_list_lock); |
1205 | } | 1220 | } |
1206 | 1221 | ||
1207 | static void tt_save_orig_buffer(struct bat_priv *bat_priv, | 1222 | static void batadv_tt_save_orig_buffer(struct bat_priv *bat_priv, |
1208 | struct orig_node *orig_node, | 1223 | struct orig_node *orig_node, |
1209 | const unsigned char *tt_buff, | 1224 | const unsigned char *tt_buff, |
1210 | uint8_t tt_num_changes) | 1225 | uint8_t tt_num_changes) |
1211 | { | 1226 | { |
1212 | uint16_t tt_buff_len = batadv_tt_len(tt_num_changes); | 1227 | uint16_t tt_buff_len = batadv_tt_len(tt_num_changes); |
1213 | 1228 | ||
@@ -1227,7 +1242,7 @@ static void tt_save_orig_buffer(struct bat_priv *bat_priv, | |||
1227 | spin_unlock_bh(&orig_node->tt_buff_lock); | 1242 | spin_unlock_bh(&orig_node->tt_buff_lock); |
1228 | } | 1243 | } |
1229 | 1244 | ||
1230 | static void tt_req_purge(struct bat_priv *bat_priv) | 1245 | static void batadv_tt_req_purge(struct bat_priv *bat_priv) |
1231 | { | 1246 | { |
1232 | struct tt_req_node *node, *safe; | 1247 | struct tt_req_node *node, *safe; |
1233 | 1248 | ||
@@ -1244,8 +1259,8 @@ static void tt_req_purge(struct bat_priv *bat_priv) | |||
1244 | /* returns the pointer to the new tt_req_node struct if no request | 1259 | /* returns the pointer to the new tt_req_node struct if no request |
1245 | * has already been issued for this orig_node, NULL otherwise | 1260 | * has already been issued for this orig_node, NULL otherwise |
1246 | */ | 1261 | */ |
1247 | static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv, | 1262 | static struct tt_req_node *batadv_new_tt_req_node(struct bat_priv *bat_priv, |
1248 | struct orig_node *orig_node) | 1263 | struct orig_node *orig_node) |
1249 | { | 1264 | { |
1250 | struct tt_req_node *tt_req_node_tmp, *tt_req_node = NULL; | 1265 | struct tt_req_node *tt_req_node_tmp, *tt_req_node = NULL; |
1251 | 1266 | ||
@@ -1271,7 +1286,8 @@ unlock: | |||
1271 | } | 1286 | } |
1272 | 1287 | ||
1273 | /* data_ptr is useless here, but has to be kept to respect the prototype */ | 1288 | /* data_ptr is useless here, but has to be kept to respect the prototype */ |
1274 | static int tt_local_valid_entry(const void *entry_ptr, const void *data_ptr) | 1289 | static int batadv_tt_local_valid_entry(const void *entry_ptr, |
1290 | const void *data_ptr) | ||
1275 | { | 1291 | { |
1276 | const struct tt_common_entry *tt_common_entry = entry_ptr; | 1292 | const struct tt_common_entry *tt_common_entry = entry_ptr; |
1277 | 1293 | ||
@@ -1280,7 +1296,8 @@ static int tt_local_valid_entry(const void *entry_ptr, const void *data_ptr) | |||
1280 | return 1; | 1296 | return 1; |
1281 | } | 1297 | } |
1282 | 1298 | ||
1283 | static int tt_global_valid_entry(const void *entry_ptr, const void *data_ptr) | 1299 | static int batadv_tt_global_valid(const void *entry_ptr, |
1300 | const void *data_ptr) | ||
1284 | { | 1301 | { |
1285 | const struct tt_common_entry *tt_common_entry = entry_ptr; | 1302 | const struct tt_common_entry *tt_common_entry = entry_ptr; |
1286 | const struct tt_global_entry *tt_global_entry; | 1303 | const struct tt_global_entry *tt_global_entry; |
@@ -1292,15 +1309,15 @@ static int tt_global_valid_entry(const void *entry_ptr, const void *data_ptr) | |||
1292 | tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, | 1309 | tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, |
1293 | common); | 1310 | common); |
1294 | 1311 | ||
1295 | return tt_global_entry_has_orig(tt_global_entry, orig_node); | 1312 | return batadv_tt_global_entry_has_orig(tt_global_entry, orig_node); |
1296 | } | 1313 | } |
1297 | 1314 | ||
1298 | static struct sk_buff *tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, | 1315 | static struct sk_buff * |
1299 | struct hashtable_t *hash, | 1316 | batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, |
1300 | struct hard_iface *primary_if, | 1317 | struct hashtable_t *hash, |
1301 | int (*valid_cb)(const void *, | 1318 | struct hard_iface *primary_if, |
1302 | const void *), | 1319 | int (*valid_cb)(const void *, const void *), |
1303 | void *cb_data) | 1320 | void *cb_data) |
1304 | { | 1321 | { |
1305 | struct tt_common_entry *tt_common_entry; | 1322 | struct tt_common_entry *tt_common_entry; |
1306 | struct tt_query_packet *tt_response; | 1323 | struct tt_query_packet *tt_response; |
@@ -1361,9 +1378,10 @@ out: | |||
1361 | return skb; | 1378 | return skb; |
1362 | } | 1379 | } |
1363 | 1380 | ||
1364 | static int send_tt_request(struct bat_priv *bat_priv, | 1381 | static int batadv_send_tt_request(struct bat_priv *bat_priv, |
1365 | struct orig_node *dst_orig_node, | 1382 | struct orig_node *dst_orig_node, |
1366 | uint8_t ttvn, uint16_t tt_crc, bool full_table) | 1383 | uint8_t ttvn, uint16_t tt_crc, |
1384 | bool full_table) | ||
1367 | { | 1385 | { |
1368 | struct sk_buff *skb = NULL; | 1386 | struct sk_buff *skb = NULL; |
1369 | struct tt_query_packet *tt_request; | 1387 | struct tt_query_packet *tt_request; |
@@ -1379,7 +1397,7 @@ static int send_tt_request(struct bat_priv *bat_priv, | |||
1379 | /* The new tt_req will be issued only if I'm not waiting for a | 1397 | /* The new tt_req will be issued only if I'm not waiting for a |
1380 | * reply from the same orig_node yet | 1398 | * reply from the same orig_node yet |
1381 | */ | 1399 | */ |
1382 | tt_req_node = new_tt_req_node(bat_priv, dst_orig_node); | 1400 | tt_req_node = batadv_new_tt_req_node(bat_priv, dst_orig_node); |
1383 | if (!tt_req_node) | 1401 | if (!tt_req_node) |
1384 | goto out; | 1402 | goto out; |
1385 | 1403 | ||
@@ -1434,8 +1452,8 @@ out: | |||
1434 | return ret; | 1452 | return ret; |
1435 | } | 1453 | } |
1436 | 1454 | ||
1437 | static bool send_other_tt_response(struct bat_priv *bat_priv, | 1455 | static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, |
1438 | struct tt_query_packet *tt_request) | 1456 | struct tt_query_packet *tt_request) |
1439 | { | 1457 | { |
1440 | struct orig_node *req_dst_orig_node = NULL, *res_dst_orig_node = NULL; | 1458 | struct orig_node *req_dst_orig_node = NULL, *res_dst_orig_node = NULL; |
1441 | struct neigh_node *neigh_node = NULL; | 1459 | struct neigh_node *neigh_node = NULL; |
@@ -1515,10 +1533,11 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, | |||
1515 | sizeof(struct tt_change); | 1533 | sizeof(struct tt_change); |
1516 | ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn); | 1534 | ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn); |
1517 | 1535 | ||
1518 | skb = tt_response_fill_table(tt_len, ttvn, | 1536 | skb = batadv_tt_response_fill_table(tt_len, ttvn, |
1519 | bat_priv->tt_global_hash, | 1537 | bat_priv->tt_global_hash, |
1520 | primary_if, tt_global_valid_entry, | 1538 | primary_if, |
1521 | req_dst_orig_node); | 1539 | batadv_tt_global_valid, |
1540 | req_dst_orig_node); | ||
1522 | if (!skb) | 1541 | if (!skb) |
1523 | goto out; | 1542 | goto out; |
1524 | 1543 | ||
@@ -1563,8 +1582,8 @@ out: | |||
1563 | return ret; | 1582 | return ret; |
1564 | 1583 | ||
1565 | } | 1584 | } |
1566 | static bool send_my_tt_response(struct bat_priv *bat_priv, | 1585 | static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, |
1567 | struct tt_query_packet *tt_request) | 1586 | struct tt_query_packet *tt_request) |
1568 | { | 1587 | { |
1569 | struct orig_node *orig_node = NULL; | 1588 | struct orig_node *orig_node = NULL; |
1570 | struct neigh_node *neigh_node = NULL; | 1589 | struct neigh_node *neigh_node = NULL; |
@@ -1635,10 +1654,11 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, | |||
1635 | sizeof(struct tt_change); | 1654 | sizeof(struct tt_change); |
1636 | ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); | 1655 | ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); |
1637 | 1656 | ||
1638 | skb = tt_response_fill_table(tt_len, ttvn, | 1657 | skb = batadv_tt_response_fill_table(tt_len, ttvn, |
1639 | bat_priv->tt_local_hash, | 1658 | bat_priv->tt_local_hash, |
1640 | primary_if, tt_local_valid_entry, | 1659 | primary_if, |
1641 | NULL); | 1660 | batadv_tt_local_valid_entry, |
1661 | NULL); | ||
1642 | if (!skb) | 1662 | if (!skb) |
1643 | goto out; | 1663 | goto out; |
1644 | 1664 | ||
@@ -1689,26 +1709,28 @@ bool batadv_send_tt_response(struct bat_priv *bat_priv, | |||
1689 | if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_request->src)) | 1709 | if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_request->src)) |
1690 | return true; | 1710 | return true; |
1691 | 1711 | ||
1692 | return send_my_tt_response(bat_priv, tt_request); | 1712 | return batadv_send_my_tt_response(bat_priv, tt_request); |
1693 | } else { | 1713 | } else { |
1694 | return send_other_tt_response(bat_priv, tt_request); | 1714 | return batadv_send_other_tt_response(bat_priv, tt_request); |
1695 | } | 1715 | } |
1696 | } | 1716 | } |
1697 | 1717 | ||
1698 | static void _tt_update_changes(struct bat_priv *bat_priv, | 1718 | static void _batadv_tt_update_changes(struct bat_priv *bat_priv, |
1699 | struct orig_node *orig_node, | 1719 | struct orig_node *orig_node, |
1700 | struct tt_change *tt_change, | 1720 | struct tt_change *tt_change, |
1701 | uint16_t tt_num_changes, uint8_t ttvn) | 1721 | uint16_t tt_num_changes, uint8_t ttvn) |
1702 | { | 1722 | { |
1703 | int i; | 1723 | int i; |
1704 | int is_wifi; | 1724 | int is_wifi; |
1725 | int roams; | ||
1705 | 1726 | ||
1706 | for (i = 0; i < tt_num_changes; i++) { | 1727 | for (i = 0; i < tt_num_changes; i++) { |
1707 | if ((tt_change + i)->flags & TT_CLIENT_DEL) { | 1728 | if ((tt_change + i)->flags & TT_CLIENT_DEL) { |
1708 | tt_global_del(bat_priv, orig_node, | 1729 | roams = (tt_change + i)->flags & TT_CLIENT_ROAM; |
1709 | (tt_change + i)->addr, | 1730 | batadv_tt_global_del(bat_priv, orig_node, |
1710 | "tt removed by changes", | 1731 | (tt_change + i)->addr, |
1711 | (tt_change + i)->flags & TT_CLIENT_ROAM); | 1732 | "tt removed by changes", |
1733 | roams); | ||
1712 | } else { | 1734 | } else { |
1713 | is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI; | 1735 | is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI; |
1714 | if (!batadv_tt_global_add(bat_priv, orig_node, | 1736 | if (!batadv_tt_global_add(bat_priv, orig_node, |
@@ -1726,8 +1748,8 @@ static void _tt_update_changes(struct bat_priv *bat_priv, | |||
1726 | orig_node->tt_initialised = true; | 1748 | orig_node->tt_initialised = true; |
1727 | } | 1749 | } |
1728 | 1750 | ||
1729 | static void tt_fill_gtable(struct bat_priv *bat_priv, | 1751 | static void batadv_tt_fill_gtable(struct bat_priv *bat_priv, |
1730 | struct tt_query_packet *tt_response) | 1752 | struct tt_query_packet *tt_response) |
1731 | { | 1753 | { |
1732 | struct orig_node *orig_node = NULL; | 1754 | struct orig_node *orig_node = NULL; |
1733 | 1755 | ||
@@ -1738,9 +1760,10 @@ static void tt_fill_gtable(struct bat_priv *bat_priv, | |||
1738 | /* Purge the old table first.. */ | 1760 | /* Purge the old table first.. */ |
1739 | batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table"); | 1761 | batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table"); |
1740 | 1762 | ||
1741 | _tt_update_changes(bat_priv, orig_node, | 1763 | _batadv_tt_update_changes(bat_priv, orig_node, |
1742 | (struct tt_change *)(tt_response + 1), | 1764 | (struct tt_change *)(tt_response + 1), |
1743 | ntohs(tt_response->tt_data), tt_response->ttvn); | 1765 | ntohs(tt_response->tt_data), |
1766 | tt_response->ttvn); | ||
1744 | 1767 | ||
1745 | spin_lock_bh(&orig_node->tt_buff_lock); | 1768 | spin_lock_bh(&orig_node->tt_buff_lock); |
1746 | kfree(orig_node->tt_buff); | 1769 | kfree(orig_node->tt_buff); |
@@ -1755,16 +1778,16 @@ out: | |||
1755 | batadv_orig_node_free_ref(orig_node); | 1778 | batadv_orig_node_free_ref(orig_node); |
1756 | } | 1779 | } |
1757 | 1780 | ||
1758 | static void tt_update_changes(struct bat_priv *bat_priv, | 1781 | static void batadv_tt_update_changes(struct bat_priv *bat_priv, |
1759 | struct orig_node *orig_node, | 1782 | struct orig_node *orig_node, |
1760 | uint16_t tt_num_changes, uint8_t ttvn, | 1783 | uint16_t tt_num_changes, uint8_t ttvn, |
1761 | struct tt_change *tt_change) | 1784 | struct tt_change *tt_change) |
1762 | { | 1785 | { |
1763 | _tt_update_changes(bat_priv, orig_node, tt_change, tt_num_changes, | 1786 | _batadv_tt_update_changes(bat_priv, orig_node, tt_change, |
1764 | ttvn); | 1787 | tt_num_changes, ttvn); |
1765 | 1788 | ||
1766 | tt_save_orig_buffer(bat_priv, orig_node, (unsigned char *)tt_change, | 1789 | batadv_tt_save_orig_buffer(bat_priv, orig_node, |
1767 | tt_num_changes); | 1790 | (unsigned char *)tt_change, tt_num_changes); |
1768 | atomic_set(&orig_node->last_ttvn, ttvn); | 1791 | atomic_set(&orig_node->last_ttvn, ttvn); |
1769 | } | 1792 | } |
1770 | 1793 | ||
@@ -1773,7 +1796,7 @@ bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) | |||
1773 | struct tt_local_entry *tt_local_entry = NULL; | 1796 | struct tt_local_entry *tt_local_entry = NULL; |
1774 | bool ret = false; | 1797 | bool ret = false; |
1775 | 1798 | ||
1776 | tt_local_entry = tt_local_hash_find(bat_priv, addr); | 1799 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); |
1777 | if (!tt_local_entry) | 1800 | if (!tt_local_entry) |
1778 | goto out; | 1801 | goto out; |
1779 | /* Check if the client has been logically deleted (but is kept for | 1802 | /* Check if the client has been logically deleted (but is kept for |
@@ -1784,7 +1807,7 @@ bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) | |||
1784 | ret = true; | 1807 | ret = true; |
1785 | out: | 1808 | out: |
1786 | if (tt_local_entry) | 1809 | if (tt_local_entry) |
1787 | tt_local_entry_free_ref(tt_local_entry); | 1810 | batadv_tt_local_entry_free_ref(tt_local_entry); |
1788 | return ret; | 1811 | return ret; |
1789 | } | 1812 | } |
1790 | 1813 | ||
@@ -1809,12 +1832,12 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, | |||
1809 | goto out; | 1832 | goto out; |
1810 | 1833 | ||
1811 | if (tt_response->flags & TT_FULL_TABLE) | 1834 | if (tt_response->flags & TT_FULL_TABLE) |
1812 | tt_fill_gtable(bat_priv, tt_response); | 1835 | batadv_tt_fill_gtable(bat_priv, tt_response); |
1813 | else | 1836 | else |
1814 | tt_update_changes(bat_priv, orig_node, | 1837 | batadv_tt_update_changes(bat_priv, orig_node, |
1815 | ntohs(tt_response->tt_data), | 1838 | ntohs(tt_response->tt_data), |
1816 | tt_response->ttvn, | 1839 | tt_response->ttvn, |
1817 | (struct tt_change *)(tt_response + 1)); | 1840 | (struct tt_change *)(tt_response + 1)); |
1818 | 1841 | ||
1819 | /* Delete the tt_req_node from pending tt_requests list */ | 1842 | /* Delete the tt_req_node from pending tt_requests list */ |
1820 | spin_lock_bh(&bat_priv->tt_req_list_lock); | 1843 | spin_lock_bh(&bat_priv->tt_req_list_lock); |
@@ -1827,7 +1850,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, | |||
1827 | spin_unlock_bh(&bat_priv->tt_req_list_lock); | 1850 | spin_unlock_bh(&bat_priv->tt_req_list_lock); |
1828 | 1851 | ||
1829 | /* Recalculate the CRC for this orig_node and store it */ | 1852 | /* Recalculate the CRC for this orig_node and store it */ |
1830 | orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); | 1853 | orig_node->tt_crc = batadv_tt_global_crc(bat_priv, orig_node); |
1831 | /* Roaming phase is over: tables are in sync again. I can | 1854 | /* Roaming phase is over: tables are in sync again. I can |
1832 | * unset the flag | 1855 | * unset the flag |
1833 | */ | 1856 | */ |
@@ -1841,20 +1864,20 @@ int batadv_tt_init(struct bat_priv *bat_priv) | |||
1841 | { | 1864 | { |
1842 | int ret; | 1865 | int ret; |
1843 | 1866 | ||
1844 | ret = tt_local_init(bat_priv); | 1867 | ret = batadv_tt_local_init(bat_priv); |
1845 | if (ret < 0) | 1868 | if (ret < 0) |
1846 | return ret; | 1869 | return ret; |
1847 | 1870 | ||
1848 | ret = tt_global_init(bat_priv); | 1871 | ret = batadv_tt_global_init(bat_priv); |
1849 | if (ret < 0) | 1872 | if (ret < 0) |
1850 | return ret; | 1873 | return ret; |
1851 | 1874 | ||
1852 | tt_start_timer(bat_priv); | 1875 | batadv_tt_start_timer(bat_priv); |
1853 | 1876 | ||
1854 | return 1; | 1877 | return 1; |
1855 | } | 1878 | } |
1856 | 1879 | ||
1857 | static void tt_roam_list_free(struct bat_priv *bat_priv) | 1880 | static void batadv_tt_roam_list_free(struct bat_priv *bat_priv) |
1858 | { | 1881 | { |
1859 | struct tt_roam_node *node, *safe; | 1882 | struct tt_roam_node *node, *safe; |
1860 | 1883 | ||
@@ -1868,7 +1891,7 @@ static void tt_roam_list_free(struct bat_priv *bat_priv) | |||
1868 | spin_unlock_bh(&bat_priv->tt_roam_list_lock); | 1891 | spin_unlock_bh(&bat_priv->tt_roam_list_lock); |
1869 | } | 1892 | } |
1870 | 1893 | ||
1871 | static void tt_roam_purge(struct bat_priv *bat_priv) | 1894 | static void batadv_tt_roam_purge(struct bat_priv *bat_priv) |
1872 | { | 1895 | { |
1873 | struct tt_roam_node *node, *safe; | 1896 | struct tt_roam_node *node, *safe; |
1874 | 1897 | ||
@@ -1889,8 +1912,8 @@ static void tt_roam_purge(struct bat_priv *bat_priv) | |||
1889 | * | 1912 | * |
1890 | * returns true if the ROAMING_ADV can be sent, false otherwise | 1913 | * returns true if the ROAMING_ADV can be sent, false otherwise |
1891 | */ | 1914 | */ |
1892 | static bool tt_check_roam_count(struct bat_priv *bat_priv, | 1915 | static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv, |
1893 | uint8_t *client) | 1916 | uint8_t *client) |
1894 | { | 1917 | { |
1895 | struct tt_roam_node *tt_roam_node; | 1918 | struct tt_roam_node *tt_roam_node; |
1896 | bool ret = false; | 1919 | bool ret = false; |
@@ -1932,8 +1955,8 @@ unlock: | |||
1932 | return ret; | 1955 | return ret; |
1933 | } | 1956 | } |
1934 | 1957 | ||
1935 | static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, | 1958 | static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, |
1936 | struct orig_node *orig_node) | 1959 | struct orig_node *orig_node) |
1937 | { | 1960 | { |
1938 | struct neigh_node *neigh_node = NULL; | 1961 | struct neigh_node *neigh_node = NULL; |
1939 | struct sk_buff *skb = NULL; | 1962 | struct sk_buff *skb = NULL; |
@@ -1944,7 +1967,7 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, | |||
1944 | /* before going on we have to check whether the client has | 1967 | /* before going on we have to check whether the client has |
1945 | * already roamed to us too many times | 1968 | * already roamed to us too many times |
1946 | */ | 1969 | */ |
1947 | if (!tt_check_roam_count(bat_priv, client)) | 1970 | if (!batadv_tt_check_roam_count(bat_priv, client)) |
1948 | goto out; | 1971 | goto out; |
1949 | 1972 | ||
1950 | skb = dev_alloc_skb(sizeof(struct roam_adv_packet) + ETH_HLEN); | 1973 | skb = dev_alloc_skb(sizeof(struct roam_adv_packet) + ETH_HLEN); |
@@ -1988,30 +2011,30 @@ out: | |||
1988 | return; | 2011 | return; |
1989 | } | 2012 | } |
1990 | 2013 | ||
1991 | static void tt_purge(struct work_struct *work) | 2014 | static void batadv_tt_purge(struct work_struct *work) |
1992 | { | 2015 | { |
1993 | struct delayed_work *delayed_work = | 2016 | struct delayed_work *delayed_work = |
1994 | container_of(work, struct delayed_work, work); | 2017 | container_of(work, struct delayed_work, work); |
1995 | struct bat_priv *bat_priv = | 2018 | struct bat_priv *bat_priv = |
1996 | container_of(delayed_work, struct bat_priv, tt_work); | 2019 | container_of(delayed_work, struct bat_priv, tt_work); |
1997 | 2020 | ||
1998 | tt_local_purge(bat_priv); | 2021 | batadv_tt_local_purge(bat_priv); |
1999 | tt_global_roam_purge(bat_priv); | 2022 | batadv_tt_global_roam_purge(bat_priv); |
2000 | tt_req_purge(bat_priv); | 2023 | batadv_tt_req_purge(bat_priv); |
2001 | tt_roam_purge(bat_priv); | 2024 | batadv_tt_roam_purge(bat_priv); |
2002 | 2025 | ||
2003 | tt_start_timer(bat_priv); | 2026 | batadv_tt_start_timer(bat_priv); |
2004 | } | 2027 | } |
2005 | 2028 | ||
2006 | void batadv_tt_free(struct bat_priv *bat_priv) | 2029 | void batadv_tt_free(struct bat_priv *bat_priv) |
2007 | { | 2030 | { |
2008 | cancel_delayed_work_sync(&bat_priv->tt_work); | 2031 | cancel_delayed_work_sync(&bat_priv->tt_work); |
2009 | 2032 | ||
2010 | tt_local_table_free(bat_priv); | 2033 | batadv_tt_local_table_free(bat_priv); |
2011 | tt_global_table_free(bat_priv); | 2034 | batadv_tt_global_table_free(bat_priv); |
2012 | tt_req_list_free(bat_priv); | 2035 | batadv_tt_req_list_free(bat_priv); |
2013 | tt_changes_list_free(bat_priv); | 2036 | batadv_tt_changes_list_free(bat_priv); |
2014 | tt_roam_list_free(bat_priv); | 2037 | batadv_tt_roam_list_free(bat_priv); |
2015 | 2038 | ||
2016 | kfree(bat_priv->tt_buff); | 2039 | kfree(bat_priv->tt_buff); |
2017 | } | 2040 | } |
@@ -2019,8 +2042,8 @@ void batadv_tt_free(struct bat_priv *bat_priv) | |||
2019 | /* This function will enable or disable the specified flags for all the entries | 2042 | /* This function will enable or disable the specified flags for all the entries |
2020 | * in the given hash table and returns the number of modified entries | 2043 | * in the given hash table and returns the number of modified entries |
2021 | */ | 2044 | */ |
2022 | static uint16_t tt_set_flags(struct hashtable_t *hash, uint16_t flags, | 2045 | static uint16_t batadv_tt_set_flags(struct hashtable_t *hash, uint16_t flags, |
2023 | bool enable) | 2046 | bool enable) |
2024 | { | 2047 | { |
2025 | uint32_t i; | 2048 | uint32_t i; |
2026 | uint16_t changed_num = 0; | 2049 | uint16_t changed_num = 0; |
@@ -2055,7 +2078,7 @@ out: | |||
2055 | } | 2078 | } |
2056 | 2079 | ||
2057 | /* Purge out all the tt local entries marked with TT_CLIENT_PENDING */ | 2080 | /* Purge out all the tt local entries marked with TT_CLIENT_PENDING */ |
2058 | static void tt_local_purge_pending_clients(struct bat_priv *bat_priv) | 2081 | static void batadv_tt_local_purge_pending_clients(struct bat_priv *bat_priv) |
2059 | { | 2082 | { |
2060 | struct hashtable_t *hash = bat_priv->tt_local_hash; | 2083 | struct hashtable_t *hash = bat_priv->tt_local_hash; |
2061 | struct tt_common_entry *tt_common_entry; | 2084 | struct tt_common_entry *tt_common_entry; |
@@ -2087,28 +2110,28 @@ static void tt_local_purge_pending_clients(struct bat_priv *bat_priv) | |||
2087 | tt_local_entry = container_of(tt_common_entry, | 2110 | tt_local_entry = container_of(tt_common_entry, |
2088 | struct tt_local_entry, | 2111 | struct tt_local_entry, |
2089 | common); | 2112 | common); |
2090 | tt_local_entry_free_ref(tt_local_entry); | 2113 | batadv_tt_local_entry_free_ref(tt_local_entry); |
2091 | } | 2114 | } |
2092 | spin_unlock_bh(list_lock); | 2115 | spin_unlock_bh(list_lock); |
2093 | } | 2116 | } |
2094 | 2117 | ||
2095 | } | 2118 | } |
2096 | 2119 | ||
2097 | static int tt_commit_changes(struct bat_priv *bat_priv, | 2120 | static int batadv_tt_commit_changes(struct bat_priv *bat_priv, |
2098 | unsigned char **packet_buff, int *packet_buff_len, | 2121 | unsigned char **packet_buff, |
2099 | int packet_min_len) | 2122 | int *packet_buff_len, int packet_min_len) |
2100 | { | 2123 | { |
2101 | uint16_t changed_num = 0; | 2124 | uint16_t changed_num = 0; |
2102 | 2125 | ||
2103 | if (atomic_read(&bat_priv->tt_local_changes) < 1) | 2126 | if (atomic_read(&bat_priv->tt_local_changes) < 1) |
2104 | return -ENOENT; | 2127 | return -ENOENT; |
2105 | 2128 | ||
2106 | changed_num = tt_set_flags(bat_priv->tt_local_hash, | 2129 | changed_num = batadv_tt_set_flags(bat_priv->tt_local_hash, |
2107 | TT_CLIENT_NEW, false); | 2130 | TT_CLIENT_NEW, false); |
2108 | 2131 | ||
2109 | /* all reset entries have to be counted as local entries */ | 2132 | /* all reset entries have to be counted as local entries */ |
2110 | atomic_add(changed_num, &bat_priv->num_local_tt); | 2133 | atomic_add(changed_num, &bat_priv->num_local_tt); |
2111 | tt_local_purge_pending_clients(bat_priv); | 2134 | batadv_tt_local_purge_pending_clients(bat_priv); |
2112 | bat_priv->tt_crc = batadv_tt_local_crc(bat_priv); | 2135 | bat_priv->tt_crc = batadv_tt_local_crc(bat_priv); |
2113 | 2136 | ||
2114 | /* Increment the TTVN only once per OGM interval */ | 2137 | /* Increment the TTVN only once per OGM interval */ |
@@ -2121,8 +2144,8 @@ static int tt_commit_changes(struct bat_priv *bat_priv, | |||
2121 | /* reset the sending counter */ | 2144 | /* reset the sending counter */ |
2122 | atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX); | 2145 | atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX); |
2123 | 2146 | ||
2124 | return tt_changes_fill_buff(bat_priv, packet_buff, | 2147 | return batadv_tt_changes_fill_buff(bat_priv, packet_buff, |
2125 | packet_buff_len, packet_min_len); | 2148 | packet_buff_len, packet_min_len); |
2126 | } | 2149 | } |
2127 | 2150 | ||
2128 | /* when calling this function (hard_iface == primary_if) has to be true */ | 2151 | /* when calling this function (hard_iface == primary_if) has to be true */ |
@@ -2133,14 +2156,15 @@ int batadv_tt_append_diff(struct bat_priv *bat_priv, | |||
2133 | int tt_num_changes; | 2156 | int tt_num_changes; |
2134 | 2157 | ||
2135 | /* if at least one change happened */ | 2158 | /* if at least one change happened */ |
2136 | tt_num_changes = tt_commit_changes(bat_priv, packet_buff, | 2159 | tt_num_changes = batadv_tt_commit_changes(bat_priv, packet_buff, |
2137 | packet_buff_len, packet_min_len); | 2160 | packet_buff_len, |
2161 | packet_min_len); | ||
2138 | 2162 | ||
2139 | /* if the changes have been sent often enough */ | 2163 | /* if the changes have been sent often enough */ |
2140 | if ((tt_num_changes < 0) && | 2164 | if ((tt_num_changes < 0) && |
2141 | (!atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) { | 2165 | (!atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) { |
2142 | tt_realloc_packet_buff(packet_buff, packet_buff_len, | 2166 | batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len, |
2143 | packet_min_len, packet_min_len); | 2167 | packet_min_len, packet_min_len); |
2144 | tt_num_changes = 0; | 2168 | tt_num_changes = 0; |
2145 | } | 2169 | } |
2146 | 2170 | ||
@@ -2157,24 +2181,24 @@ bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, | |||
2157 | if (!atomic_read(&bat_priv->ap_isolation)) | 2181 | if (!atomic_read(&bat_priv->ap_isolation)) |
2158 | return false; | 2182 | return false; |
2159 | 2183 | ||
2160 | tt_local_entry = tt_local_hash_find(bat_priv, dst); | 2184 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst); |
2161 | if (!tt_local_entry) | 2185 | if (!tt_local_entry) |
2162 | goto out; | 2186 | goto out; |
2163 | 2187 | ||
2164 | tt_global_entry = tt_global_hash_find(bat_priv, src); | 2188 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, src); |
2165 | if (!tt_global_entry) | 2189 | if (!tt_global_entry) |
2166 | goto out; | 2190 | goto out; |
2167 | 2191 | ||
2168 | if (_is_ap_isolated(tt_local_entry, tt_global_entry)) | 2192 | if (_batadv_is_ap_isolated(tt_local_entry, tt_global_entry)) |
2169 | goto out; | 2193 | goto out; |
2170 | 2194 | ||
2171 | ret = false; | 2195 | ret = false; |
2172 | 2196 | ||
2173 | out: | 2197 | out: |
2174 | if (tt_global_entry) | 2198 | if (tt_global_entry) |
2175 | tt_global_entry_free_ref(tt_global_entry); | 2199 | batadv_tt_global_entry_free_ref(tt_global_entry); |
2176 | if (tt_local_entry) | 2200 | if (tt_local_entry) |
2177 | tt_local_entry_free_ref(tt_local_entry); | 2201 | batadv_tt_local_entry_free_ref(tt_local_entry); |
2178 | return ret; | 2202 | return ret; |
2179 | } | 2203 | } |
2180 | 2204 | ||
@@ -2204,14 +2228,14 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv, | |||
2204 | goto request_table; | 2228 | goto request_table; |
2205 | } | 2229 | } |
2206 | 2230 | ||
2207 | tt_update_changes(bat_priv, orig_node, tt_num_changes, ttvn, | 2231 | batadv_tt_update_changes(bat_priv, orig_node, tt_num_changes, |
2208 | (struct tt_change *)tt_buff); | 2232 | ttvn, (struct tt_change *)tt_buff); |
2209 | 2233 | ||
2210 | /* Even if we received the precomputed crc with the OGM, we | 2234 | /* Even if we received the precomputed crc with the OGM, we |
2211 | * prefer to recompute it to spot any possible inconsistency | 2235 | * prefer to recompute it to spot any possible inconsistency |
2212 | * in the global table | 2236 | * in the global table |
2213 | */ | 2237 | */ |
2214 | orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); | 2238 | orig_node->tt_crc = batadv_tt_global_crc(bat_priv, orig_node); |
2215 | 2239 | ||
2216 | /* The ttvn alone is not enough to guarantee consistency | 2240 | /* The ttvn alone is not enough to guarantee consistency |
2217 | * because a single value could represent different states | 2241 | * because a single value could represent different states |
@@ -2240,8 +2264,8 @@ request_table: | |||
2240 | "TT inconsistency for %pM. Need to retrieve the correct information (ttvn: %u last_ttvn: %u crc: %u last_crc: %u num_changes: %u)\n", | 2264 | "TT inconsistency for %pM. Need to retrieve the correct information (ttvn: %u last_ttvn: %u crc: %u last_crc: %u num_changes: %u)\n", |
2241 | orig_node->orig, ttvn, orig_ttvn, tt_crc, | 2265 | orig_node->orig, ttvn, orig_ttvn, tt_crc, |
2242 | orig_node->tt_crc, tt_num_changes); | 2266 | orig_node->tt_crc, tt_num_changes); |
2243 | send_tt_request(bat_priv, orig_node, ttvn, tt_crc, | 2267 | batadv_send_tt_request(bat_priv, orig_node, ttvn, |
2244 | full_table); | 2268 | tt_crc, full_table); |
2245 | return; | 2269 | return; |
2246 | } | 2270 | } |
2247 | } | 2271 | } |
@@ -2257,12 +2281,12 @@ bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv, | |||
2257 | struct tt_global_entry *tt_global_entry; | 2281 | struct tt_global_entry *tt_global_entry; |
2258 | bool ret = false; | 2282 | bool ret = false; |
2259 | 2283 | ||
2260 | tt_global_entry = tt_global_hash_find(bat_priv, addr); | 2284 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr); |
2261 | if (!tt_global_entry) | 2285 | if (!tt_global_entry) |
2262 | goto out; | 2286 | goto out; |
2263 | 2287 | ||
2264 | ret = tt_global_entry->common.flags & TT_CLIENT_ROAM; | 2288 | ret = tt_global_entry->common.flags & TT_CLIENT_ROAM; |
2265 | tt_global_entry_free_ref(tt_global_entry); | 2289 | batadv_tt_global_entry_free_ref(tt_global_entry); |
2266 | out: | 2290 | out: |
2267 | return ret; | 2291 | return ret; |
2268 | } | 2292 | } |