aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/originator.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-20 16:43:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-20 16:43:21 -0400
commit06f4e926d256d902dd9a53dcb400fd74974ce087 (patch)
tree0b438b67f5f0eff6fd617bc497a9dace6164a488 /net/batman-adv/originator.c
parent8e7bfcbab3825d1b404d615cb1b54f44ff81f981 (diff)
parentd93515611bbc70c2fe4db232e5feb448ed8e4cc9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1446 commits) macvlan: fix panic if lowerdev in a bond tg3: Add braces around 5906 workaround. tg3: Fix NETIF_F_LOOPBACK error macvlan: remove one synchronize_rcu() call networking: NET_CLS_ROUTE4 depends on INET irda: Fix error propagation in ircomm_lmp_connect_response() irda: Kill set but unused variable 'bytes' in irlan_check_command_param() irda: Kill set but unused variable 'clen' in ircomm_connect_indication() rxrpc: Fix set but unused variable 'usage' in rxrpc_get_transport() be2net: Kill set but unused variable 'req' in lancer_fw_download() irda: Kill set but unused vars 'saddr' and 'daddr' in irlan_provider_connect_indication() atl1c: atl1c_resume() is only used when CONFIG_PM_SLEEP is defined. rxrpc: Fix set but unused variable 'usage' in rxrpc_get_peer(). rxrpc: Kill set but unused variable 'local' in rxrpc_UDP_error_handler() rxrpc: Kill set but unused variable 'sp' in rxrpc_process_connection() rxrpc: Kill set but unused variable 'sp' in rxrpc_rotate_tx_window() pkt_sched: Kill set but unused variable 'protocol' in tc_classify() isdn: capi: Use pr_debug() instead of ifdefs. tg3: Update version to 3.119 tg3: Apply rx_discards fix to 5719/5720 ... Fix up trivial conflicts in arch/x86/Kconfig and net/mac80211/agg-tx.c as per Davem.
Diffstat (limited to 'net/batman-adv/originator.c')
-rw-r--r--net/batman-adv/originator.c82
1 files changed, 54 insertions, 28 deletions
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index ed23a5895d6..40a30bbcd14 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -19,8 +19,6 @@
19 * 19 *
20 */ 20 */
21 21
22/* increase the reference counter for this originator */
23
24#include "main.h" 22#include "main.h"
25#include "originator.h" 23#include "originator.h"
26#include "hash.h" 24#include "hash.h"
@@ -62,6 +60,21 @@ void neigh_node_free_ref(struct neigh_node *neigh_node)
62 kfree_rcu(neigh_node, rcu); 60 kfree_rcu(neigh_node, rcu);
63} 61}
64 62
63/* increases the refcounter of a found router */
64struct neigh_node *orig_node_get_router(struct orig_node *orig_node)
65{
66 struct neigh_node *router;
67
68 rcu_read_lock();
69 router = rcu_dereference(orig_node->router);
70
71 if (router && !atomic_inc_not_zero(&router->refcount))
72 router = NULL;
73
74 rcu_read_unlock();
75 return router;
76}
77
65struct neigh_node *create_neighbor(struct orig_node *orig_node, 78struct neigh_node *create_neighbor(struct orig_node *orig_node,
66 struct orig_node *orig_neigh_node, 79 struct orig_node *orig_neigh_node,
67 uint8_t *neigh, 80 uint8_t *neigh,
@@ -79,6 +92,7 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node,
79 92
80 INIT_HLIST_NODE(&neigh_node->list); 93 INIT_HLIST_NODE(&neigh_node->list);
81 INIT_LIST_HEAD(&neigh_node->bonding_list); 94 INIT_LIST_HEAD(&neigh_node->bonding_list);
95 spin_lock_init(&neigh_node->tq_lock);
82 96
83 memcpy(neigh_node->addr, neigh, ETH_ALEN); 97 memcpy(neigh_node->addr, neigh, ETH_ALEN);
84 neigh_node->orig_node = orig_neigh_node; 98 neigh_node->orig_node = orig_neigh_node;
@@ -120,7 +134,7 @@ static void orig_node_free_rcu(struct rcu_head *rcu)
120 spin_unlock_bh(&orig_node->neigh_list_lock); 134 spin_unlock_bh(&orig_node->neigh_list_lock);
121 135
122 frag_list_free(&orig_node->frag_list); 136 frag_list_free(&orig_node->frag_list);
123 hna_global_del_orig(orig_node->bat_priv, orig_node, 137 tt_global_del_orig(orig_node->bat_priv, orig_node,
124 "originator timed out"); 138 "originator timed out");
125 139
126 kfree(orig_node->bcast_own); 140 kfree(orig_node->bcast_own);
@@ -198,7 +212,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)
198 orig_node->bat_priv = bat_priv; 212 orig_node->bat_priv = bat_priv;
199 memcpy(orig_node->orig, addr, ETH_ALEN); 213 memcpy(orig_node->orig, addr, ETH_ALEN);
200 orig_node->router = NULL; 214 orig_node->router = NULL;
201 orig_node->hna_buff = NULL; 215 orig_node->tt_buff = NULL;
202 orig_node->bcast_seqno_reset = jiffies - 1 216 orig_node->bcast_seqno_reset = jiffies - 1
203 - msecs_to_jiffies(RESET_PROTECTION_MS); 217 - msecs_to_jiffies(RESET_PROTECTION_MS);
204 orig_node->batman_seqno_reset = jiffies - 1 218 orig_node->batman_seqno_reset = jiffies - 1
@@ -309,8 +323,8 @@ static bool purge_orig_node(struct bat_priv *bat_priv,
309 &best_neigh_node)) { 323 &best_neigh_node)) {
310 update_routes(bat_priv, orig_node, 324 update_routes(bat_priv, orig_node,
311 best_neigh_node, 325 best_neigh_node,
312 orig_node->hna_buff, 326 orig_node->tt_buff,
313 orig_node->hna_buff_len); 327 orig_node->tt_buff_len);
314 } 328 }
315 } 329 }
316 330
@@ -381,29 +395,34 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
381 struct hashtable_t *hash = bat_priv->orig_hash; 395 struct hashtable_t *hash = bat_priv->orig_hash;
382 struct hlist_node *node, *node_tmp; 396 struct hlist_node *node, *node_tmp;
383 struct hlist_head *head; 397 struct hlist_head *head;
398 struct hard_iface *primary_if;
384 struct orig_node *orig_node; 399 struct orig_node *orig_node;
385 struct neigh_node *neigh_node; 400 struct neigh_node *neigh_node, *neigh_node_tmp;
386 int batman_count = 0; 401 int batman_count = 0;
387 int last_seen_secs; 402 int last_seen_secs;
388 int last_seen_msecs; 403 int last_seen_msecs;
389 int i; 404 int i, ret = 0;
390 405
391 if ((!bat_priv->primary_if) || 406 primary_if = primary_if_get_selected(bat_priv);
392 (bat_priv->primary_if->if_status != IF_ACTIVE)) { 407
393 if (!bat_priv->primary_if) 408 if (!primary_if) {
394 return seq_printf(seq, "BATMAN mesh %s disabled - " 409 ret = seq_printf(seq, "BATMAN mesh %s disabled - "
395 "please specify interfaces to enable it\n", 410 "please specify interfaces to enable it\n",
396 net_dev->name); 411 net_dev->name);
412 goto out;
413 }
397 414
398 return seq_printf(seq, "BATMAN mesh %s " 415 if (primary_if->if_status != IF_ACTIVE) {
399 "disabled - primary interface not active\n", 416 ret = seq_printf(seq, "BATMAN mesh %s "
400 net_dev->name); 417 "disabled - primary interface not active\n",
418 net_dev->name);
419 goto out;
401 } 420 }
402 421
403 seq_printf(seq, "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n", 422 seq_printf(seq, "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n",
404 SOURCE_VERSION, REVISION_VERSION_STR, 423 SOURCE_VERSION, REVISION_VERSION_STR,
405 bat_priv->primary_if->net_dev->name, 424 primary_if->net_dev->name,
406 bat_priv->primary_if->net_dev->dev_addr, net_dev->name); 425 primary_if->net_dev->dev_addr, net_dev->name);
407 seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", 426 seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n",
408 "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop", 427 "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop",
409 "outgoingIF", "Potential nexthops"); 428 "outgoingIF", "Potential nexthops");
@@ -413,40 +432,47 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
413 432
414 rcu_read_lock(); 433 rcu_read_lock();
415 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 434 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
416 if (!orig_node->router) 435 neigh_node = orig_node_get_router(orig_node);
436 if (!neigh_node)
417 continue; 437 continue;
418 438
419 if (orig_node->router->tq_avg == 0) 439 if (neigh_node->tq_avg == 0)
420 continue; 440 goto next;
421 441
422 last_seen_secs = jiffies_to_msecs(jiffies - 442 last_seen_secs = jiffies_to_msecs(jiffies -
423 orig_node->last_valid) / 1000; 443 orig_node->last_valid) / 1000;
424 last_seen_msecs = jiffies_to_msecs(jiffies - 444 last_seen_msecs = jiffies_to_msecs(jiffies -
425 orig_node->last_valid) % 1000; 445 orig_node->last_valid) % 1000;
426 446
427 neigh_node = orig_node->router;
428 seq_printf(seq, "%pM %4i.%03is (%3i) %pM [%10s]:", 447 seq_printf(seq, "%pM %4i.%03is (%3i) %pM [%10s]:",
429 orig_node->orig, last_seen_secs, 448 orig_node->orig, last_seen_secs,
430 last_seen_msecs, neigh_node->tq_avg, 449 last_seen_msecs, neigh_node->tq_avg,
431 neigh_node->addr, 450 neigh_node->addr,
432 neigh_node->if_incoming->net_dev->name); 451 neigh_node->if_incoming->net_dev->name);
433 452
434 hlist_for_each_entry_rcu(neigh_node, node_tmp, 453 hlist_for_each_entry_rcu(neigh_node_tmp, node_tmp,
435 &orig_node->neigh_list, list) { 454 &orig_node->neigh_list, list) {
436 seq_printf(seq, " %pM (%3i)", neigh_node->addr, 455 seq_printf(seq, " %pM (%3i)",
437 neigh_node->tq_avg); 456 neigh_node_tmp->addr,
457 neigh_node_tmp->tq_avg);
438 } 458 }
439 459
440 seq_printf(seq, "\n"); 460 seq_printf(seq, "\n");
441 batman_count++; 461 batman_count++;
462
463next:
464 neigh_node_free_ref(neigh_node);
442 } 465 }
443 rcu_read_unlock(); 466 rcu_read_unlock();
444 } 467 }
445 468
446 if ((batman_count == 0)) 469 if (batman_count == 0)
447 seq_printf(seq, "No batman nodes in range ...\n"); 470 seq_printf(seq, "No batman nodes in range ...\n");
448 471
449 return 0; 472out:
473 if (primary_if)
474 hardif_free_ref(primary_if);
475 return ret;
450} 476}
451 477
452static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) 478static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)