aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/originator.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/batman-adv/originator.c')
-rw-r--r--net/batman-adv/originator.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 40a30bbcd14..f3c3f620d19 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -37,6 +37,14 @@ static void start_purge_timer(struct bat_priv *bat_priv)
37 queue_delayed_work(bat_event_workqueue, &bat_priv->orig_work, 1 * HZ); 37 queue_delayed_work(bat_event_workqueue, &bat_priv->orig_work, 1 * HZ);
38} 38}
39 39
40/* returns 1 if they are the same originator */
41static int compare_orig(const struct hlist_node *node, const void *data2)
42{
43 const void *data1 = container_of(node, struct orig_node, hash_entry);
44
45 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
46}
47
40int originator_init(struct bat_priv *bat_priv) 48int originator_init(struct bat_priv *bat_priv)
41{ 49{
42 if (bat_priv->orig_hash) 50 if (bat_priv->orig_hash)
@@ -77,7 +85,7 @@ struct neigh_node *orig_node_get_router(struct orig_node *orig_node)
77 85
78struct neigh_node *create_neighbor(struct orig_node *orig_node, 86struct neigh_node *create_neighbor(struct orig_node *orig_node,
79 struct orig_node *orig_neigh_node, 87 struct orig_node *orig_neigh_node,
80 uint8_t *neigh, 88 const uint8_t *neigh,
81 struct hard_iface *if_incoming) 89 struct hard_iface *if_incoming)
82{ 90{
83 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 91 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
@@ -86,7 +94,7 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node,
86 bat_dbg(DBG_BATMAN, bat_priv, 94 bat_dbg(DBG_BATMAN, bat_priv,
87 "Creating new last-hop neighbor of originator\n"); 95 "Creating new last-hop neighbor of originator\n");
88 96
89 neigh_node = kzalloc(sizeof(struct neigh_node), GFP_ATOMIC); 97 neigh_node = kzalloc(sizeof(*neigh_node), GFP_ATOMIC);
90 if (!neigh_node) 98 if (!neigh_node)
91 return NULL; 99 return NULL;
92 100
@@ -137,6 +145,7 @@ static void orig_node_free_rcu(struct rcu_head *rcu)
137 tt_global_del_orig(orig_node->bat_priv, orig_node, 145 tt_global_del_orig(orig_node->bat_priv, orig_node,
138 "originator timed out"); 146 "originator timed out");
139 147
148 kfree(orig_node->tt_buff);
140 kfree(orig_node->bcast_own); 149 kfree(orig_node->bcast_own);
141 kfree(orig_node->bcast_own_sum); 150 kfree(orig_node->bcast_own_sum);
142 kfree(orig_node); 151 kfree(orig_node);
@@ -183,7 +192,7 @@ void originator_free(struct bat_priv *bat_priv)
183 192
184/* this function finds or creates an originator entry for the given 193/* this function finds or creates an originator entry for the given
185 * address if it does not exits */ 194 * address if it does not exits */
186struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) 195struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr)
187{ 196{
188 struct orig_node *orig_node; 197 struct orig_node *orig_node;
189 int size; 198 int size;
@@ -196,7 +205,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)
196 bat_dbg(DBG_BATMAN, bat_priv, 205 bat_dbg(DBG_BATMAN, bat_priv,
197 "Creating new originator: %pM\n", addr); 206 "Creating new originator: %pM\n", addr);
198 207
199 orig_node = kzalloc(sizeof(struct orig_node), GFP_ATOMIC); 208 orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC);
200 if (!orig_node) 209 if (!orig_node)
201 return NULL; 210 return NULL;
202 211
@@ -205,14 +214,20 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)
205 spin_lock_init(&orig_node->ogm_cnt_lock); 214 spin_lock_init(&orig_node->ogm_cnt_lock);
206 spin_lock_init(&orig_node->bcast_seqno_lock); 215 spin_lock_init(&orig_node->bcast_seqno_lock);
207 spin_lock_init(&orig_node->neigh_list_lock); 216 spin_lock_init(&orig_node->neigh_list_lock);
217 spin_lock_init(&orig_node->tt_buff_lock);
208 218
209 /* extra reference for return */ 219 /* extra reference for return */
210 atomic_set(&orig_node->refcount, 2); 220 atomic_set(&orig_node->refcount, 2);
211 221
222 orig_node->tt_poss_change = false;
212 orig_node->bat_priv = bat_priv; 223 orig_node->bat_priv = bat_priv;
213 memcpy(orig_node->orig, addr, ETH_ALEN); 224 memcpy(orig_node->orig, addr, ETH_ALEN);
214 orig_node->router = NULL; 225 orig_node->router = NULL;
226 orig_node->tt_crc = 0;
227 atomic_set(&orig_node->last_ttvn, 0);
215 orig_node->tt_buff = NULL; 228 orig_node->tt_buff = NULL;
229 orig_node->tt_buff_len = 0;
230 atomic_set(&orig_node->tt_size, 0);
216 orig_node->bcast_seqno_reset = jiffies - 1 231 orig_node->bcast_seqno_reset = jiffies - 1
217 - msecs_to_jiffies(RESET_PROTECTION_MS); 232 - msecs_to_jiffies(RESET_PROTECTION_MS);
218 orig_node->batman_seqno_reset = jiffies - 1 233 orig_node->batman_seqno_reset = jiffies - 1
@@ -322,9 +337,7 @@ static bool purge_orig_node(struct bat_priv *bat_priv,
322 if (purge_orig_neighbors(bat_priv, orig_node, 337 if (purge_orig_neighbors(bat_priv, orig_node,
323 &best_neigh_node)) { 338 &best_neigh_node)) {
324 update_routes(bat_priv, orig_node, 339 update_routes(bat_priv, orig_node,
325 best_neigh_node, 340 best_neigh_node);
326 orig_node->tt_buff,
327 orig_node->tt_buff_len);
328 } 341 }
329 } 342 }
330 343
@@ -419,9 +432,8 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
419 goto out; 432 goto out;
420 } 433 }
421 434
422 seq_printf(seq, "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n", 435 seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n",
423 SOURCE_VERSION, REVISION_VERSION_STR, 436 SOURCE_VERSION, primary_if->net_dev->name,
424 primary_if->net_dev->name,
425 primary_if->net_dev->dev_addr, net_dev->name); 437 primary_if->net_dev->dev_addr, net_dev->name);
426 seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", 438 seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n",
427 "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop", 439 "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop",
@@ -559,7 +571,7 @@ static int orig_node_del_if(struct orig_node *orig_node,
559 memcpy(data_ptr, orig_node->bcast_own, del_if_num * chunk_size); 571 memcpy(data_ptr, orig_node->bcast_own, del_if_num * chunk_size);
560 572
561 /* copy second part */ 573 /* copy second part */
562 memcpy(data_ptr + del_if_num * chunk_size, 574 memcpy((char *)data_ptr + del_if_num * chunk_size,
563 orig_node->bcast_own + ((del_if_num + 1) * chunk_size), 575 orig_node->bcast_own + ((del_if_num + 1) * chunk_size),
564 (max_if_num - del_if_num) * chunk_size); 576 (max_if_num - del_if_num) * chunk_size);
565 577
@@ -579,7 +591,7 @@ free_bcast_own:
579 memcpy(data_ptr, orig_node->bcast_own_sum, 591 memcpy(data_ptr, orig_node->bcast_own_sum,
580 del_if_num * sizeof(uint8_t)); 592 del_if_num * sizeof(uint8_t));
581 593
582 memcpy(data_ptr + del_if_num * sizeof(uint8_t), 594 memcpy((char *)data_ptr + del_if_num * sizeof(uint8_t),
583 orig_node->bcast_own_sum + ((del_if_num + 1) * sizeof(uint8_t)), 595 orig_node->bcast_own_sum + ((del_if_num + 1) * sizeof(uint8_t)),
584 (max_if_num - del_if_num) * sizeof(uint8_t)); 596 (max_if_num - del_if_num) * sizeof(uint8_t));
585 597