aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/translation-table.c
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2012-11-08 16:16:16 -0500
committerAntonio Quartulli <ordex@autistici.org>2013-01-12 05:58:20 -0500
commit85766a82003ec5ecc35403e855c47ce69c4658fc (patch)
treedcf741c649440dd5beb15c49b1844788b0f8f89a /net/batman-adv/translation-table.c
parent7cf4d520fdb72250b769920274279249629881ce (diff)
batman-adv: improve local translation table output
This patch adds a nice header to the local translation table and the last_seen time for each local entry Signed-off-by: Antonio Quartulli <ordex@autistici.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/translation-table.c')
-rw-r--r--net/batman-adv/translation-table.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 22457a7952ba..426a3ae47788 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -472,10 +472,16 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
472 struct batadv_priv *bat_priv = netdev_priv(net_dev); 472 struct batadv_priv *bat_priv = netdev_priv(net_dev);
473 struct batadv_hashtable *hash = bat_priv->tt.local_hash; 473 struct batadv_hashtable *hash = bat_priv->tt.local_hash;
474 struct batadv_tt_common_entry *tt_common_entry; 474 struct batadv_tt_common_entry *tt_common_entry;
475 struct batadv_tt_local_entry *tt_local;
475 struct batadv_hard_iface *primary_if; 476 struct batadv_hard_iface *primary_if;
476 struct hlist_node *node; 477 struct hlist_node *node;
477 struct hlist_head *head; 478 struct hlist_head *head;
478 uint32_t i; 479 uint32_t i;
480 int last_seen_secs;
481 int last_seen_msecs;
482 unsigned long last_seen_jiffies;
483 bool no_purge;
484 uint16_t np_flag = BATADV_TT_CLIENT_NOPURGE;
479 485
480 primary_if = batadv_seq_print_text_primary_if_get(seq); 486 primary_if = batadv_seq_print_text_primary_if_get(seq);
481 if (!primary_if) 487 if (!primary_if)
@@ -484,6 +490,8 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
484 seq_printf(seq, 490 seq_printf(seq,
485 "Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n", 491 "Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n",
486 net_dev->name, (uint8_t)atomic_read(&bat_priv->tt.vn)); 492 net_dev->name, (uint8_t)atomic_read(&bat_priv->tt.vn));
493 seq_printf(seq, " %-13s %-7s %-10s\n", "Client", "Flags",
494 "Last seen");
487 495
488 for (i = 0; i < hash->size; i++) { 496 for (i = 0; i < hash->size; i++) {
489 head = &hash->table[i]; 497 head = &hash->table[i];
@@ -491,18 +499,29 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
491 rcu_read_lock(); 499 rcu_read_lock();
492 hlist_for_each_entry_rcu(tt_common_entry, node, 500 hlist_for_each_entry_rcu(tt_common_entry, node,
493 head, hash_entry) { 501 head, hash_entry) {
494 seq_printf(seq, " * %pM [%c%c%c%c%c]\n", 502 tt_local = container_of(tt_common_entry,
503 struct batadv_tt_local_entry,
504 common);
505 last_seen_jiffies = jiffies - tt_local->last_seen;
506 last_seen_msecs = jiffies_to_msecs(last_seen_jiffies);
507 last_seen_secs = last_seen_msecs / 1000;
508 last_seen_msecs = last_seen_msecs % 1000;
509
510 no_purge = tt_common_entry->flags & np_flag;
511
512 seq_printf(seq, " * %pM [%c%c%c%c%c] %3u.%03u\n",
495 tt_common_entry->addr, 513 tt_common_entry->addr,
496 (tt_common_entry->flags & 514 (tt_common_entry->flags &
497 BATADV_TT_CLIENT_ROAM ? 'R' : '.'), 515 BATADV_TT_CLIENT_ROAM ? 'R' : '.'),
498 (tt_common_entry->flags & 516 no_purge ? 'P' : '.',
499 BATADV_TT_CLIENT_NOPURGE ? 'P' : '.'),
500 (tt_common_entry->flags & 517 (tt_common_entry->flags &
501 BATADV_TT_CLIENT_NEW ? 'N' : '.'), 518 BATADV_TT_CLIENT_NEW ? 'N' : '.'),
502 (tt_common_entry->flags & 519 (tt_common_entry->flags &
503 BATADV_TT_CLIENT_PENDING ? 'X' : '.'), 520 BATADV_TT_CLIENT_PENDING ? 'X' : '.'),
504 (tt_common_entry->flags & 521 (tt_common_entry->flags &
505 BATADV_TT_CLIENT_WIFI ? 'W' : '.')); 522 BATADV_TT_CLIENT_WIFI ? 'W' : '.'),
523 no_purge ? last_seen_secs : 0,
524 no_purge ? last_seen_msecs : 0);
506 } 525 }
507 rcu_read_unlock(); 526 rcu_read_unlock();
508 } 527 }