diff options
author | Sven Eckelmann <sven@narfation.org> | 2012-06-05 16:31:30 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-07-01 16:47:21 -0400 |
commit | 96412690116afcc1b2705615b5a7c8dc6c5e905f (patch) | |
tree | 0eb2a1a557e2997175b27f3ab925bbdc29ece54d /net/batman-adv/vis.c | |
parent | b4d66b877bc21ce907938bfd027dfe016617fac0 (diff) |
batman-adv: Prefix packet structs with batadv_
Reported-by: Martin Hundebøll <martin@hundeboll.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/vis.c')
-rw-r--r-- | net/batman-adv/vis.c | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index c1fafa3b172f..309493d9128a 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
@@ -53,12 +53,12 @@ static void batadv_free_info(struct kref *ref) | |||
53 | static int batadv_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 batadv_vis_packet *p1, *p2; |
57 | 57 | ||
58 | d1 = container_of(node, struct vis_info, hash_entry); | 58 | d1 = container_of(node, struct vis_info, hash_entry); |
59 | d2 = data2; | 59 | d2 = data2; |
60 | p1 = (struct vis_packet *)d1->skb_packet->data; | 60 | p1 = (struct batadv_vis_packet *)d1->skb_packet->data; |
61 | p2 = (struct vis_packet *)d2->skb_packet->data; | 61 | p2 = (struct batadv_vis_packet *)d2->skb_packet->data; |
62 | return batadv_compare_eth(p1->vis_orig, p2->vis_orig); | 62 | return batadv_compare_eth(p1->vis_orig, p2->vis_orig); |
63 | } | 63 | } |
64 | 64 | ||
@@ -68,12 +68,12 @@ static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2) | |||
68 | static uint32_t batadv_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 batadv_vis_packet *packet; |
72 | const unsigned char *key; | 72 | const unsigned char *key; |
73 | uint32_t hash = 0; | 73 | uint32_t hash = 0; |
74 | size_t i; | 74 | size_t i; |
75 | 75 | ||
76 | packet = (struct vis_packet *)vis_info->skb_packet->data; | 76 | packet = (struct batadv_vis_packet *)vis_info->skb_packet->data; |
77 | key = packet->vis_orig; | 77 | key = packet->vis_orig; |
78 | for (i = 0; i < ETH_ALEN; i++) { | 78 | for (i = 0; i < ETH_ALEN; i++) { |
79 | hash += key[i]; | 79 | hash += key[i]; |
@@ -169,7 +169,7 @@ static ssize_t batadv_vis_data_read_entry(struct seq_file *seq, | |||
169 | } | 169 | } |
170 | 170 | ||
171 | static void batadv_vis_data_insert_interfaces(struct hlist_head *list, | 171 | static void batadv_vis_data_insert_interfaces(struct hlist_head *list, |
172 | struct vis_packet *packet, | 172 | struct batadv_vis_packet *packet, |
173 | struct vis_info_entry *entries) | 173 | struct vis_info_entry *entries) |
174 | { | 174 | { |
175 | int i; | 175 | int i; |
@@ -187,7 +187,7 @@ static void batadv_vis_data_insert_interfaces(struct hlist_head *list, | |||
187 | 187 | ||
188 | static void batadv_vis_data_read_entries(struct seq_file *seq, | 188 | static void batadv_vis_data_read_entries(struct seq_file *seq, |
189 | struct hlist_head *list, | 189 | struct hlist_head *list, |
190 | struct vis_packet *packet, | 190 | struct batadv_vis_packet *packet, |
191 | struct vis_info_entry *entries) | 191 | struct vis_info_entry *entries) |
192 | { | 192 | { |
193 | int i; | 193 | int i; |
@@ -214,7 +214,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq, | |||
214 | { | 214 | { |
215 | struct hlist_node *node; | 215 | struct hlist_node *node; |
216 | struct vis_info *info; | 216 | struct vis_info *info; |
217 | struct vis_packet *packet; | 217 | struct batadv_vis_packet *packet; |
218 | uint8_t *entries_pos; | 218 | uint8_t *entries_pos; |
219 | struct vis_info_entry *entries; | 219 | struct vis_info_entry *entries; |
220 | struct if_list_entry *entry; | 220 | struct if_list_entry *entry; |
@@ -223,7 +223,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq, | |||
223 | HLIST_HEAD(vis_if_list); | 223 | HLIST_HEAD(vis_if_list); |
224 | 224 | ||
225 | hlist_for_each_entry_rcu(info, node, head, hash_entry) { | 225 | hlist_for_each_entry_rcu(info, node, head, hash_entry) { |
226 | packet = (struct vis_packet *)info->skb_packet->data; | 226 | packet = (struct batadv_vis_packet *)info->skb_packet->data; |
227 | entries_pos = (uint8_t *)packet + sizeof(*packet); | 227 | entries_pos = (uint8_t *)packet + sizeof(*packet); |
228 | entries = (struct vis_info_entry *)entries_pos; | 228 | entries = (struct vis_info_entry *)entries_pos; |
229 | 229 | ||
@@ -334,15 +334,17 @@ static int batadv_recv_list_is_in(struct bat_priv *bat_priv, | |||
334 | * is newer than old entries in the hash. | 334 | * is newer than old entries in the hash. |
335 | */ | 335 | */ |
336 | static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, | 336 | static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, |
337 | struct vis_packet *vis_packet, | 337 | struct batadv_vis_packet *vis_packet, |
338 | int vis_info_len, int *is_new, | 338 | int vis_info_len, int *is_new, |
339 | int make_broadcast) | 339 | int make_broadcast) |
340 | { | 340 | { |
341 | struct vis_info *info, *old_info; | 341 | struct vis_info *info, *old_info; |
342 | struct vis_packet *search_packet, *old_packet; | 342 | struct batadv_vis_packet *search_packet, *old_packet; |
343 | struct vis_info search_elem; | 343 | struct vis_info search_elem; |
344 | struct vis_packet *packet; | 344 | struct batadv_vis_packet *packet; |
345 | struct sk_buff *tmp_skb; | ||
345 | int hash_added; | 346 | int hash_added; |
347 | size_t len; | ||
346 | 348 | ||
347 | *is_new = 0; | 349 | *is_new = 0; |
348 | /* sanity check */ | 350 | /* sanity check */ |
@@ -353,15 +355,17 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, | |||
353 | search_elem.skb_packet = dev_alloc_skb(sizeof(*search_packet)); | 355 | search_elem.skb_packet = dev_alloc_skb(sizeof(*search_packet)); |
354 | if (!search_elem.skb_packet) | 356 | if (!search_elem.skb_packet) |
355 | return NULL; | 357 | return NULL; |
356 | search_packet = (struct vis_packet *)skb_put(search_elem.skb_packet, | 358 | len = sizeof(*search_packet); |
357 | sizeof(*search_packet)); | 359 | tmp_skb = search_elem.skb_packet; |
360 | search_packet = (struct batadv_vis_packet *)skb_put(tmp_skb, len); | ||
358 | 361 | ||
359 | memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN); | 362 | memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN); |
360 | old_info = batadv_vis_hash_find(bat_priv, &search_elem); | 363 | old_info = batadv_vis_hash_find(bat_priv, &search_elem); |
361 | kfree_skb(search_elem.skb_packet); | 364 | kfree_skb(search_elem.skb_packet); |
362 | 365 | ||
363 | if (old_info) { | 366 | if (old_info) { |
364 | old_packet = (struct vis_packet *)old_info->skb_packet->data; | 367 | tmp_skb = old_info->skb_packet; |
368 | old_packet = (struct batadv_vis_packet *)tmp_skb->data; | ||
365 | if (!batadv_seq_after(ntohl(vis_packet->seqno), | 369 | if (!batadv_seq_after(ntohl(vis_packet->seqno), |
366 | ntohl(old_packet->seqno))) { | 370 | ntohl(old_packet->seqno))) { |
367 | if (old_packet->seqno == vis_packet->seqno) { | 371 | if (old_packet->seqno == vis_packet->seqno) { |
@@ -385,22 +389,21 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, | |||
385 | if (!info) | 389 | if (!info) |
386 | return NULL; | 390 | return NULL; |
387 | 391 | ||
388 | info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len + | 392 | len = sizeof(*packet) + vis_info_len; |
389 | ETH_HLEN); | 393 | info->skb_packet = dev_alloc_skb(len + ETH_HLEN); |
390 | if (!info->skb_packet) { | 394 | if (!info->skb_packet) { |
391 | kfree(info); | 395 | kfree(info); |
392 | return NULL; | 396 | return NULL; |
393 | } | 397 | } |
394 | skb_reserve(info->skb_packet, ETH_HLEN); | 398 | skb_reserve(info->skb_packet, ETH_HLEN); |
395 | packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet) | 399 | packet = (struct batadv_vis_packet *)skb_put(info->skb_packet, len); |
396 | + vis_info_len); | ||
397 | 400 | ||
398 | kref_init(&info->refcount); | 401 | kref_init(&info->refcount); |
399 | INIT_LIST_HEAD(&info->send_list); | 402 | INIT_LIST_HEAD(&info->send_list); |
400 | INIT_LIST_HEAD(&info->recv_list); | 403 | INIT_LIST_HEAD(&info->recv_list); |
401 | info->first_seen = jiffies; | 404 | info->first_seen = jiffies; |
402 | info->bat_priv = bat_priv; | 405 | info->bat_priv = bat_priv; |
403 | memcpy(packet, vis_packet, sizeof(*packet) + vis_info_len); | 406 | memcpy(packet, vis_packet, len); |
404 | 407 | ||
405 | /* initialize and add new packet. */ | 408 | /* initialize and add new packet. */ |
406 | *is_new = 1; | 409 | *is_new = 1; |
@@ -430,7 +433,7 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, | |||
430 | 433 | ||
431 | /* handle the server sync packet, forward if needed. */ | 434 | /* handle the server sync packet, forward if needed. */ |
432 | void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, | 435 | void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, |
433 | struct vis_packet *vis_packet, | 436 | struct batadv_vis_packet *vis_packet, |
434 | int vis_info_len) | 437 | int vis_info_len) |
435 | { | 438 | { |
436 | struct vis_info *info; | 439 | struct vis_info *info; |
@@ -456,11 +459,11 @@ end: | |||
456 | 459 | ||
457 | /* handle an incoming client update packet and schedule forward if needed. */ | 460 | /* handle an incoming client update packet and schedule forward if needed. */ |
458 | void batadv_receive_client_update_packet(struct bat_priv *bat_priv, | 461 | void batadv_receive_client_update_packet(struct bat_priv *bat_priv, |
459 | struct vis_packet *vis_packet, | 462 | struct batadv_vis_packet *vis_packet, |
460 | int vis_info_len) | 463 | int vis_info_len) |
461 | { | 464 | { |
462 | struct vis_info *info; | 465 | struct vis_info *info; |
463 | struct vis_packet *packet; | 466 | struct batadv_vis_packet *packet; |
464 | int is_new; | 467 | int is_new; |
465 | int vis_server = atomic_read(&bat_priv->vis_mode); | 468 | int vis_server = atomic_read(&bat_priv->vis_mode); |
466 | int are_target = 0; | 469 | int are_target = 0; |
@@ -482,7 +485,7 @@ void batadv_receive_client_update_packet(struct bat_priv *bat_priv, | |||
482 | goto end; | 485 | goto end; |
483 | /* note that outdated packets will be dropped at this point. */ | 486 | /* note that outdated packets will be dropped at this point. */ |
484 | 487 | ||
485 | packet = (struct vis_packet *)info->skb_packet->data; | 488 | packet = (struct batadv_vis_packet *)info->skb_packet->data; |
486 | 489 | ||
487 | /* send only if we're the target server or ... */ | 490 | /* send only if we're the target server or ... */ |
488 | if (are_target && is_new) { | 491 | if (are_target && is_new) { |
@@ -511,11 +514,11 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv, | |||
511 | struct hlist_node *node; | 514 | struct hlist_node *node; |
512 | struct hlist_head *head; | 515 | struct hlist_head *head; |
513 | struct orig_node *orig_node; | 516 | struct orig_node *orig_node; |
514 | struct vis_packet *packet; | 517 | struct batadv_vis_packet *packet; |
515 | int best_tq = -1; | 518 | int best_tq = -1; |
516 | uint32_t i; | 519 | uint32_t i; |
517 | 520 | ||
518 | packet = (struct vis_packet *)info->skb_packet->data; | 521 | packet = (struct batadv_vis_packet *)info->skb_packet->data; |
519 | 522 | ||
520 | for (i = 0; i < hash->size; i++) { | 523 | for (i = 0; i < hash->size; i++) { |
521 | head = &hash->table[i]; | 524 | head = &hash->table[i]; |
@@ -543,10 +546,10 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv, | |||
543 | /* Return true if the vis packet is full. */ | 546 | /* Return true if the vis packet is full. */ |
544 | static bool batadv_vis_packet_full(const struct vis_info *info) | 547 | static bool batadv_vis_packet_full(const struct vis_info *info) |
545 | { | 548 | { |
546 | const struct vis_packet *packet; | 549 | const struct batadv_vis_packet *packet; |
547 | size_t num_items; | 550 | size_t num_items; |
548 | 551 | ||
549 | packet = (struct vis_packet *)info->skb_packet->data; | 552 | packet = (struct batadv_vis_packet *)info->skb_packet->data; |
550 | num_items = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry); | 553 | num_items = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry); |
551 | 554 | ||
552 | if (num_items < packet->entries + 1) | 555 | if (num_items < packet->entries + 1) |
@@ -565,13 +568,14 @@ static int batadv_generate_vis_packet(struct bat_priv *bat_priv) | |||
565 | struct orig_node *orig_node; | 568 | struct orig_node *orig_node; |
566 | struct neigh_node *router; | 569 | struct neigh_node *router; |
567 | struct vis_info *info = bat_priv->my_vis_info; | 570 | struct vis_info *info = bat_priv->my_vis_info; |
568 | struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data; | 571 | struct batadv_vis_packet *packet; |
569 | struct vis_info_entry *entry; | 572 | struct vis_info_entry *entry; |
570 | struct tt_common_entry *tt_common_entry; | 573 | struct tt_common_entry *tt_common_entry; |
571 | int best_tq = -1; | 574 | int best_tq = -1; |
572 | uint32_t i; | 575 | uint32_t i; |
573 | 576 | ||
574 | info->first_seen = jiffies; | 577 | info->first_seen = jiffies; |
578 | packet = (struct batadv_vis_packet *)info->skb_packet->data; | ||
575 | packet->vis_type = atomic_read(&bat_priv->vis_mode); | 579 | packet->vis_type = atomic_read(&bat_priv->vis_mode); |
576 | 580 | ||
577 | memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN); | 581 | memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN); |
@@ -691,14 +695,14 @@ static void batadv_broadcast_vis_packet(struct bat_priv *bat_priv, | |||
691 | struct hlist_node *node; | 695 | struct hlist_node *node; |
692 | struct hlist_head *head; | 696 | struct hlist_head *head; |
693 | struct orig_node *orig_node; | 697 | struct orig_node *orig_node; |
694 | struct vis_packet *packet; | 698 | struct batadv_vis_packet *packet; |
695 | struct sk_buff *skb; | 699 | struct sk_buff *skb; |
696 | struct hard_iface *hard_iface; | 700 | struct hard_iface *hard_iface; |
697 | uint8_t dstaddr[ETH_ALEN]; | 701 | uint8_t dstaddr[ETH_ALEN]; |
698 | uint32_t i; | 702 | uint32_t i; |
699 | 703 | ||
700 | 704 | ||
701 | packet = (struct vis_packet *)info->skb_packet->data; | 705 | packet = (struct batadv_vis_packet *)info->skb_packet->data; |
702 | 706 | ||
703 | /* send to all routers in range. */ | 707 | /* send to all routers in range. */ |
704 | for (i = 0; i < hash->size; i++) { | 708 | for (i = 0; i < hash->size; i++) { |
@@ -745,9 +749,9 @@ static void batadv_unicast_vis_packet(struct bat_priv *bat_priv, | |||
745 | struct orig_node *orig_node; | 749 | struct orig_node *orig_node; |
746 | struct neigh_node *router = NULL; | 750 | struct neigh_node *router = NULL; |
747 | struct sk_buff *skb; | 751 | struct sk_buff *skb; |
748 | struct vis_packet *packet; | 752 | struct batadv_vis_packet *packet; |
749 | 753 | ||
750 | packet = (struct vis_packet *)info->skb_packet->data; | 754 | packet = (struct batadv_vis_packet *)info->skb_packet->data; |
751 | 755 | ||
752 | orig_node = batadv_orig_hash_find(bat_priv, packet->target_orig); | 756 | orig_node = batadv_orig_hash_find(bat_priv, packet->target_orig); |
753 | if (!orig_node) | 757 | if (!orig_node) |
@@ -773,13 +777,13 @@ static void batadv_send_vis_packet(struct bat_priv *bat_priv, | |||
773 | struct vis_info *info) | 777 | struct vis_info *info) |
774 | { | 778 | { |
775 | struct hard_iface *primary_if; | 779 | struct hard_iface *primary_if; |
776 | struct vis_packet *packet; | 780 | struct batadv_vis_packet *packet; |
777 | 781 | ||
778 | primary_if = batadv_primary_if_get_selected(bat_priv); | 782 | primary_if = batadv_primary_if_get_selected(bat_priv); |
779 | if (!primary_if) | 783 | if (!primary_if) |
780 | goto out; | 784 | goto out; |
781 | 785 | ||
782 | packet = (struct vis_packet *)info->skb_packet->data; | 786 | packet = (struct batadv_vis_packet *)info->skb_packet->data; |
783 | if (packet->header.ttl < 2) { | 787 | if (packet->header.ttl < 2) { |
784 | pr_debug("Error - can't send vis packet: ttl exceeded\n"); | 788 | pr_debug("Error - can't send vis packet: ttl exceeded\n"); |
785 | goto out; | 789 | goto out; |
@@ -838,10 +842,11 @@ static void batadv_send_vis_packets(struct work_struct *work) | |||
838 | */ | 842 | */ |
839 | int batadv_vis_init(struct bat_priv *bat_priv) | 843 | int batadv_vis_init(struct bat_priv *bat_priv) |
840 | { | 844 | { |
841 | struct vis_packet *packet; | 845 | struct batadv_vis_packet *packet; |
842 | int hash_added; | 846 | int hash_added; |
843 | unsigned int len; | 847 | unsigned int len; |
844 | unsigned long first_seen; | 848 | unsigned long first_seen; |
849 | struct sk_buff *tmp_skb; | ||
845 | 850 | ||
846 | if (bat_priv->vis_hash) | 851 | if (bat_priv->vis_hash) |
847 | return 0; | 852 | return 0; |
@@ -864,8 +869,8 @@ int batadv_vis_init(struct bat_priv *bat_priv) | |||
864 | goto free_info; | 869 | goto free_info; |
865 | 870 | ||
866 | skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN); | 871 | skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN); |
867 | packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet, | 872 | tmp_skb = bat_priv->my_vis_info->skb_packet; |
868 | sizeof(*packet)); | 873 | packet = (struct batadv_vis_packet *)skb_put(tmp_skb, sizeof(*packet)); |
869 | 874 | ||
870 | /* prefill the vis info */ | 875 | /* prefill the vis info */ |
871 | first_seen = jiffies - msecs_to_jiffies(BATADV_VIS_INTERVAL); | 876 | first_seen = jiffies - msecs_to_jiffies(BATADV_VIS_INTERVAL); |