aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorAntonio Quartulli <antonio@open-mesh.com>2013-09-02 06:15:03 -0400
committerAntonio Quartulli <antonio@meshcoding.com>2013-10-23 09:33:10 -0400
commit737a2a229774ef983ef783149384bae3e3aa38ac (patch)
treeef2aa375749d3a3f1c2fe52f2fb0897ba2f88d1a /net/batman-adv
parentbbad0a5e3691cb3976d7a4815c47d9b7bb244731 (diff)
batman-adv: add bat_orig_print API function
Each routing protocol has its own metric and private variables, therefore it is useful to introduce a new API for originator information printing. This API needs to be implemented by each protocol in order to provide its specific originator table output. Signed-off-by: Antonio Quartulli <antonio@open-mesh.com> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/bat_iv_ogm.c65
-rw-r--r--net/batman-adv/originator.c66
-rw-r--r--net/batman-adv/types.h3
3 files changed, 78 insertions, 56 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 0b1343dde5d2..4aabd554ca75 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1411,6 +1411,70 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
1411 return NET_RX_SUCCESS; 1411 return NET_RX_SUCCESS;
1412} 1412}
1413 1413
1414/**
1415 * batadv_iv_ogm_orig_print - print the originator table
1416 * @bat_priv: the bat priv with all the soft interface information
1417 * @seq: debugfs table seq_file struct
1418 */
1419static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv,
1420 struct seq_file *seq)
1421{
1422 struct batadv_neigh_node *neigh_node, *neigh_node_tmp;
1423 struct batadv_hashtable *hash = bat_priv->orig_hash;
1424 int last_seen_msecs, last_seen_secs;
1425 struct batadv_orig_node *orig_node;
1426 unsigned long last_seen_jiffies;
1427 struct hlist_head *head;
1428 int batman_count = 0;
1429 uint32_t i;
1430
1431 seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n",
1432 "Originator", "last-seen", "#", BATADV_TQ_MAX_VALUE,
1433 "Nexthop", "outgoingIF", "Potential nexthops");
1434
1435 for (i = 0; i < hash->size; i++) {
1436 head = &hash->table[i];
1437
1438 rcu_read_lock();
1439 hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
1440 neigh_node = batadv_orig_node_get_router(orig_node);
1441 if (!neigh_node)
1442 continue;
1443
1444 if (neigh_node->bat_iv.tq_avg == 0)
1445 goto next;
1446
1447 last_seen_jiffies = jiffies - orig_node->last_seen;
1448 last_seen_msecs = jiffies_to_msecs(last_seen_jiffies);
1449 last_seen_secs = last_seen_msecs / 1000;
1450 last_seen_msecs = last_seen_msecs % 1000;
1451
1452 seq_printf(seq, "%pM %4i.%03is (%3i) %pM [%10s]:",
1453 orig_node->orig, last_seen_secs,
1454 last_seen_msecs, neigh_node->bat_iv.tq_avg,
1455 neigh_node->addr,
1456 neigh_node->if_incoming->net_dev->name);
1457
1458 hlist_for_each_entry_rcu(neigh_node_tmp,
1459 &orig_node->neigh_list, list) {
1460 seq_printf(seq, " %pM (%3i)",
1461 neigh_node_tmp->addr,
1462 neigh_node_tmp->bat_iv.tq_avg);
1463 }
1464
1465 seq_puts(seq, "\n");
1466 batman_count++;
1467
1468next:
1469 batadv_neigh_node_free_ref(neigh_node);
1470 }
1471 rcu_read_unlock();
1472 }
1473
1474 if (batman_count == 0)
1475 seq_puts(seq, "No batman nodes in range ...\n");
1476}
1477
1414static struct batadv_algo_ops batadv_batman_iv __read_mostly = { 1478static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
1415 .name = "BATMAN_IV", 1479 .name = "BATMAN_IV",
1416 .bat_iface_enable = batadv_iv_ogm_iface_enable, 1480 .bat_iface_enable = batadv_iv_ogm_iface_enable,
@@ -1419,6 +1483,7 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
1419 .bat_primary_iface_set = batadv_iv_ogm_primary_iface_set, 1483 .bat_primary_iface_set = batadv_iv_ogm_primary_iface_set,
1420 .bat_ogm_schedule = batadv_iv_ogm_schedule, 1484 .bat_ogm_schedule = batadv_iv_ogm_schedule,
1421 .bat_ogm_emit = batadv_iv_ogm_emit, 1485 .bat_ogm_emit = batadv_iv_ogm_emit,
1486 .bat_orig_print = batadv_iv_ogm_orig_print,
1422}; 1487};
1423 1488
1424int __init batadv_iv_init(void) 1489int __init batadv_iv_init(void)
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index aa1409467d08..8d1b16eb12d1 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -513,73 +513,27 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
513{ 513{
514 struct net_device *net_dev = (struct net_device *)seq->private; 514 struct net_device *net_dev = (struct net_device *)seq->private;
515 struct batadv_priv *bat_priv = netdev_priv(net_dev); 515 struct batadv_priv *bat_priv = netdev_priv(net_dev);
516 struct batadv_hashtable *hash = bat_priv->orig_hash;
517 struct hlist_head *head;
518 struct batadv_hard_iface *primary_if; 516 struct batadv_hard_iface *primary_if;
519 struct batadv_orig_node *orig_node;
520 struct batadv_neigh_node *neigh_node, *neigh_node_tmp;
521 int batman_count = 0;
522 int last_seen_secs;
523 int last_seen_msecs;
524 unsigned long last_seen_jiffies;
525 uint32_t i;
526 517
527 primary_if = batadv_seq_print_text_primary_if_get(seq); 518 primary_if = batadv_seq_print_text_primary_if_get(seq);
528 if (!primary_if) 519 if (!primary_if)
529 goto out; 520 return 0;
530 521
531 seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", 522 seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n",
532 BATADV_SOURCE_VERSION, primary_if->net_dev->name, 523 BATADV_SOURCE_VERSION, primary_if->net_dev->name,
533 primary_if->net_dev->dev_addr, net_dev->name); 524 primary_if->net_dev->dev_addr, net_dev->name,
534 seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", 525 bat_priv->bat_algo_ops->name);
535 "Originator", "last-seen", "#", BATADV_TQ_MAX_VALUE,
536 "Nexthop", "outgoingIF", "Potential nexthops");
537
538 for (i = 0; i < hash->size; i++) {
539 head = &hash->table[i];
540
541 rcu_read_lock();
542 hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
543 neigh_node = batadv_orig_node_get_router(orig_node);
544 if (!neigh_node)
545 continue;
546
547 if (neigh_node->bat_iv.tq_avg == 0)
548 goto next;
549
550 last_seen_jiffies = jiffies - orig_node->last_seen;
551 last_seen_msecs = jiffies_to_msecs(last_seen_jiffies);
552 last_seen_secs = last_seen_msecs / 1000;
553 last_seen_msecs = last_seen_msecs % 1000;
554
555 seq_printf(seq, "%pM %4i.%03is (%3i) %pM [%10s]:",
556 orig_node->orig, last_seen_secs,
557 last_seen_msecs, neigh_node->bat_iv.tq_avg,
558 neigh_node->addr,
559 neigh_node->if_incoming->net_dev->name);
560
561 hlist_for_each_entry_rcu(neigh_node_tmp,
562 &orig_node->neigh_list, list) {
563 seq_printf(seq, " %pM (%3i)",
564 neigh_node_tmp->addr,
565 neigh_node_tmp->bat_iv.tq_avg);
566 }
567 526
568 seq_puts(seq, "\n"); 527 batadv_hardif_free_ref(primary_if);
569 batman_count++;
570 528
571next: 529 if (!bat_priv->bat_algo_ops->bat_orig_print) {
572 batadv_neigh_node_free_ref(neigh_node); 530 seq_puts(seq,
573 } 531 "No printing function for this routing protocol\n");
574 rcu_read_unlock(); 532 return 0;
575 } 533 }
576 534
577 if (batman_count == 0) 535 bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq);
578 seq_puts(seq, "No batman nodes in range ...\n");
579 536
580out:
581 if (primary_if)
582 batadv_hardif_free_ref(primary_if);
583 return 0; 537 return 0;
584} 538}
585 539
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 97bde51b6031..72fd617b2e73 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -992,6 +992,7 @@ struct batadv_forw_packet {
992 * @bat_primary_iface_set: called when primary interface is selected / changed 992 * @bat_primary_iface_set: called when primary interface is selected / changed
993 * @bat_ogm_schedule: prepare a new outgoing OGM for the send queue 993 * @bat_ogm_schedule: prepare a new outgoing OGM for the send queue
994 * @bat_ogm_emit: send scheduled OGM 994 * @bat_ogm_emit: send scheduled OGM
995 * @bat_orig_print: print the originator table (optional)
995 */ 996 */
996struct batadv_algo_ops { 997struct batadv_algo_ops {
997 struct hlist_node list; 998 struct hlist_node list;
@@ -1002,6 +1003,8 @@ struct batadv_algo_ops {
1002 void (*bat_primary_iface_set)(struct batadv_hard_iface *hard_iface); 1003 void (*bat_primary_iface_set)(struct batadv_hard_iface *hard_iface);
1003 void (*bat_ogm_schedule)(struct batadv_hard_iface *hard_iface); 1004 void (*bat_ogm_schedule)(struct batadv_hard_iface *hard_iface);
1004 void (*bat_ogm_emit)(struct batadv_forw_packet *forw_packet); 1005 void (*bat_ogm_emit)(struct batadv_forw_packet *forw_packet);
1006 /* orig_node handling API */
1007 void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq);
1005}; 1008};
1006 1009
1007/** 1010/**