aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/bridge_loop_avoidance.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/batman-adv/bridge_loop_avoidance.c')
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c135
1 files changed, 64 insertions, 71 deletions
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 5aebe9327d68..30f46526cbbd 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors: 1/* Copyright (C) 2011-2013 B.A.T.M.A.N. contributors:
2 * 2 *
3 * Simon Wunderlich 3 * Simon Wunderlich
4 * 4 *
@@ -34,13 +34,14 @@
34static const uint8_t batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05}; 34static const uint8_t batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05};
35 35
36static void batadv_bla_periodic_work(struct work_struct *work); 36static void batadv_bla_periodic_work(struct work_struct *work);
37static void batadv_bla_send_announce(struct batadv_priv *bat_priv, 37static void
38 struct batadv_backbone_gw *backbone_gw); 38batadv_bla_send_announce(struct batadv_priv *bat_priv,
39 struct batadv_bla_backbone_gw *backbone_gw);
39 40
40/* return the index of the claim */ 41/* return the index of the claim */
41static inline uint32_t batadv_choose_claim(const void *data, uint32_t size) 42static inline uint32_t batadv_choose_claim(const void *data, uint32_t size)
42{ 43{
43 struct batadv_claim *claim = (struct batadv_claim *)data; 44 struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data;
44 uint32_t hash = 0; 45 uint32_t hash = 0;
45 46
46 hash = batadv_hash_bytes(hash, &claim->addr, sizeof(claim->addr)); 47 hash = batadv_hash_bytes(hash, &claim->addr, sizeof(claim->addr));
@@ -57,7 +58,7 @@ static inline uint32_t batadv_choose_claim(const void *data, uint32_t size)
57static inline uint32_t batadv_choose_backbone_gw(const void *data, 58static inline uint32_t batadv_choose_backbone_gw(const void *data,
58 uint32_t size) 59 uint32_t size)
59{ 60{
60 struct batadv_claim *claim = (struct batadv_claim *)data; 61 const struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data;
61 uint32_t hash = 0; 62 uint32_t hash = 0;
62 63
63 hash = batadv_hash_bytes(hash, &claim->addr, sizeof(claim->addr)); 64 hash = batadv_hash_bytes(hash, &claim->addr, sizeof(claim->addr));
@@ -75,9 +76,9 @@ static inline uint32_t batadv_choose_backbone_gw(const void *data,
75static int batadv_compare_backbone_gw(const struct hlist_node *node, 76static int batadv_compare_backbone_gw(const struct hlist_node *node,
76 const void *data2) 77 const void *data2)
77{ 78{
78 const void *data1 = container_of(node, struct batadv_backbone_gw, 79 const void *data1 = container_of(node, struct batadv_bla_backbone_gw,
79 hash_entry); 80 hash_entry);
80 const struct batadv_backbone_gw *gw1 = data1, *gw2 = data2; 81 const struct batadv_bla_backbone_gw *gw1 = data1, *gw2 = data2;
81 82
82 if (!batadv_compare_eth(gw1->orig, gw2->orig)) 83 if (!batadv_compare_eth(gw1->orig, gw2->orig))
83 return 0; 84 return 0;
@@ -92,9 +93,9 @@ static int batadv_compare_backbone_gw(const struct hlist_node *node,
92static int batadv_compare_claim(const struct hlist_node *node, 93static int batadv_compare_claim(const struct hlist_node *node,
93 const void *data2) 94 const void *data2)
94{ 95{
95 const void *data1 = container_of(node, struct batadv_claim, 96 const void *data1 = container_of(node, struct batadv_bla_claim,
96 hash_entry); 97 hash_entry);
97 const struct batadv_claim *cl1 = data1, *cl2 = data2; 98 const struct batadv_bla_claim *cl1 = data1, *cl2 = data2;
98 99
99 if (!batadv_compare_eth(cl1->addr, cl2->addr)) 100 if (!batadv_compare_eth(cl1->addr, cl2->addr))
100 return 0; 101 return 0;
@@ -106,7 +107,8 @@ static int batadv_compare_claim(const struct hlist_node *node,
106} 107}
107 108
108/* free a backbone gw */ 109/* free a backbone gw */
109static void batadv_backbone_gw_free_ref(struct batadv_backbone_gw *backbone_gw) 110static void
111batadv_backbone_gw_free_ref(struct batadv_bla_backbone_gw *backbone_gw)
110{ 112{
111 if (atomic_dec_and_test(&backbone_gw->refcount)) 113 if (atomic_dec_and_test(&backbone_gw->refcount))
112 kfree_rcu(backbone_gw, rcu); 114 kfree_rcu(backbone_gw, rcu);
@@ -115,16 +117,16 @@ static void batadv_backbone_gw_free_ref(struct batadv_backbone_gw *backbone_gw)
115/* finally deinitialize the claim */ 117/* finally deinitialize the claim */
116static void batadv_claim_free_rcu(struct rcu_head *rcu) 118static void batadv_claim_free_rcu(struct rcu_head *rcu)
117{ 119{
118 struct batadv_claim *claim; 120 struct batadv_bla_claim *claim;
119 121
120 claim = container_of(rcu, struct batadv_claim, rcu); 122 claim = container_of(rcu, struct batadv_bla_claim, rcu);
121 123
122 batadv_backbone_gw_free_ref(claim->backbone_gw); 124 batadv_backbone_gw_free_ref(claim->backbone_gw);
123 kfree(claim); 125 kfree(claim);
124} 126}
125 127
126/* free a claim, call claim_free_rcu if its the last reference */ 128/* free a claim, call claim_free_rcu if its the last reference */
127static void batadv_claim_free_ref(struct batadv_claim *claim) 129static void batadv_claim_free_ref(struct batadv_bla_claim *claim)
128{ 130{
129 if (atomic_dec_and_test(&claim->refcount)) 131 if (atomic_dec_and_test(&claim->refcount))
130 call_rcu(&claim->rcu, batadv_claim_free_rcu); 132 call_rcu(&claim->rcu, batadv_claim_free_rcu);
@@ -136,14 +138,15 @@ static void batadv_claim_free_ref(struct batadv_claim *claim)
136 * looks for a claim in the hash, and returns it if found 138 * looks for a claim in the hash, and returns it if found
137 * or NULL otherwise. 139 * or NULL otherwise.
138 */ 140 */
139static struct batadv_claim *batadv_claim_hash_find(struct batadv_priv *bat_priv, 141static struct batadv_bla_claim
140 struct batadv_claim *data) 142*batadv_claim_hash_find(struct batadv_priv *bat_priv,
143 struct batadv_bla_claim *data)
141{ 144{
142 struct batadv_hashtable *hash = bat_priv->bla.claim_hash; 145 struct batadv_hashtable *hash = bat_priv->bla.claim_hash;
143 struct hlist_head *head; 146 struct hlist_head *head;
144 struct hlist_node *node; 147 struct hlist_node *node;
145 struct batadv_claim *claim; 148 struct batadv_bla_claim *claim;
146 struct batadv_claim *claim_tmp = NULL; 149 struct batadv_bla_claim *claim_tmp = NULL;
147 int index; 150 int index;
148 151
149 if (!hash) 152 if (!hash)
@@ -176,15 +179,15 @@ static struct batadv_claim *batadv_claim_hash_find(struct batadv_priv *bat_priv,
176 * 179 *
177 * Returns claim if found or NULL otherwise. 180 * Returns claim if found or NULL otherwise.
178 */ 181 */
179static struct batadv_backbone_gw * 182static struct batadv_bla_backbone_gw *
180batadv_backbone_hash_find(struct batadv_priv *bat_priv, 183batadv_backbone_hash_find(struct batadv_priv *bat_priv,
181 uint8_t *addr, short vid) 184 uint8_t *addr, short vid)
182{ 185{
183 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash; 186 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
184 struct hlist_head *head; 187 struct hlist_head *head;
185 struct hlist_node *node; 188 struct hlist_node *node;
186 struct batadv_backbone_gw search_entry, *backbone_gw; 189 struct batadv_bla_backbone_gw search_entry, *backbone_gw;
187 struct batadv_backbone_gw *backbone_gw_tmp = NULL; 190 struct batadv_bla_backbone_gw *backbone_gw_tmp = NULL;
188 int index; 191 int index;
189 192
190 if (!hash) 193 if (!hash)
@@ -215,12 +218,12 @@ batadv_backbone_hash_find(struct batadv_priv *bat_priv,
215 218
216/* delete all claims for a backbone */ 219/* delete all claims for a backbone */
217static void 220static void
218batadv_bla_del_backbone_claims(struct batadv_backbone_gw *backbone_gw) 221batadv_bla_del_backbone_claims(struct batadv_bla_backbone_gw *backbone_gw)
219{ 222{
220 struct batadv_hashtable *hash; 223 struct batadv_hashtable *hash;
221 struct hlist_node *node, *node_tmp; 224 struct hlist_node *node, *node_tmp;
222 struct hlist_head *head; 225 struct hlist_head *head;
223 struct batadv_claim *claim; 226 struct batadv_bla_claim *claim;
224 int i; 227 int i;
225 spinlock_t *list_lock; /* protects write access to the hash lists */ 228 spinlock_t *list_lock; /* protects write access to the hash lists */
226 229
@@ -235,7 +238,6 @@ batadv_bla_del_backbone_claims(struct batadv_backbone_gw *backbone_gw)
235 spin_lock_bh(list_lock); 238 spin_lock_bh(list_lock);
236 hlist_for_each_entry_safe(claim, node, node_tmp, 239 hlist_for_each_entry_safe(claim, node, node_tmp,
237 head, hash_entry) { 240 head, hash_entry) {
238
239 if (claim->backbone_gw != backbone_gw) 241 if (claim->backbone_gw != backbone_gw)
240 continue; 242 continue;
241 243
@@ -338,7 +340,6 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
338 "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n", 340 "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n",
339 ethhdr->h_source, ethhdr->h_dest, vid); 341 ethhdr->h_source, ethhdr->h_dest, vid);
340 break; 342 break;
341
342 } 343 }
343 344
344 if (vid != -1) 345 if (vid != -1)
@@ -366,11 +367,11 @@ out:
366 * searches for the backbone gw or creates a new one if it could not 367 * searches for the backbone gw or creates a new one if it could not
367 * be found. 368 * be found.
368 */ 369 */
369static struct batadv_backbone_gw * 370static struct batadv_bla_backbone_gw *
370batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, 371batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig,
371 short vid, bool own_backbone) 372 short vid, bool own_backbone)
372{ 373{
373 struct batadv_backbone_gw *entry; 374 struct batadv_bla_backbone_gw *entry;
374 struct batadv_orig_node *orig_node; 375 struct batadv_orig_node *orig_node;
375 int hash_added; 376 int hash_added;
376 377
@@ -437,7 +438,7 @@ batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv,
437 struct batadv_hard_iface *primary_if, 438 struct batadv_hard_iface *primary_if,
438 short vid) 439 short vid)
439{ 440{
440 struct batadv_backbone_gw *backbone_gw; 441 struct batadv_bla_backbone_gw *backbone_gw;
441 442
442 backbone_gw = batadv_bla_get_backbone_gw(bat_priv, 443 backbone_gw = batadv_bla_get_backbone_gw(bat_priv,
443 primary_if->net_dev->dev_addr, 444 primary_if->net_dev->dev_addr,
@@ -462,8 +463,8 @@ static void batadv_bla_answer_request(struct batadv_priv *bat_priv,
462 struct hlist_node *node; 463 struct hlist_node *node;
463 struct hlist_head *head; 464 struct hlist_head *head;
464 struct batadv_hashtable *hash; 465 struct batadv_hashtable *hash;
465 struct batadv_claim *claim; 466 struct batadv_bla_claim *claim;
466 struct batadv_backbone_gw *backbone_gw; 467 struct batadv_bla_backbone_gw *backbone_gw;
467 int i; 468 int i;
468 469
469 batadv_dbg(BATADV_DBG_BLA, bat_priv, 470 batadv_dbg(BATADV_DBG_BLA, bat_priv,
@@ -502,7 +503,7 @@ static void batadv_bla_answer_request(struct batadv_priv *bat_priv,
502 * After the request, it will repeat all of his own claims and finally 503 * After the request, it will repeat all of his own claims and finally
503 * send an announcement claim with which we can check again. 504 * send an announcement claim with which we can check again.
504 */ 505 */
505static void batadv_bla_send_request(struct batadv_backbone_gw *backbone_gw) 506static void batadv_bla_send_request(struct batadv_bla_backbone_gw *backbone_gw)
506{ 507{
507 /* first, remove all old entries */ 508 /* first, remove all old entries */
508 batadv_bla_del_backbone_claims(backbone_gw); 509 batadv_bla_del_backbone_claims(backbone_gw);
@@ -528,7 +529,7 @@ static void batadv_bla_send_request(struct batadv_backbone_gw *backbone_gw)
528 * places. 529 * places.
529 */ 530 */
530static void batadv_bla_send_announce(struct batadv_priv *bat_priv, 531static void batadv_bla_send_announce(struct batadv_priv *bat_priv,
531 struct batadv_backbone_gw *backbone_gw) 532 struct batadv_bla_backbone_gw *backbone_gw)
532{ 533{
533 uint8_t mac[ETH_ALEN]; 534 uint8_t mac[ETH_ALEN];
534 __be16 crc; 535 __be16 crc;
@@ -539,7 +540,6 @@ static void batadv_bla_send_announce(struct batadv_priv *bat_priv,
539 540
540 batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid, 541 batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid,
541 BATADV_CLAIM_TYPE_ANNOUNCE); 542 BATADV_CLAIM_TYPE_ANNOUNCE);
542
543} 543}
544 544
545/** 545/**
@@ -551,10 +551,10 @@ static void batadv_bla_send_announce(struct batadv_priv *bat_priv,
551 */ 551 */
552static void batadv_bla_add_claim(struct batadv_priv *bat_priv, 552static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
553 const uint8_t *mac, const short vid, 553 const uint8_t *mac, const short vid,
554 struct batadv_backbone_gw *backbone_gw) 554 struct batadv_bla_backbone_gw *backbone_gw)
555{ 555{
556 struct batadv_claim *claim; 556 struct batadv_bla_claim *claim;
557 struct batadv_claim search_claim; 557 struct batadv_bla_claim search_claim;
558 int hash_added; 558 int hash_added;
559 559
560 memcpy(search_claim.addr, mac, ETH_ALEN); 560 memcpy(search_claim.addr, mac, ETH_ALEN);
@@ -598,7 +598,6 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
598 598
599 claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN); 599 claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
600 batadv_backbone_gw_free_ref(claim->backbone_gw); 600 batadv_backbone_gw_free_ref(claim->backbone_gw);
601
602 } 601 }
603 /* set (new) backbone gw */ 602 /* set (new) backbone gw */
604 atomic_inc(&backbone_gw->refcount); 603 atomic_inc(&backbone_gw->refcount);
@@ -617,7 +616,7 @@ claim_free_ref:
617static void batadv_bla_del_claim(struct batadv_priv *bat_priv, 616static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
618 const uint8_t *mac, const short vid) 617 const uint8_t *mac, const short vid)
619{ 618{
620 struct batadv_claim search_claim, *claim; 619 struct batadv_bla_claim search_claim, *claim;
621 620
622 memcpy(search_claim.addr, mac, ETH_ALEN); 621 memcpy(search_claim.addr, mac, ETH_ALEN);
623 search_claim.vid = vid; 622 search_claim.vid = vid;
@@ -643,7 +642,7 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv,
643 uint8_t *an_addr, uint8_t *backbone_addr, 642 uint8_t *an_addr, uint8_t *backbone_addr,
644 short vid) 643 short vid)
645{ 644{
646 struct batadv_backbone_gw *backbone_gw; 645 struct batadv_bla_backbone_gw *backbone_gw;
647 uint16_t crc; 646 uint16_t crc;
648 647
649 if (memcmp(an_addr, batadv_announce_mac, 4) != 0) 648 if (memcmp(an_addr, batadv_announce_mac, 4) != 0)
@@ -661,12 +660,12 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv,
661 crc = ntohs(*((__be16 *)(&an_addr[4]))); 660 crc = ntohs(*((__be16 *)(&an_addr[4])));
662 661
663 batadv_dbg(BATADV_DBG_BLA, bat_priv, 662 batadv_dbg(BATADV_DBG_BLA, bat_priv,
664 "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n", 663 "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %#.4x\n",
665 vid, backbone_gw->orig, crc); 664 vid, backbone_gw->orig, crc);
666 665
667 if (backbone_gw->crc != crc) { 666 if (backbone_gw->crc != crc) {
668 batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv, 667 batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
669 "handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n", 668 "handle_announce(): CRC FAILED for %pM/%d (my = %#.4x, sent = %#.4x)\n",
670 backbone_gw->orig, backbone_gw->vid, 669 backbone_gw->orig, backbone_gw->vid,
671 backbone_gw->crc, crc); 670 backbone_gw->crc, crc);
672 671
@@ -715,7 +714,7 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv,
715 uint8_t *backbone_addr, 714 uint8_t *backbone_addr,
716 uint8_t *claim_addr, short vid) 715 uint8_t *claim_addr, short vid)
717{ 716{
718 struct batadv_backbone_gw *backbone_gw; 717 struct batadv_bla_backbone_gw *backbone_gw;
719 718
720 /* unclaim in any case if it is our own */ 719 /* unclaim in any case if it is our own */
721 if (primary_if && batadv_compare_eth(backbone_addr, 720 if (primary_if && batadv_compare_eth(backbone_addr,
@@ -744,7 +743,7 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv,
744 uint8_t *backbone_addr, uint8_t *claim_addr, 743 uint8_t *backbone_addr, uint8_t *claim_addr,
745 short vid) 744 short vid)
746{ 745{
747 struct batadv_backbone_gw *backbone_gw; 746 struct batadv_bla_backbone_gw *backbone_gw;
748 747
749 /* register the gateway if not yet available, and add the claim. */ 748 /* register the gateway if not yet available, and add the claim. */
750 749
@@ -835,7 +834,7 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv,
835 /* if our mesh friends mac is bigger, use it for ourselves. */ 834 /* if our mesh friends mac is bigger, use it for ourselves. */
836 if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) { 835 if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) {
837 batadv_dbg(BATADV_DBG_BLA, bat_priv, 836 batadv_dbg(BATADV_DBG_BLA, bat_priv,
838 "taking other backbones claim group: %04x\n", 837 "taking other backbones claim group: %#.4x\n",
839 ntohs(bla_dst->group)); 838 ntohs(bla_dst->group));
840 bla_dst_own->group = bla_dst->group; 839 bla_dst_own->group = bla_dst->group;
841 } 840 }
@@ -958,7 +957,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
958 */ 957 */
959static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now) 958static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now)
960{ 959{
961 struct batadv_backbone_gw *backbone_gw; 960 struct batadv_bla_backbone_gw *backbone_gw;
962 struct hlist_node *node, *node_tmp; 961 struct hlist_node *node, *node_tmp;
963 struct hlist_head *head; 962 struct hlist_head *head;
964 struct batadv_hashtable *hash; 963 struct batadv_hashtable *hash;
@@ -1013,7 +1012,7 @@ static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
1013 struct batadv_hard_iface *primary_if, 1012 struct batadv_hard_iface *primary_if,
1014 int now) 1013 int now)
1015{ 1014{
1016 struct batadv_claim *claim; 1015 struct batadv_bla_claim *claim;
1017 struct hlist_node *node; 1016 struct hlist_node *node;
1018 struct hlist_head *head; 1017 struct hlist_head *head;
1019 struct batadv_hashtable *hash; 1018 struct batadv_hashtable *hash;
@@ -1062,7 +1061,7 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
1062 struct batadv_hard_iface *primary_if, 1061 struct batadv_hard_iface *primary_if,
1063 struct batadv_hard_iface *oldif) 1062 struct batadv_hard_iface *oldif)
1064{ 1063{
1065 struct batadv_backbone_gw *backbone_gw; 1064 struct batadv_bla_backbone_gw *backbone_gw;
1066 struct hlist_node *node; 1065 struct hlist_node *node;
1067 struct hlist_head *head; 1066 struct hlist_head *head;
1068 struct batadv_hashtable *hash; 1067 struct batadv_hashtable *hash;
@@ -1104,16 +1103,6 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
1104 } 1103 }
1105} 1104}
1106 1105
1107
1108
1109/* (re)start the timer */
1110static void batadv_bla_start_timer(struct batadv_priv *bat_priv)
1111{
1112 INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
1113 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
1114 msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
1115}
1116
1117/* periodic work to do: 1106/* periodic work to do:
1118 * * purge structures when they are too old 1107 * * purge structures when they are too old
1119 * * send announcements 1108 * * send announcements
@@ -1125,7 +1114,7 @@ static void batadv_bla_periodic_work(struct work_struct *work)
1125 struct batadv_priv_bla *priv_bla; 1114 struct batadv_priv_bla *priv_bla;
1126 struct hlist_node *node; 1115 struct hlist_node *node;
1127 struct hlist_head *head; 1116 struct hlist_head *head;
1128 struct batadv_backbone_gw *backbone_gw; 1117 struct batadv_bla_backbone_gw *backbone_gw;
1129 struct batadv_hashtable *hash; 1118 struct batadv_hashtable *hash;
1130 struct batadv_hard_iface *primary_if; 1119 struct batadv_hard_iface *primary_if;
1131 int i; 1120 int i;
@@ -1184,7 +1173,8 @@ out:
1184 if (primary_if) 1173 if (primary_if)
1185 batadv_hardif_free_ref(primary_if); 1174 batadv_hardif_free_ref(primary_if);
1186 1175
1187 batadv_bla_start_timer(bat_priv); 1176 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
1177 msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
1188} 1178}
1189 1179
1190/* The hash for claim and backbone hash receive the same key because they 1180/* The hash for claim and backbone hash receive the same key because they
@@ -1242,7 +1232,10 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
1242 1232
1243 batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n"); 1233 batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n");
1244 1234
1245 batadv_bla_start_timer(bat_priv); 1235 INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
1236
1237 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
1238 msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
1246 return 0; 1239 return 0;
1247} 1240}
1248 1241
@@ -1330,7 +1323,7 @@ int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig)
1330 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash; 1323 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
1331 struct hlist_head *head; 1324 struct hlist_head *head;
1332 struct hlist_node *node; 1325 struct hlist_node *node;
1333 struct batadv_backbone_gw *backbone_gw; 1326 struct batadv_bla_backbone_gw *backbone_gw;
1334 int i; 1327 int i;
1335 1328
1336 if (!atomic_read(&bat_priv->bridge_loop_avoidance)) 1329 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
@@ -1371,7 +1364,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
1371{ 1364{
1372 struct ethhdr *ethhdr; 1365 struct ethhdr *ethhdr;
1373 struct vlan_ethhdr *vhdr; 1366 struct vlan_ethhdr *vhdr;
1374 struct batadv_backbone_gw *backbone_gw; 1367 struct batadv_bla_backbone_gw *backbone_gw;
1375 short vid = -1; 1368 short vid = -1;
1376 1369
1377 if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance)) 1370 if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance))
@@ -1442,7 +1435,7 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid,
1442 bool is_bcast) 1435 bool is_bcast)
1443{ 1436{
1444 struct ethhdr *ethhdr; 1437 struct ethhdr *ethhdr;
1445 struct batadv_claim search_claim, *claim = NULL; 1438 struct batadv_bla_claim search_claim, *claim = NULL;
1446 struct batadv_hard_iface *primary_if; 1439 struct batadv_hard_iface *primary_if;
1447 int ret; 1440 int ret;
1448 1441
@@ -1536,7 +1529,7 @@ out:
1536int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid) 1529int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid)
1537{ 1530{
1538 struct ethhdr *ethhdr; 1531 struct ethhdr *ethhdr;
1539 struct batadv_claim search_claim, *claim = NULL; 1532 struct batadv_bla_claim search_claim, *claim = NULL;
1540 struct batadv_hard_iface *primary_if; 1533 struct batadv_hard_iface *primary_if;
1541 int ret = 0; 1534 int ret = 0;
1542 1535
@@ -1612,7 +1605,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
1612 struct net_device *net_dev = (struct net_device *)seq->private; 1605 struct net_device *net_dev = (struct net_device *)seq->private;
1613 struct batadv_priv *bat_priv = netdev_priv(net_dev); 1606 struct batadv_priv *bat_priv = netdev_priv(net_dev);
1614 struct batadv_hashtable *hash = bat_priv->bla.claim_hash; 1607 struct batadv_hashtable *hash = bat_priv->bla.claim_hash;
1615 struct batadv_claim *claim; 1608 struct batadv_bla_claim *claim;
1616 struct batadv_hard_iface *primary_if; 1609 struct batadv_hard_iface *primary_if;
1617 struct hlist_node *node; 1610 struct hlist_node *node;
1618 struct hlist_head *head; 1611 struct hlist_head *head;
@@ -1626,10 +1619,10 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
1626 1619
1627 primary_addr = primary_if->net_dev->dev_addr; 1620 primary_addr = primary_if->net_dev->dev_addr;
1628 seq_printf(seq, 1621 seq_printf(seq,
1629 "Claims announced for the mesh %s (orig %pM, group id %04x)\n", 1622 "Claims announced for the mesh %s (orig %pM, group id %#.4x)\n",
1630 net_dev->name, primary_addr, 1623 net_dev->name, primary_addr,
1631 ntohs(bat_priv->bla.claim_dest.group)); 1624 ntohs(bat_priv->bla.claim_dest.group));
1632 seq_printf(seq, " %-17s %-5s %-17s [o] (%-4s)\n", 1625 seq_printf(seq, " %-17s %-5s %-17s [o] (%-6s)\n",
1633 "Client", "VID", "Originator", "CRC"); 1626 "Client", "VID", "Originator", "CRC");
1634 for (i = 0; i < hash->size; i++) { 1627 for (i = 0; i < hash->size; i++) {
1635 head = &hash->table[i]; 1628 head = &hash->table[i];
@@ -1638,7 +1631,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
1638 hlist_for_each_entry_rcu(claim, node, head, hash_entry) { 1631 hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
1639 is_own = batadv_compare_eth(claim->backbone_gw->orig, 1632 is_own = batadv_compare_eth(claim->backbone_gw->orig,
1640 primary_addr); 1633 primary_addr);
1641 seq_printf(seq, " * %pM on % 5d by %pM [%c] (%04x)\n", 1634 seq_printf(seq, " * %pM on % 5d by %pM [%c] (%#.4x)\n",
1642 claim->addr, claim->vid, 1635 claim->addr, claim->vid,
1643 claim->backbone_gw->orig, 1636 claim->backbone_gw->orig,
1644 (is_own ? 'x' : ' '), 1637 (is_own ? 'x' : ' '),
@@ -1657,7 +1650,7 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
1657 struct net_device *net_dev = (struct net_device *)seq->private; 1650 struct net_device *net_dev = (struct net_device *)seq->private;
1658 struct batadv_priv *bat_priv = netdev_priv(net_dev); 1651 struct batadv_priv *bat_priv = netdev_priv(net_dev);
1659 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash; 1652 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
1660 struct batadv_backbone_gw *backbone_gw; 1653 struct batadv_bla_backbone_gw *backbone_gw;
1661 struct batadv_hard_iface *primary_if; 1654 struct batadv_hard_iface *primary_if;
1662 struct hlist_node *node; 1655 struct hlist_node *node;
1663 struct hlist_head *head; 1656 struct hlist_head *head;
@@ -1672,10 +1665,10 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
1672 1665
1673 primary_addr = primary_if->net_dev->dev_addr; 1666 primary_addr = primary_if->net_dev->dev_addr;
1674 seq_printf(seq, 1667 seq_printf(seq,
1675 "Backbones announced for the mesh %s (orig %pM, group id %04x)\n", 1668 "Backbones announced for the mesh %s (orig %pM, group id %#.4x)\n",
1676 net_dev->name, primary_addr, 1669 net_dev->name, primary_addr,
1677 ntohs(bat_priv->bla.claim_dest.group)); 1670 ntohs(bat_priv->bla.claim_dest.group));
1678 seq_printf(seq, " %-17s %-5s %-9s (%-4s)\n", 1671 seq_printf(seq, " %-17s %-5s %-9s (%-6s)\n",
1679 "Originator", "VID", "last seen", "CRC"); 1672 "Originator", "VID", "last seen", "CRC");
1680 for (i = 0; i < hash->size; i++) { 1673 for (i = 0; i < hash->size; i++) {
1681 head = &hash->table[i]; 1674 head = &hash->table[i];
@@ -1693,7 +1686,7 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
1693 continue; 1686 continue;
1694 1687
1695 seq_printf(seq, 1688 seq_printf(seq,
1696 " * %pM on % 5d % 4i.%03is (%04x)\n", 1689 " * %pM on % 5d % 4i.%03is (%#.4x)\n",
1697 backbone_gw->orig, backbone_gw->vid, 1690 backbone_gw->orig, backbone_gw->vid,
1698 secs, msecs, backbone_gw->crc); 1691 secs, msecs, backbone_gw->crc);
1699 } 1692 }