Commit 85766a82003ec5ecc35403e855c47ce69c4658fc

Authored by Antonio Quartulli
1 parent 7cf4d520fd

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>

Showing 1 changed file with 23 additions and 4 deletions Side-by-side Diff

net/batman-adv/translation-table.c
... ... @@ -472,10 +472,16 @@
472 472 struct batadv_priv *bat_priv = netdev_priv(net_dev);
473 473 struct batadv_hashtable *hash = bat_priv->tt.local_hash;
474 474 struct batadv_tt_common_entry *tt_common_entry;
  475 + struct batadv_tt_local_entry *tt_local;
475 476 struct batadv_hard_iface *primary_if;
476 477 struct hlist_node *node;
477 478 struct hlist_head *head;
478 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 486 primary_if = batadv_seq_print_text_primary_if_get(seq);
481 487 if (!primary_if)
... ... @@ -484,6 +490,8 @@
484 490 seq_printf(seq,
485 491 "Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n",
486 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 496 for (i = 0; i < hash->size; i++) {
489 497 head = &hash->table[i];
490 498  
491 499  
492 500  
... ... @@ -491,18 +499,29 @@
491 499 rcu_read_lock();
492 500 hlist_for_each_entry_rcu(tt_common_entry, node,
493 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 513 tt_common_entry->addr,
496 514 (tt_common_entry->flags &
497 515 BATADV_TT_CLIENT_ROAM ? 'R' : '.'),
  516 + no_purge ? 'P' : '.',
498 517 (tt_common_entry->flags &
499   - BATADV_TT_CLIENT_NOPURGE ? 'P' : '.'),
500   - (tt_common_entry->flags &
501 518 BATADV_TT_CLIENT_NEW ? 'N' : '.'),
502 519 (tt_common_entry->flags &
503 520 BATADV_TT_CLIENT_PENDING ? 'X' : '.'),
504 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 526 rcu_read_unlock();
508 527 }