diff options
author | Sven Eckelmann <sven@narfation.org> | 2012-05-16 14:23:18 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-06-28 02:44:46 -0400 |
commit | eaad8ad95392d1da3c0f2404dfc3fce56afea766 (patch) | |
tree | 8891820cd6a620c1d9c4fbe6930f332fca87a60b /net/batman-adv | |
parent | 0354440ba142eb9b6a03d287349350c1f75e5786 (diff) |
batman-adv: Prefix vis 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>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/vis.c | 201 |
1 files changed, 103 insertions, 98 deletions
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index d45989e0bbd7..607b1015a761 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
@@ -28,10 +28,10 @@ | |||
28 | 28 | ||
29 | #define MAX_VIS_PACKET_SIZE 1000 | 29 | #define MAX_VIS_PACKET_SIZE 1000 |
30 | 30 | ||
31 | static void start_vis_timer(struct bat_priv *bat_priv); | 31 | static void batadv_start_vis_timer(struct bat_priv *bat_priv); |
32 | 32 | ||
33 | /* free the info */ | 33 | /* free the info */ |
34 | static void free_info(struct kref *ref) | 34 | static void batadv_free_info(struct kref *ref) |
35 | { | 35 | { |
36 | struct vis_info *info = container_of(ref, struct vis_info, refcount); | 36 | struct vis_info *info = container_of(ref, struct vis_info, refcount); |
37 | struct bat_priv *bat_priv = info->bat_priv; | 37 | struct bat_priv *bat_priv = info->bat_priv; |
@@ -50,7 +50,7 @@ static void free_info(struct kref *ref) | |||
50 | } | 50 | } |
51 | 51 | ||
52 | /* Compare two vis packets, used by the hashing algorithm */ | 52 | /* Compare two vis packets, used by the hashing algorithm */ |
53 | static int vis_info_cmp(const struct hlist_node *node, const void *data2) | 53 | static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2) |
54 | { | 54 | { |
55 | const struct vis_info *d1, *d2; | 55 | const struct vis_info *d1, *d2; |
56 | const struct vis_packet *p1, *p2; | 56 | const struct vis_packet *p1, *p2; |
@@ -65,7 +65,7 @@ static int vis_info_cmp(const struct hlist_node *node, const void *data2) | |||
65 | /* hash function to choose an entry in a hash table of given size | 65 | /* hash function to choose an entry in a hash table of given size |
66 | * hash algorithm from http://en.wikipedia.org/wiki/Hash_table | 66 | * hash algorithm from http://en.wikipedia.org/wiki/Hash_table |
67 | */ | 67 | */ |
68 | static uint32_t vis_info_choose(const void *data, uint32_t size) | 68 | static uint32_t batadv_vis_info_choose(const void *data, uint32_t size) |
69 | { | 69 | { |
70 | const struct vis_info *vis_info = data; | 70 | const struct vis_info *vis_info = data; |
71 | const struct vis_packet *packet; | 71 | const struct vis_packet *packet; |
@@ -88,8 +88,8 @@ static uint32_t vis_info_choose(const void *data, uint32_t size) | |||
88 | return hash % size; | 88 | return hash % size; |
89 | } | 89 | } |
90 | 90 | ||
91 | static struct vis_info *vis_hash_find(struct bat_priv *bat_priv, | 91 | static struct vis_info *batadv_vis_hash_find(struct bat_priv *bat_priv, |
92 | const void *data) | 92 | const void *data) |
93 | { | 93 | { |
94 | struct hashtable_t *hash = bat_priv->vis_hash; | 94 | struct hashtable_t *hash = bat_priv->vis_hash; |
95 | struct hlist_head *head; | 95 | struct hlist_head *head; |
@@ -100,12 +100,12 @@ static struct vis_info *vis_hash_find(struct bat_priv *bat_priv, | |||
100 | if (!hash) | 100 | if (!hash) |
101 | return NULL; | 101 | return NULL; |
102 | 102 | ||
103 | index = vis_info_choose(data, hash->size); | 103 | index = batadv_vis_info_choose(data, hash->size); |
104 | head = &hash->table[index]; | 104 | head = &hash->table[index]; |
105 | 105 | ||
106 | rcu_read_lock(); | 106 | rcu_read_lock(); |
107 | hlist_for_each_entry_rcu(vis_info, node, head, hash_entry) { | 107 | hlist_for_each_entry_rcu(vis_info, node, head, hash_entry) { |
108 | if (!vis_info_cmp(node, data)) | 108 | if (!batadv_vis_info_cmp(node, data)) |
109 | continue; | 109 | continue; |
110 | 110 | ||
111 | vis_info_tmp = vis_info; | 111 | vis_info_tmp = vis_info; |
@@ -119,9 +119,9 @@ static struct vis_info *vis_hash_find(struct bat_priv *bat_priv, | |||
119 | /* insert interface to the list of interfaces of one originator, if it | 119 | /* insert interface to the list of interfaces of one originator, if it |
120 | * does not already exist in the list | 120 | * does not already exist in the list |
121 | */ | 121 | */ |
122 | static void vis_data_insert_interface(const uint8_t *interface, | 122 | static void batadv_vis_data_insert_interface(const uint8_t *interface, |
123 | struct hlist_head *if_list, | 123 | struct hlist_head *if_list, |
124 | bool primary) | 124 | bool primary) |
125 | { | 125 | { |
126 | struct if_list_entry *entry; | 126 | struct if_list_entry *entry; |
127 | struct hlist_node *pos; | 127 | struct hlist_node *pos; |
@@ -140,8 +140,7 @@ static void vis_data_insert_interface(const uint8_t *interface, | |||
140 | hlist_add_head(&entry->list, if_list); | 140 | hlist_add_head(&entry->list, if_list); |
141 | } | 141 | } |
142 | 142 | ||
143 | static ssize_t vis_data_read_prim_sec(char *buff, | 143 | static ssize_t batadv_vis_prim_sec(char *buff, const struct hlist_head *if_list) |
144 | const struct hlist_head *if_list) | ||
145 | { | 144 | { |
146 | struct if_list_entry *entry; | 145 | struct if_list_entry *entry; |
147 | struct hlist_node *pos; | 146 | struct hlist_node *pos; |
@@ -157,7 +156,7 @@ static ssize_t vis_data_read_prim_sec(char *buff, | |||
157 | return len; | 156 | return len; |
158 | } | 157 | } |
159 | 158 | ||
160 | static size_t vis_data_count_prim_sec(struct hlist_head *if_list) | 159 | static size_t batadv_vis_cnt_prim_sec(struct hlist_head *if_list) |
161 | { | 160 | { |
162 | struct if_list_entry *entry; | 161 | struct if_list_entry *entry; |
163 | struct hlist_node *pos; | 162 | struct hlist_node *pos; |
@@ -174,9 +173,9 @@ static size_t vis_data_count_prim_sec(struct hlist_head *if_list) | |||
174 | } | 173 | } |
175 | 174 | ||
176 | /* read an entry */ | 175 | /* read an entry */ |
177 | static ssize_t vis_data_read_entry(char *buff, | 176 | static ssize_t batadv_vis_data_read_entry(char *buff, |
178 | const struct vis_info_entry *entry, | 177 | const struct vis_info_entry *entry, |
179 | const uint8_t *src, bool primary) | 178 | const uint8_t *src, bool primary) |
180 | { | 179 | { |
181 | /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ | 180 | /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ |
182 | if (primary && entry->quality == 0) | 181 | if (primary && entry->quality == 0) |
@@ -227,8 +226,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) | |||
227 | entries = (struct vis_info_entry *) | 226 | entries = (struct vis_info_entry *) |
228 | ((char *)packet + sizeof(*packet)); | 227 | ((char *)packet + sizeof(*packet)); |
229 | 228 | ||
230 | vis_data_insert_interface(packet->vis_orig, | 229 | batadv_vis_data_insert_interface(packet->vis_orig, |
231 | &vis_if_list, true); | 230 | &vis_if_list, true); |
232 | 231 | ||
233 | for (j = 0; j < packet->entries; j++) { | 232 | for (j = 0; j < packet->entries; j++) { |
234 | if (entries[j].quality == 0) | 233 | if (entries[j].quality == 0) |
@@ -236,9 +235,9 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) | |||
236 | if (batadv_compare_eth(entries[j].src, | 235 | if (batadv_compare_eth(entries[j].src, |
237 | packet->vis_orig)) | 236 | packet->vis_orig)) |
238 | continue; | 237 | continue; |
239 | vis_data_insert_interface(entries[j].src, | 238 | batadv_vis_data_insert_interface(entries[j].src, |
240 | &vis_if_list, | 239 | &vis_if_list, |
241 | false); | 240 | false); |
242 | } | 241 | } |
243 | 242 | ||
244 | hlist_for_each_entry(entry, pos, &vis_if_list, list) { | 243 | hlist_for_each_entry(entry, pos, &vis_if_list, list) { |
@@ -248,7 +247,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) | |||
248 | if (batadv_compare_eth(entry->addr, | 247 | if (batadv_compare_eth(entry->addr, |
249 | packet->vis_orig)) | 248 | packet->vis_orig)) |
250 | buf_size += | 249 | buf_size += |
251 | vis_data_count_prim_sec(&vis_if_list); | 250 | batadv_vis_cnt_prim_sec(&vis_if_list); |
252 | 251 | ||
253 | buf_size += 1; | 252 | buf_size += 1; |
254 | } | 253 | } |
@@ -280,8 +279,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) | |||
280 | entries = (struct vis_info_entry *) | 279 | entries = (struct vis_info_entry *) |
281 | ((char *)packet + sizeof(*packet)); | 280 | ((char *)packet + sizeof(*packet)); |
282 | 281 | ||
283 | vis_data_insert_interface(packet->vis_orig, | 282 | batadv_vis_data_insert_interface(packet->vis_orig, |
284 | &vis_if_list, true); | 283 | &vis_if_list, true); |
285 | 284 | ||
286 | for (j = 0; j < packet->entries; j++) { | 285 | for (j = 0; j < packet->entries; j++) { |
287 | if (entries[j].quality == 0) | 286 | if (entries[j].quality == 0) |
@@ -289,9 +288,9 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) | |||
289 | if (batadv_compare_eth(entries[j].src, | 288 | if (batadv_compare_eth(entries[j].src, |
290 | packet->vis_orig)) | 289 | packet->vis_orig)) |
291 | continue; | 290 | continue; |
292 | vis_data_insert_interface(entries[j].src, | 291 | batadv_vis_data_insert_interface(entries[j].src, |
293 | &vis_if_list, | 292 | &vis_if_list, |
294 | false); | 293 | false); |
295 | } | 294 | } |
296 | 295 | ||
297 | hlist_for_each_entry(entry, pos, &vis_if_list, list) { | 296 | hlist_for_each_entry(entry, pos, &vis_if_list, list) { |
@@ -299,7 +298,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) | |||
299 | entry->addr); | 298 | entry->addr); |
300 | 299 | ||
301 | for (j = 0; j < packet->entries; j++) | 300 | for (j = 0; j < packet->entries; j++) |
302 | buff_pos += vis_data_read_entry( | 301 | buff_pos += batadv_vis_data_read_entry( |
303 | buff + buff_pos, | 302 | buff + buff_pos, |
304 | &entries[j], | 303 | &entries[j], |
305 | entry->addr, | 304 | entry->addr, |
@@ -309,8 +308,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) | |||
309 | if (batadv_compare_eth(entry->addr, | 308 | if (batadv_compare_eth(entry->addr, |
310 | packet->vis_orig)) | 309 | packet->vis_orig)) |
311 | buff_pos += | 310 | buff_pos += |
312 | vis_data_read_prim_sec(buff + buff_pos, | 311 | batadv_vis_prim_sec(buff + buff_pos, |
313 | &vis_if_list); | 312 | &vis_if_list); |
314 | 313 | ||
315 | buff_pos += sprintf(buff + buff_pos, "\n"); | 314 | buff_pos += sprintf(buff + buff_pos, "\n"); |
316 | } | 315 | } |
@@ -338,7 +337,8 @@ out: | |||
338 | /* add the info packet to the send list, if it was not | 337 | /* add the info packet to the send list, if it was not |
339 | * already linked in. | 338 | * already linked in. |
340 | */ | 339 | */ |
341 | static void send_list_add(struct bat_priv *bat_priv, struct vis_info *info) | 340 | static void batadv_send_list_add(struct bat_priv *bat_priv, |
341 | struct vis_info *info) | ||
342 | { | 342 | { |
343 | if (list_empty(&info->send_list)) { | 343 | if (list_empty(&info->send_list)) { |
344 | kref_get(&info->refcount); | 344 | kref_get(&info->refcount); |
@@ -349,17 +349,17 @@ static void send_list_add(struct bat_priv *bat_priv, struct vis_info *info) | |||
349 | /* delete the info packet from the send list, if it was | 349 | /* delete the info packet from the send list, if it was |
350 | * linked in. | 350 | * linked in. |
351 | */ | 351 | */ |
352 | static void send_list_del(struct vis_info *info) | 352 | static void batadv_send_list_del(struct vis_info *info) |
353 | { | 353 | { |
354 | if (!list_empty(&info->send_list)) { | 354 | if (!list_empty(&info->send_list)) { |
355 | list_del_init(&info->send_list); | 355 | list_del_init(&info->send_list); |
356 | kref_put(&info->refcount, free_info); | 356 | kref_put(&info->refcount, batadv_free_info); |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | /* tries to add one entry to the receive list. */ | 360 | /* tries to add one entry to the receive list. */ |
361 | static void recv_list_add(struct bat_priv *bat_priv, | 361 | static void batadv_recv_list_add(struct bat_priv *bat_priv, |
362 | struct list_head *recv_list, const char *mac) | 362 | struct list_head *recv_list, const char *mac) |
363 | { | 363 | { |
364 | struct recvlist_node *entry; | 364 | struct recvlist_node *entry; |
365 | 365 | ||
@@ -374,8 +374,9 @@ static void recv_list_add(struct bat_priv *bat_priv, | |||
374 | } | 374 | } |
375 | 375 | ||
376 | /* returns 1 if this mac is in the recv_list */ | 376 | /* returns 1 if this mac is in the recv_list */ |
377 | static int recv_list_is_in(struct bat_priv *bat_priv, | 377 | static int batadv_recv_list_is_in(struct bat_priv *bat_priv, |
378 | const struct list_head *recv_list, const char *mac) | 378 | const struct list_head *recv_list, |
379 | const char *mac) | ||
379 | { | 380 | { |
380 | const struct recvlist_node *entry; | 381 | const struct recvlist_node *entry; |
381 | 382 | ||
@@ -394,10 +395,10 @@ static int recv_list_is_in(struct bat_priv *bat_priv, | |||
394 | * broken.. ). vis hash must be locked outside. is_new is set when the packet | 395 | * broken.. ). vis hash must be locked outside. is_new is set when the packet |
395 | * is newer than old entries in the hash. | 396 | * is newer than old entries in the hash. |
396 | */ | 397 | */ |
397 | static struct vis_info *add_packet(struct bat_priv *bat_priv, | 398 | static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, |
398 | struct vis_packet *vis_packet, | 399 | struct vis_packet *vis_packet, |
399 | int vis_info_len, int *is_new, | 400 | int vis_info_len, int *is_new, |
400 | int make_broadcast) | 401 | int make_broadcast) |
401 | { | 402 | { |
402 | struct vis_info *info, *old_info; | 403 | struct vis_info *info, *old_info; |
403 | struct vis_packet *search_packet, *old_packet; | 404 | struct vis_packet *search_packet, *old_packet; |
@@ -418,7 +419,7 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, | |||
418 | sizeof(*search_packet)); | 419 | sizeof(*search_packet)); |
419 | 420 | ||
420 | memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN); | 421 | memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN); |
421 | old_info = vis_hash_find(bat_priv, &search_elem); | 422 | old_info = batadv_vis_hash_find(bat_priv, &search_elem); |
422 | kfree_skb(search_elem.skb_packet); | 423 | kfree_skb(search_elem.skb_packet); |
423 | 424 | ||
424 | if (old_info) { | 425 | if (old_info) { |
@@ -426,8 +427,9 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, | |||
426 | if (!seq_after(ntohl(vis_packet->seqno), | 427 | if (!seq_after(ntohl(vis_packet->seqno), |
427 | ntohl(old_packet->seqno))) { | 428 | ntohl(old_packet->seqno))) { |
428 | if (old_packet->seqno == vis_packet->seqno) { | 429 | if (old_packet->seqno == vis_packet->seqno) { |
429 | recv_list_add(bat_priv, &old_info->recv_list, | 430 | batadv_recv_list_add(bat_priv, |
430 | vis_packet->sender_orig); | 431 | &old_info->recv_list, |
432 | vis_packet->sender_orig); | ||
431 | return old_info; | 433 | return old_info; |
432 | } else { | 434 | } else { |
433 | /* newer packet is already in hash. */ | 435 | /* newer packet is already in hash. */ |
@@ -435,10 +437,10 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, | |||
435 | } | 437 | } |
436 | } | 438 | } |
437 | /* remove old entry */ | 439 | /* remove old entry */ |
438 | batadv_hash_remove(bat_priv->vis_hash, vis_info_cmp, | 440 | batadv_hash_remove(bat_priv->vis_hash, batadv_vis_info_cmp, |
439 | vis_info_choose, old_info); | 441 | batadv_vis_info_choose, old_info); |
440 | send_list_del(old_info); | 442 | batadv_send_list_del(old_info); |
441 | kref_put(&old_info->refcount, free_info); | 443 | kref_put(&old_info->refcount, batadv_free_info); |
442 | } | 444 | } |
443 | 445 | ||
444 | info = kmalloc(sizeof(*info), GFP_ATOMIC); | 446 | info = kmalloc(sizeof(*info), GFP_ATOMIC); |
@@ -473,14 +475,15 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, | |||
473 | if (packet->entries * sizeof(struct vis_info_entry) > vis_info_len) | 475 | if (packet->entries * sizeof(struct vis_info_entry) > vis_info_len) |
474 | packet->entries = vis_info_len / sizeof(struct vis_info_entry); | 476 | packet->entries = vis_info_len / sizeof(struct vis_info_entry); |
475 | 477 | ||
476 | recv_list_add(bat_priv, &info->recv_list, packet->sender_orig); | 478 | batadv_recv_list_add(bat_priv, &info->recv_list, packet->sender_orig); |
477 | 479 | ||
478 | /* try to add it */ | 480 | /* try to add it */ |
479 | hash_added = batadv_hash_add(bat_priv->vis_hash, vis_info_cmp, | 481 | hash_added = batadv_hash_add(bat_priv->vis_hash, batadv_vis_info_cmp, |
480 | vis_info_choose, info, &info->hash_entry); | 482 | batadv_vis_info_choose, info, |
483 | &info->hash_entry); | ||
481 | if (hash_added != 0) { | 484 | if (hash_added != 0) { |
482 | /* did not work (for some reason) */ | 485 | /* did not work (for some reason) */ |
483 | kref_put(&info->refcount, free_info); | 486 | kref_put(&info->refcount, batadv_free_info); |
484 | info = NULL; | 487 | info = NULL; |
485 | } | 488 | } |
486 | 489 | ||
@@ -499,8 +502,8 @@ void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, | |||
499 | make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC); | 502 | make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC); |
500 | 503 | ||
501 | spin_lock_bh(&bat_priv->vis_hash_lock); | 504 | spin_lock_bh(&bat_priv->vis_hash_lock); |
502 | info = add_packet(bat_priv, vis_packet, vis_info_len, | 505 | info = batadv_add_packet(bat_priv, vis_packet, vis_info_len, |
503 | &is_new, make_broadcast); | 506 | &is_new, make_broadcast); |
504 | if (!info) | 507 | if (!info) |
505 | goto end; | 508 | goto end; |
506 | 509 | ||
@@ -508,7 +511,7 @@ void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, | |||
508 | * hash. | 511 | * hash. |
509 | */ | 512 | */ |
510 | if (vis_server == VIS_TYPE_SERVER_SYNC && is_new) | 513 | if (vis_server == VIS_TYPE_SERVER_SYNC && is_new) |
511 | send_list_add(bat_priv, info); | 514 | batadv_send_list_add(bat_priv, info); |
512 | end: | 515 | end: |
513 | spin_unlock_bh(&bat_priv->vis_hash_lock); | 516 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
514 | } | 517 | } |
@@ -534,8 +537,8 @@ void batadv_receive_client_update_packet(struct bat_priv *bat_priv, | |||
534 | are_target = 1; | 537 | are_target = 1; |
535 | 538 | ||
536 | spin_lock_bh(&bat_priv->vis_hash_lock); | 539 | spin_lock_bh(&bat_priv->vis_hash_lock); |
537 | info = add_packet(bat_priv, vis_packet, vis_info_len, | 540 | info = batadv_add_packet(bat_priv, vis_packet, vis_info_len, |
538 | &is_new, are_target); | 541 | &is_new, are_target); |
539 | 542 | ||
540 | if (!info) | 543 | if (!info) |
541 | goto end; | 544 | goto end; |
@@ -546,11 +549,11 @@ void batadv_receive_client_update_packet(struct bat_priv *bat_priv, | |||
546 | /* send only if we're the target server or ... */ | 549 | /* send only if we're the target server or ... */ |
547 | if (are_target && is_new) { | 550 | if (are_target && is_new) { |
548 | packet->vis_type = VIS_TYPE_SERVER_SYNC; /* upgrade! */ | 551 | packet->vis_type = VIS_TYPE_SERVER_SYNC; /* upgrade! */ |
549 | send_list_add(bat_priv, info); | 552 | batadv_send_list_add(bat_priv, info); |
550 | 553 | ||
551 | /* ... we're not the recipient (and thus need to forward). */ | 554 | /* ... we're not the recipient (and thus need to forward). */ |
552 | } else if (!batadv_is_my_mac(packet->target_orig)) { | 555 | } else if (!batadv_is_my_mac(packet->target_orig)) { |
553 | send_list_add(bat_priv, info); | 556 | batadv_send_list_add(bat_priv, info); |
554 | } | 557 | } |
555 | 558 | ||
556 | end: | 559 | end: |
@@ -562,8 +565,8 @@ end: | |||
562 | * | 565 | * |
563 | * Must be called with the originator hash locked | 566 | * Must be called with the originator hash locked |
564 | */ | 567 | */ |
565 | static int find_best_vis_server(struct bat_priv *bat_priv, | 568 | static int batadv_find_best_vis_server(struct bat_priv *bat_priv, |
566 | struct vis_info *info) | 569 | struct vis_info *info) |
567 | { | 570 | { |
568 | struct hashtable_t *hash = bat_priv->orig_hash; | 571 | struct hashtable_t *hash = bat_priv->orig_hash; |
569 | struct neigh_node *router; | 572 | struct neigh_node *router; |
@@ -600,7 +603,7 @@ static int find_best_vis_server(struct bat_priv *bat_priv, | |||
600 | } | 603 | } |
601 | 604 | ||
602 | /* Return true if the vis packet is full. */ | 605 | /* Return true if the vis packet is full. */ |
603 | static bool vis_packet_full(const struct vis_info *info) | 606 | static bool batadv_vis_packet_full(const struct vis_info *info) |
604 | { | 607 | { |
605 | const struct vis_packet *packet; | 608 | const struct vis_packet *packet; |
606 | packet = (struct vis_packet *)info->skb_packet->data; | 609 | packet = (struct vis_packet *)info->skb_packet->data; |
@@ -614,7 +617,7 @@ static bool vis_packet_full(const struct vis_info *info) | |||
614 | /* generates a packet of own vis data, | 617 | /* generates a packet of own vis data, |
615 | * returns 0 on success, -1 if no packet could be generated | 618 | * returns 0 on success, -1 if no packet could be generated |
616 | */ | 619 | */ |
617 | static int generate_vis_packet(struct bat_priv *bat_priv) | 620 | static int batadv_generate_vis_packet(struct bat_priv *bat_priv) |
618 | { | 621 | { |
619 | struct hashtable_t *hash = bat_priv->orig_hash; | 622 | struct hashtable_t *hash = bat_priv->orig_hash; |
620 | struct hlist_node *node; | 623 | struct hlist_node *node; |
@@ -638,7 +641,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv) | |||
638 | skb_trim(info->skb_packet, sizeof(*packet)); | 641 | skb_trim(info->skb_packet, sizeof(*packet)); |
639 | 642 | ||
640 | if (packet->vis_type == VIS_TYPE_CLIENT_UPDATE) { | 643 | if (packet->vis_type == VIS_TYPE_CLIENT_UPDATE) { |
641 | best_tq = find_best_vis_server(bat_priv, info); | 644 | best_tq = batadv_find_best_vis_server(bat_priv, info); |
642 | 645 | ||
643 | if (best_tq < 0) | 646 | if (best_tq < 0) |
644 | return best_tq; | 647 | return best_tq; |
@@ -675,7 +678,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv) | |||
675 | next: | 678 | next: |
676 | batadv_neigh_node_free_ref(router); | 679 | batadv_neigh_node_free_ref(router); |
677 | 680 | ||
678 | if (vis_packet_full(info)) | 681 | if (batadv_vis_packet_full(info)) |
679 | goto unlock; | 682 | goto unlock; |
680 | } | 683 | } |
681 | rcu_read_unlock(); | 684 | rcu_read_unlock(); |
@@ -697,7 +700,7 @@ next: | |||
697 | entry->quality = 0; /* 0 means TT */ | 700 | entry->quality = 0; /* 0 means TT */ |
698 | packet->entries++; | 701 | packet->entries++; |
699 | 702 | ||
700 | if (vis_packet_full(info)) | 703 | if (batadv_vis_packet_full(info)) |
701 | goto unlock; | 704 | goto unlock; |
702 | } | 705 | } |
703 | rcu_read_unlock(); | 706 | rcu_read_unlock(); |
@@ -713,7 +716,7 @@ unlock: | |||
713 | /* free old vis packets. Must be called with this vis_hash_lock | 716 | /* free old vis packets. Must be called with this vis_hash_lock |
714 | * held | 717 | * held |
715 | */ | 718 | */ |
716 | static void purge_vis_packets(struct bat_priv *bat_priv) | 719 | static void batadv_purge_vis_packets(struct bat_priv *bat_priv) |
717 | { | 720 | { |
718 | uint32_t i; | 721 | uint32_t i; |
719 | struct hashtable_t *hash = bat_priv->vis_hash; | 722 | struct hashtable_t *hash = bat_priv->vis_hash; |
@@ -733,15 +736,15 @@ static void purge_vis_packets(struct bat_priv *bat_priv) | |||
733 | if (batadv_has_timed_out(info->first_seen, | 736 | if (batadv_has_timed_out(info->first_seen, |
734 | VIS_TIMEOUT)) { | 737 | VIS_TIMEOUT)) { |
735 | hlist_del(node); | 738 | hlist_del(node); |
736 | send_list_del(info); | 739 | batadv_send_list_del(info); |
737 | kref_put(&info->refcount, free_info); | 740 | kref_put(&info->refcount, batadv_free_info); |
738 | } | 741 | } |
739 | } | 742 | } |
740 | } | 743 | } |
741 | } | 744 | } |
742 | 745 | ||
743 | static void broadcast_vis_packet(struct bat_priv *bat_priv, | 746 | static void batadv_broadcast_vis_packet(struct bat_priv *bat_priv, |
744 | struct vis_info *info) | 747 | struct vis_info *info) |
745 | { | 748 | { |
746 | struct neigh_node *router; | 749 | struct neigh_node *router; |
747 | struct hashtable_t *hash = bat_priv->orig_hash; | 750 | struct hashtable_t *hash = bat_priv->orig_hash; |
@@ -774,8 +777,8 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv, | |||
774 | /* don't send it if we already received the packet from | 777 | /* don't send it if we already received the packet from |
775 | * this node. | 778 | * this node. |
776 | */ | 779 | */ |
777 | if (recv_list_is_in(bat_priv, &info->recv_list, | 780 | if (batadv_recv_list_is_in(bat_priv, &info->recv_list, |
778 | orig_node->orig)) { | 781 | orig_node->orig)) { |
779 | batadv_neigh_node_free_ref(router); | 782 | batadv_neigh_node_free_ref(router); |
780 | continue; | 783 | continue; |
781 | } | 784 | } |
@@ -796,8 +799,8 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv, | |||
796 | } | 799 | } |
797 | } | 800 | } |
798 | 801 | ||
799 | static void unicast_vis_packet(struct bat_priv *bat_priv, | 802 | static void batadv_unicast_vis_packet(struct bat_priv *bat_priv, |
800 | struct vis_info *info) | 803 | struct vis_info *info) |
801 | { | 804 | { |
802 | struct orig_node *orig_node; | 805 | struct orig_node *orig_node; |
803 | struct neigh_node *router = NULL; | 806 | struct neigh_node *router = NULL; |
@@ -825,8 +828,9 @@ out: | |||
825 | batadv_orig_node_free_ref(orig_node); | 828 | batadv_orig_node_free_ref(orig_node); |
826 | } | 829 | } |
827 | 830 | ||
828 | /* only send one vis packet. called from send_vis_packets() */ | 831 | /* only send one vis packet. called from batadv_send_vis_packets() */ |
829 | static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info) | 832 | static void batadv_send_vis_packet(struct bat_priv *bat_priv, |
833 | struct vis_info *info) | ||
830 | { | 834 | { |
831 | struct hard_iface *primary_if; | 835 | struct hard_iface *primary_if; |
832 | struct vis_packet *packet; | 836 | struct vis_packet *packet; |
@@ -845,9 +849,9 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info) | |||
845 | packet->header.ttl--; | 849 | packet->header.ttl--; |
846 | 850 | ||
847 | if (is_broadcast_ether_addr(packet->target_orig)) | 851 | if (is_broadcast_ether_addr(packet->target_orig)) |
848 | broadcast_vis_packet(bat_priv, info); | 852 | batadv_broadcast_vis_packet(bat_priv, info); |
849 | else | 853 | else |
850 | unicast_vis_packet(bat_priv, info); | 854 | batadv_unicast_vis_packet(bat_priv, info); |
851 | packet->header.ttl++; /* restore TTL */ | 855 | packet->header.ttl++; /* restore TTL */ |
852 | 856 | ||
853 | out: | 857 | out: |
@@ -856,7 +860,7 @@ out: | |||
856 | } | 860 | } |
857 | 861 | ||
858 | /* called from timer; send (and maybe generate) vis packet. */ | 862 | /* called from timer; send (and maybe generate) vis packet. */ |
859 | static void send_vis_packets(struct work_struct *work) | 863 | static void batadv_send_vis_packets(struct work_struct *work) |
860 | { | 864 | { |
861 | struct delayed_work *delayed_work = | 865 | struct delayed_work *delayed_work = |
862 | container_of(work, struct delayed_work, work); | 866 | container_of(work, struct delayed_work, work); |
@@ -865,11 +869,11 @@ static void send_vis_packets(struct work_struct *work) | |||
865 | struct vis_info *info; | 869 | struct vis_info *info; |
866 | 870 | ||
867 | spin_lock_bh(&bat_priv->vis_hash_lock); | 871 | spin_lock_bh(&bat_priv->vis_hash_lock); |
868 | purge_vis_packets(bat_priv); | 872 | batadv_purge_vis_packets(bat_priv); |
869 | 873 | ||
870 | if (generate_vis_packet(bat_priv) == 0) { | 874 | if (batadv_generate_vis_packet(bat_priv) == 0) { |
871 | /* schedule if generation was successful */ | 875 | /* schedule if generation was successful */ |
872 | send_list_add(bat_priv, bat_priv->my_vis_info); | 876 | batadv_send_list_add(bat_priv, bat_priv->my_vis_info); |
873 | } | 877 | } |
874 | 878 | ||
875 | while (!list_empty(&bat_priv->vis_send_list)) { | 879 | while (!list_empty(&bat_priv->vis_send_list)) { |
@@ -879,14 +883,14 @@ static void send_vis_packets(struct work_struct *work) | |||
879 | kref_get(&info->refcount); | 883 | kref_get(&info->refcount); |
880 | spin_unlock_bh(&bat_priv->vis_hash_lock); | 884 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
881 | 885 | ||
882 | send_vis_packet(bat_priv, info); | 886 | batadv_send_vis_packet(bat_priv, info); |
883 | 887 | ||
884 | spin_lock_bh(&bat_priv->vis_hash_lock); | 888 | spin_lock_bh(&bat_priv->vis_hash_lock); |
885 | send_list_del(info); | 889 | batadv_send_list_del(info); |
886 | kref_put(&info->refcount, free_info); | 890 | kref_put(&info->refcount, batadv_free_info); |
887 | } | 891 | } |
888 | spin_unlock_bh(&bat_priv->vis_hash_lock); | 892 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
889 | start_vis_timer(bat_priv); | 893 | batadv_start_vis_timer(bat_priv); |
890 | } | 894 | } |
891 | 895 | ||
892 | /* init the vis server. this may only be called when if_list is already | 896 | /* init the vis server. this may only be called when if_list is already |
@@ -937,18 +941,19 @@ int batadv_vis_init(struct bat_priv *bat_priv) | |||
937 | 941 | ||
938 | INIT_LIST_HEAD(&bat_priv->vis_send_list); | 942 | INIT_LIST_HEAD(&bat_priv->vis_send_list); |
939 | 943 | ||
940 | hash_added = batadv_hash_add(bat_priv->vis_hash, vis_info_cmp, | 944 | hash_added = batadv_hash_add(bat_priv->vis_hash, batadv_vis_info_cmp, |
941 | vis_info_choose, bat_priv->my_vis_info, | 945 | batadv_vis_info_choose, |
946 | bat_priv->my_vis_info, | ||
942 | &bat_priv->my_vis_info->hash_entry); | 947 | &bat_priv->my_vis_info->hash_entry); |
943 | if (hash_added != 0) { | 948 | if (hash_added != 0) { |
944 | pr_err("Can't add own vis packet into hash\n"); | 949 | pr_err("Can't add own vis packet into hash\n"); |
945 | /* not in hash, need to remove it manually. */ | 950 | /* not in hash, need to remove it manually. */ |
946 | kref_put(&bat_priv->my_vis_info->refcount, free_info); | 951 | kref_put(&bat_priv->my_vis_info->refcount, batadv_free_info); |
947 | goto err; | 952 | goto err; |
948 | } | 953 | } |
949 | 954 | ||
950 | spin_unlock_bh(&bat_priv->vis_hash_lock); | 955 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
951 | start_vis_timer(bat_priv); | 956 | batadv_start_vis_timer(bat_priv); |
952 | return 0; | 957 | return 0; |
953 | 958 | ||
954 | free_info: | 959 | free_info: |
@@ -961,13 +966,13 @@ err: | |||
961 | } | 966 | } |
962 | 967 | ||
963 | /* Decrease the reference count on a hash item info */ | 968 | /* Decrease the reference count on a hash item info */ |
964 | static void free_info_ref(struct hlist_node *node, void *arg) | 969 | static void batadv_free_info_ref(struct hlist_node *node, void *arg) |
965 | { | 970 | { |
966 | struct vis_info *info; | 971 | struct vis_info *info; |
967 | 972 | ||
968 | info = container_of(node, struct vis_info, hash_entry); | 973 | info = container_of(node, struct vis_info, hash_entry); |
969 | send_list_del(info); | 974 | batadv_send_list_del(info); |
970 | kref_put(&info->refcount, free_info); | 975 | kref_put(&info->refcount, batadv_free_info); |
971 | } | 976 | } |
972 | 977 | ||
973 | /* shutdown vis-server */ | 978 | /* shutdown vis-server */ |
@@ -980,16 +985,16 @@ void batadv_vis_quit(struct bat_priv *bat_priv) | |||
980 | 985 | ||
981 | spin_lock_bh(&bat_priv->vis_hash_lock); | 986 | spin_lock_bh(&bat_priv->vis_hash_lock); |
982 | /* properly remove, kill timers ... */ | 987 | /* properly remove, kill timers ... */ |
983 | batadv_hash_delete(bat_priv->vis_hash, free_info_ref, NULL); | 988 | batadv_hash_delete(bat_priv->vis_hash, batadv_free_info_ref, NULL); |
984 | bat_priv->vis_hash = NULL; | 989 | bat_priv->vis_hash = NULL; |
985 | bat_priv->my_vis_info = NULL; | 990 | bat_priv->my_vis_info = NULL; |
986 | spin_unlock_bh(&bat_priv->vis_hash_lock); | 991 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
987 | } | 992 | } |
988 | 993 | ||
989 | /* schedule packets for (re)transmission */ | 994 | /* schedule packets for (re)transmission */ |
990 | static void start_vis_timer(struct bat_priv *bat_priv) | 995 | static void batadv_start_vis_timer(struct bat_priv *bat_priv) |
991 | { | 996 | { |
992 | INIT_DELAYED_WORK(&bat_priv->vis_work, send_vis_packets); | 997 | INIT_DELAYED_WORK(&bat_priv->vis_work, batadv_send_vis_packets); |
993 | queue_delayed_work(batadv_event_workqueue, &bat_priv->vis_work, | 998 | queue_delayed_work(batadv_event_workqueue, &bat_priv->vis_work, |
994 | msecs_to_jiffies(VIS_INTERVAL)); | 999 | msecs_to_jiffies(VIS_INTERVAL)); |
995 | } | 1000 | } |