ip-neighbor: show age instead of time in cli

To match the API behavior, and as it is more useful to have an entry
age than its time last probe.

Type: fix
Change-Id: I07680cd713d0d2b6208a58208b032af7f6a92825
Signed-off-by: Maxime Peim <mpeim@cisco.com>
diff --git a/src/vnet/ip-neighbor/ip_neighbor.c b/src/vnet/ip-neighbor/ip_neighbor.c
index d340037..614b784 100644
--- a/src/vnet/ip-neighbor/ip_neighbor.c
+++ b/src/vnet/ip-neighbor/ip_neighbor.c
@@ -460,6 +460,7 @@
   af = ip_neighbor_get_af (ipn);
 
   IP_NEIGHBOR_DBG ("free: %U", format_ip_neighbor,
+		   vlib_time_now (vlib_get_main ()),
 		   ip_neighbor_get_index (ipn));
 
   ip_neighbor_publish (ip_neighbor_get_index (ipn),
@@ -944,20 +945,20 @@
 			   vlib_cli_command_t * cmd, ip_address_family_t af)
 {
   ip_neighbor_elt_t *elt, *head;
+  f64 now;
 
   head = pool_elt_at_index (ip_neighbor_elt_pool, ip_neighbor_list_head[af]);
+  now = vlib_time_now (vm);
 
-
-  vlib_cli_output (vm, "%=12s%=40s%=6s%=20s%=24s", "Time", "IP",
-		   "Flags", "Ethernet", "Interface");
+  vlib_cli_output (vm, "%=12s%=40s%=6s%=20s%=24s", "Age", "IP", "Flags",
+		   "Ethernet", "Interface");
 
   /* the list is time sorted, newest first, so start from the back
    * and work forwards. Stop when we get to one that is alive */
-  clib_llist_foreach_reverse(ip_neighbor_elt_pool,
-                             ipne_anchor, head, elt,
-  ({
-    vlib_cli_output (vm, "%U", format_ip_neighbor, elt->ipne_index);
-  }));
+  clib_llist_foreach_reverse (ip_neighbor_elt_pool, ipne_anchor, head, elt, ({
+				vlib_cli_output (vm, "%U", format_ip_neighbor,
+						 now, elt->ipne_index);
+			      }));
 
   return (NULL);
 }
@@ -969,6 +970,7 @@
 {
   index_t *ipni, *ipnis = NULL;
   u32 sw_if_index;
+  f64 now;
 
   /* Filter entries by interface if given. */
   sw_if_index = ~0;
@@ -976,14 +978,15 @@
 			&sw_if_index);
 
   ipnis = ip_neighbor_entries (sw_if_index, af);
+  now = vlib_time_now (vm);
 
   if (ipnis)
-    vlib_cli_output (vm, "%=12s%=40s%=6s%=20s%=24s", "Time", "IP",
-		     "Flags", "Ethernet", "Interface");
+    vlib_cli_output (vm, "%=12s%=40s%=6s%=20s%=24s", "Age", "IP", "Flags",
+		     "Ethernet", "Interface");
 
   vec_foreach (ipni, ipnis)
   {
-    vlib_cli_output (vm, "%U", format_ip_neighbor, *ipni);
+    vlib_cli_output (vm, "%U", format_ip_neighbor, now, *ipni);
   }
   vec_free (ipnis);
 
@@ -1573,13 +1576,12 @@
 
   if (ttl > ipndb_age)
     {
-      IP_NEIGHBOR_DBG ("aged: %U @%f - %f > %d",
-		       format_ip_neighbor, ipni, now,
-		       ipn->ipn_time_last_updated, ipndb_age);
+      IP_NEIGHBOR_DBG ("aged: %U @%f - %f > %d", format_ip_neighbor, now, ipni,
+		       now, ipn->ipn_time_last_updated, ipndb_age);
       if (ipn->ipn_n_probes > 2)
 	{
 	  /* 3 strikes and yea-re out */
-	  IP_NEIGHBOR_DBG ("dead: %U", format_ip_neighbor, ipni);
+	  IP_NEIGHBOR_DBG ("dead: %U", format_ip_neighbor, now, ipni);
 	  *wait = 1;
 	  return (IP_NEIGHBOR_AGE_DEAD);
 	}
diff --git a/src/vnet/ip-neighbor/ip_neighbor_types.c b/src/vnet/ip-neighbor/ip_neighbor_types.c
index 39039a4..a6f3c26 100644
--- a/src/vnet/ip-neighbor/ip_neighbor_types.c
+++ b/src/vnet/ip-neighbor/ip_neighbor_types.c
@@ -68,19 +68,18 @@
 u8 *
 format_ip_neighbor (u8 * s, va_list * va)
 {
+  f64 now = va_arg (*va, f64);
   index_t ipni = va_arg (*va, index_t);
   ip_neighbor_t *ipn;
 
   ipn = ip_neighbor_get (ipni);
 
-  return (format (s, "%=12U%=40U%=6U%=20U%U",
-		  format_vlib_time, vlib_get_main (),
-		  ipn->ipn_time_last_updated,
-		  format_ip_address, &ipn->ipn_key->ipnk_ip,
-		  format_ip_neighbor_flags, ipn->ipn_flags,
-		  format_mac_address_t, &ipn->ipn_mac,
-		  format_vnet_sw_if_index_name, vnet_get_main (),
-		  ipn->ipn_key->ipnk_sw_if_index));
+  return (
+    format (s, "%=12U%=40U%=6U%=20U%U", format_vlib_time, vlib_get_main (),
+	    now - ipn->ipn_time_last_updated, format_ip_address,
+	    &ipn->ipn_key->ipnk_ip, format_ip_neighbor_flags, ipn->ipn_flags,
+	    format_mac_address_t, &ipn->ipn_mac, format_vnet_sw_if_index_name,
+	    vnet_get_main (), ipn->ipn_key->ipnk_sw_if_index));
 }
 
 static void