aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/originator.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2012-06-05 16:31:31 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-07-01 16:47:21 -0400
commit56303d34a332be8e2f4daf7891ebc12cb7900529 (patch)
treebc972916771e698bd8a88fd66917950ce0bd48c1 /net/batman-adv/originator.c
parent96412690116afcc1b2705615b5a7c8dc6c5e905f (diff)
batman-adv: Prefix types 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/originator.c')
-rw-r--r--net/batman-adv/originator.c102
1 files changed, 54 insertions, 48 deletions
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index dc9c4bf63118..fc1ce26ac627 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -30,7 +30,7 @@
30 30
31static void batadv_purge_orig(struct work_struct *work); 31static void batadv_purge_orig(struct work_struct *work);
32 32
33static void batadv_start_purge_timer(struct bat_priv *bat_priv) 33static void batadv_start_purge_timer(struct batadv_priv *bat_priv)
34{ 34{
35 INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig); 35 INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig);
36 queue_delayed_work(batadv_event_workqueue, 36 queue_delayed_work(batadv_event_workqueue,
@@ -40,12 +40,13 @@ static void batadv_start_purge_timer(struct bat_priv *bat_priv)
40/* returns 1 if they are the same originator */ 40/* returns 1 if they are the same originator */
41static int batadv_compare_orig(const struct hlist_node *node, const void *data2) 41static int batadv_compare_orig(const struct hlist_node *node, const void *data2)
42{ 42{
43 const void *data1 = container_of(node, struct orig_node, hash_entry); 43 const void *data1 = container_of(node, struct batadv_orig_node,
44 hash_entry);
44 45
45 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); 46 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
46} 47}
47 48
48int batadv_originator_init(struct bat_priv *bat_priv) 49int batadv_originator_init(struct batadv_priv *bat_priv)
49{ 50{
50 if (bat_priv->orig_hash) 51 if (bat_priv->orig_hash)
51 return 0; 52 return 0;
@@ -62,16 +63,17 @@ err:
62 return -ENOMEM; 63 return -ENOMEM;
63} 64}
64 65
65void batadv_neigh_node_free_ref(struct neigh_node *neigh_node) 66void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node)
66{ 67{
67 if (atomic_dec_and_test(&neigh_node->refcount)) 68 if (atomic_dec_and_test(&neigh_node->refcount))
68 kfree_rcu(neigh_node, rcu); 69 kfree_rcu(neigh_node, rcu);
69} 70}
70 71
71/* increases the refcounter of a found router */ 72/* increases the refcounter of a found router */
72struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node) 73struct batadv_neigh_node *
74batadv_orig_node_get_router(struct batadv_orig_node *orig_node)
73{ 75{
74 struct neigh_node *router; 76 struct batadv_neigh_node *router;
75 77
76 rcu_read_lock(); 78 rcu_read_lock();
77 router = rcu_dereference(orig_node->router); 79 router = rcu_dereference(orig_node->router);
@@ -83,12 +85,12 @@ struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node)
83 return router; 85 return router;
84} 86}
85 87
86struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, 88struct batadv_neigh_node *
87 const uint8_t *neigh_addr, 89batadv_neigh_node_new(struct batadv_hard_iface *hard_iface,
88 uint32_t seqno) 90 const uint8_t *neigh_addr, uint32_t seqno)
89{ 91{
90 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 92 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
91 struct neigh_node *neigh_node; 93 struct batadv_neigh_node *neigh_node;
92 94
93 neigh_node = kzalloc(sizeof(*neigh_node), GFP_ATOMIC); 95 neigh_node = kzalloc(sizeof(*neigh_node), GFP_ATOMIC);
94 if (!neigh_node) 96 if (!neigh_node)
@@ -113,10 +115,10 @@ out:
113static void batadv_orig_node_free_rcu(struct rcu_head *rcu) 115static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
114{ 116{
115 struct hlist_node *node, *node_tmp; 117 struct hlist_node *node, *node_tmp;
116 struct neigh_node *neigh_node, *tmp_neigh_node; 118 struct batadv_neigh_node *neigh_node, *tmp_neigh_node;
117 struct orig_node *orig_node; 119 struct batadv_orig_node *orig_node;
118 120
119 orig_node = container_of(rcu, struct orig_node, rcu); 121 orig_node = container_of(rcu, struct batadv_orig_node, rcu);
120 122
121 spin_lock_bh(&orig_node->neigh_list_lock); 123 spin_lock_bh(&orig_node->neigh_list_lock);
122 124
@@ -146,19 +148,19 @@ static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
146 kfree(orig_node); 148 kfree(orig_node);
147} 149}
148 150
149void batadv_orig_node_free_ref(struct orig_node *orig_node) 151void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node)
150{ 152{
151 if (atomic_dec_and_test(&orig_node->refcount)) 153 if (atomic_dec_and_test(&orig_node->refcount))
152 call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu); 154 call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu);
153} 155}
154 156
155void batadv_originator_free(struct bat_priv *bat_priv) 157void batadv_originator_free(struct batadv_priv *bat_priv)
156{ 158{
157 struct batadv_hashtable *hash = bat_priv->orig_hash; 159 struct batadv_hashtable *hash = bat_priv->orig_hash;
158 struct hlist_node *node, *node_tmp; 160 struct hlist_node *node, *node_tmp;
159 struct hlist_head *head; 161 struct hlist_head *head;
160 spinlock_t *list_lock; /* spinlock to protect write access */ 162 spinlock_t *list_lock; /* spinlock to protect write access */
161 struct orig_node *orig_node; 163 struct batadv_orig_node *orig_node;
162 uint32_t i; 164 uint32_t i;
163 165
164 if (!hash) 166 if (!hash)
@@ -188,10 +190,10 @@ void batadv_originator_free(struct bat_priv *bat_priv)
188/* this function finds or creates an originator entry for the given 190/* this function finds or creates an originator entry for the given
189 * address if it does not exits 191 * address if it does not exits
190 */ 192 */
191struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, 193struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv,
192 const uint8_t *addr) 194 const uint8_t *addr)
193{ 195{
194 struct orig_node *orig_node; 196 struct batadv_orig_node *orig_node;
195 int size; 197 int size;
196 int hash_added; 198 int hash_added;
197 unsigned long reset_time; 199 unsigned long reset_time;
@@ -264,15 +266,16 @@ free_orig_node:
264 return NULL; 266 return NULL;
265} 267}
266 268
267static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv, 269static bool
268 struct orig_node *orig_node, 270batadv_purge_orig_neighbors(struct batadv_priv *bat_priv,
269 struct neigh_node **best_neigh_node) 271 struct batadv_orig_node *orig_node,
272 struct batadv_neigh_node **best_neigh_node)
270{ 273{
271 struct hlist_node *node, *node_tmp; 274 struct hlist_node *node, *node_tmp;
272 struct neigh_node *neigh_node; 275 struct batadv_neigh_node *neigh_node;
273 bool neigh_purged = false; 276 bool neigh_purged = false;
274 unsigned long last_seen; 277 unsigned long last_seen;
275 struct hard_iface *if_incoming; 278 struct batadv_hard_iface *if_incoming;
276 279
277 *best_neigh_node = NULL; 280 *best_neigh_node = NULL;
278 281
@@ -319,10 +322,10 @@ static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv,
319 return neigh_purged; 322 return neigh_purged;
320} 323}
321 324
322static bool batadv_purge_orig_node(struct bat_priv *bat_priv, 325static bool batadv_purge_orig_node(struct batadv_priv *bat_priv,
323 struct orig_node *orig_node) 326 struct batadv_orig_node *orig_node)
324{ 327{
325 struct neigh_node *best_neigh_node; 328 struct batadv_neigh_node *best_neigh_node;
326 329
327 if (batadv_has_timed_out(orig_node->last_seen, 330 if (batadv_has_timed_out(orig_node->last_seen,
328 2 * BATADV_PURGE_TIMEOUT)) { 331 2 * BATADV_PURGE_TIMEOUT)) {
@@ -341,13 +344,13 @@ static bool batadv_purge_orig_node(struct bat_priv *bat_priv,
341 return false; 344 return false;
342} 345}
343 346
344static void _batadv_purge_orig(struct bat_priv *bat_priv) 347static void _batadv_purge_orig(struct batadv_priv *bat_priv)
345{ 348{
346 struct batadv_hashtable *hash = bat_priv->orig_hash; 349 struct batadv_hashtable *hash = bat_priv->orig_hash;
347 struct hlist_node *node, *node_tmp; 350 struct hlist_node *node, *node_tmp;
348 struct hlist_head *head; 351 struct hlist_head *head;
349 spinlock_t *list_lock; /* spinlock to protect write access */ 352 spinlock_t *list_lock; /* spinlock to protect write access */
350 struct orig_node *orig_node; 353 struct batadv_orig_node *orig_node;
351 uint32_t i; 354 uint32_t i;
352 355
353 if (!hash) 356 if (!hash)
@@ -383,16 +386,16 @@ static void _batadv_purge_orig(struct bat_priv *bat_priv)
383 386
384static void batadv_purge_orig(struct work_struct *work) 387static void batadv_purge_orig(struct work_struct *work)
385{ 388{
386 struct delayed_work *delayed_work = 389 struct delayed_work *delayed_work;
387 container_of(work, struct delayed_work, work); 390 struct batadv_priv *bat_priv;
388 struct bat_priv *bat_priv =
389 container_of(delayed_work, struct bat_priv, orig_work);
390 391
392 delayed_work = container_of(work, struct delayed_work, work);
393 bat_priv = container_of(delayed_work, struct batadv_priv, orig_work);
391 _batadv_purge_orig(bat_priv); 394 _batadv_purge_orig(bat_priv);
392 batadv_start_purge_timer(bat_priv); 395 batadv_start_purge_timer(bat_priv);
393} 396}
394 397
395void batadv_purge_orig_ref(struct bat_priv *bat_priv) 398void batadv_purge_orig_ref(struct batadv_priv *bat_priv)
396{ 399{
397 _batadv_purge_orig(bat_priv); 400 _batadv_purge_orig(bat_priv);
398} 401}
@@ -400,13 +403,13 @@ void batadv_purge_orig_ref(struct bat_priv *bat_priv)
400int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) 403int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
401{ 404{
402 struct net_device *net_dev = (struct net_device *)seq->private; 405 struct net_device *net_dev = (struct net_device *)seq->private;
403 struct bat_priv *bat_priv = netdev_priv(net_dev); 406 struct batadv_priv *bat_priv = netdev_priv(net_dev);
404 struct batadv_hashtable *hash = bat_priv->orig_hash; 407 struct batadv_hashtable *hash = bat_priv->orig_hash;
405 struct hlist_node *node, *node_tmp; 408 struct hlist_node *node, *node_tmp;
406 struct hlist_head *head; 409 struct hlist_head *head;
407 struct hard_iface *primary_if; 410 struct batadv_hard_iface *primary_if;
408 struct orig_node *orig_node; 411 struct batadv_orig_node *orig_node;
409 struct neigh_node *neigh_node, *neigh_node_tmp; 412 struct batadv_neigh_node *neigh_node, *neigh_node_tmp;
410 int batman_count = 0; 413 int batman_count = 0;
411 int last_seen_secs; 414 int last_seen_secs;
412 int last_seen_msecs; 415 int last_seen_msecs;
@@ -484,7 +487,8 @@ out:
484 return ret; 487 return ret;
485} 488}
486 489
487static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num) 490static int batadv_orig_node_add_if(struct batadv_orig_node *orig_node,
491 int max_if_num)
488{ 492{
489 void *data_ptr; 493 void *data_ptr;
490 size_t data_size, old_size; 494 size_t data_size, old_size;
@@ -511,13 +515,14 @@ static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num)
511 return 0; 515 return 0;
512} 516}
513 517
514int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num) 518int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
519 int max_if_num)
515{ 520{
516 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 521 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
517 struct batadv_hashtable *hash = bat_priv->orig_hash; 522 struct batadv_hashtable *hash = bat_priv->orig_hash;
518 struct hlist_node *node; 523 struct hlist_node *node;
519 struct hlist_head *head; 524 struct hlist_head *head;
520 struct orig_node *orig_node; 525 struct batadv_orig_node *orig_node;
521 uint32_t i; 526 uint32_t i;
522 int ret; 527 int ret;
523 528
@@ -546,7 +551,7 @@ err:
546 return -ENOMEM; 551 return -ENOMEM;
547} 552}
548 553
549static int batadv_orig_node_del_if(struct orig_node *orig_node, 554static int batadv_orig_node_del_if(struct batadv_orig_node *orig_node,
550 int max_if_num, int del_if_num) 555 int max_if_num, int del_if_num)
551{ 556{
552 void *data_ptr = NULL; 557 void *data_ptr = NULL;
@@ -594,14 +599,15 @@ free_own_sum:
594 return 0; 599 return 0;
595} 600}
596 601
597int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) 602int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
603 int max_if_num)
598{ 604{
599 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 605 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
600 struct batadv_hashtable *hash = bat_priv->orig_hash; 606 struct batadv_hashtable *hash = bat_priv->orig_hash;
601 struct hlist_node *node; 607 struct hlist_node *node;
602 struct hlist_head *head; 608 struct hlist_head *head;
603 struct hard_iface *hard_iface_tmp; 609 struct batadv_hard_iface *hard_iface_tmp;
604 struct orig_node *orig_node; 610 struct batadv_orig_node *orig_node;
605 uint32_t i; 611 uint32_t i;
606 int ret; 612 int ret;
607 613