]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Timers: Show sub-second times in some protocol outputs
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 13 Jun 2017 14:52:21 +0000 (16:52 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 7 Dec 2017 12:49:27 +0000 (13:49 +0100)
nest/proto.c
proto/bfd/bfd.c
proto/bgp/bgp.c
proto/ospf/neighbor.c
proto/rpki/rpki.c

index 3043b648d29eda3b20ab9449031acbacdf68f58b..8d5edda3dd058fb2daa0216a12e7b9857a97361b 100644 (file)
@@ -1136,7 +1136,7 @@ graceful_restart_show_status(void)
 
   cli_msg(-24, "Graceful restart recovery in progress");
   cli_msg(-24, "  Waiting for %d channels to recover", graceful_restart_locks);
-  cli_msg(-24, "  Wait timer is %d/%d", tm_remains(gr_wait_timer), config->gr_wait);
+  cli_msg(-24, "  Wait timer is %t/%u", tm2_remains(gr_wait_timer), config->gr_wait);
 }
 
 /**
index 2374cfe8ca434540a6ac217c7fc22f3d90b6360f..8915140d567bab2212ced6374d8b4d67c42b21f7 100644 (file)
@@ -1078,7 +1078,7 @@ bfd_show_sessions(struct proto *P)
   byte tbuf[TM_DATETIME_BUFFER_SIZE];
   struct bfd_proto *p = (struct bfd_proto *) P;
   uint state, diag UNUSED;
-  u32 tx_int, timeout;
+  btime tx_int, timeout;
   const char *ifname;
 
   if (p->p.proto_state != PS_UP)
@@ -1099,15 +1099,14 @@ bfd_show_sessions(struct proto *P)
     state = s->loc_state;
     diag = s->loc_diag;
     ifname = (s->ifa && s->ifa->iface) ? s->ifa->iface->name : "---";
-    tx_int = s->last_tx ? (MAX(s->des_min_tx_int, s->rem_min_rx_int) TO_MS) : 0;
-    timeout = (MAX(s->req_min_rx_int, s->rem_min_tx_int) TO_MS) * s->rem_detect_mult;
+    tx_int = s->last_tx ? MAX(s->des_min_tx_int, s->rem_min_rx_int) : 0;
+    timeout = (btime) MAX(s->req_min_rx_int, s->rem_min_tx_int) * s->rem_detect_mult;
 
     state = (state < 4) ? state : 0;
     tm_format_time(tbuf, &config->tf_proto, s->last_state_change);
 
-    cli_msg(-1020, "%-25I %-10s %-10s %-10s  %3u.%03u  %3u.%03u",
-           s->addr, ifname, bfd_state_names[state], tbuf,
-           tx_int / 1000, tx_int % 1000, timeout / 1000, timeout % 1000);
+    cli_msg(-1020, "%-25I %-10s %-10s %-10s  %7t  %7t",
+           s->addr, ifname, bfd_state_names[state], tbuf, tx_int, timeout);
   }
   HASH_WALK_END;
 
index dba7c875d9c791693684416da5229732e31563af..9823be6b37ad2568d808175f605390a80e562d00 100644 (file)
@@ -2009,17 +2009,17 @@ bgp_show_proto_info(struct proto *P)
 
     if ((p->start_state < BSS_CONNECT) &&
        (tm_active(p->startup_timer)))
-      cli_msg(-1006, "    Error wait:       %d/%d",
-             (int) tm_remains(p->startup_timer), p->startup_delay);
+      cli_msg(-1006, "    Error wait:       %t/%u",
+             tm2_remains(p->startup_timer), p->startup_delay);
 
     if ((oc->state == BS_ACTIVE) &&
        (tm_active(oc->connect_timer)))
-      cli_msg(-1006, "    Connect delay:    %d/%d",
-             (int) tm_remains(oc->connect_timer), p->cf->connect_delay_time);
+      cli_msg(-1006, "    Connect delay:    %t/%u",
+             tm2_remains(oc->connect_timer), p->cf->connect_delay_time);
 
     if (p->gr_active_num && tm_active(p->gr_timer))
-      cli_msg(-1006, "    Restart timer:    %d/-",
-             (int) tm_remains(p->gr_timer));
+      cli_msg(-1006, "    Restart timer:    %t/-",
+             tm2_remains(p->gr_timer));
   }
   else if (P->proto_state == PS_UP)
   {
@@ -2040,10 +2040,10 @@ bgp_show_proto_info(struct proto *P)
              p->ext_messages ? " ext-messages" : "");
 */
     cli_msg(-1006, "    Source address:   %I", p->source_addr);
-    cli_msg(-1006, "    Hold timer:       %d/%d",
-           tm_remains(p->conn->hold_timer), p->conn->hold_time);
-    cli_msg(-1006, "    Keepalive timer:  %d/%d",
-           tm_remains(p->conn->keepalive_timer), p->conn->keepalive_time);
+    cli_msg(-1006, "    Hold timer:       %t/%u",
+           tm2_remains(p->conn->hold_timer), p->conn->hold_time);
+    cli_msg(-1006, "    Keepalive timer:  %t/%u",
+           tm2_remains(p->conn->keepalive_timer), p->conn->keepalive_time);
   }
 
   if ((p->last_error_class != BE_NONE) &&
index 64165e4634992960d45e30355b6b216a2ba76835..74ea63d02d9f123828497862bc7d38887694c67e 100644 (file)
@@ -651,20 +651,6 @@ ospf_sh_neigh_info(struct ospf_neighbor *n)
 {
   struct ospf_iface *ifa = n->ifa;
   char *pos = "PtP  ";
-  char etime[6];
-  int exp, sec, min;
-
-  exp = tm_remains(n->inactim);
-  sec = exp % 60;
-  min = exp / 60;
-  if (min > 59)
-  {
-    bsprintf(etime, "-Inf-");
-  }
-  else
-  {
-    bsprintf(etime, "%02u:%02u", min, sec);
-  }
 
   if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_NBMA))
   {
@@ -676,6 +662,7 @@ ospf_sh_neigh_info(struct ospf_neighbor *n)
       pos = "Other";
   }
 
-  cli_msg(-1013, "%-1R\t%3u\t%s/%s\t%-5s\t%-10s %-1I", n->rid, n->priority,
-         ospf_ns_names[n->state], pos, etime, ifa->ifname, n->ip);
+  cli_msg(-1013, "%-1R\t%3u\t%s/%s\t%7t\t%-10s %-1I",
+         n->rid, n->priority, ospf_ns_names[n->state], pos,
+         tm2_remains(n->inactim), ifa->ifname, n->ip);
 }
index a331e45eb0e80f947a31f49eb160f297e02ba0d4..7930363f2b1cc873739379d42d632242412a25f3 100644 (file)
@@ -790,9 +790,9 @@ static void
 rpki_show_proto_info_timer(const char *name, uint num, timer *t)
 {
   if (tm_active(t))
-    cli_msg(-1006, "  %-17s %us (remains %ds)", name, num, (int) tm_remains(t));
+    cli_msg(-1006, "  %-16s: %t/%u", name, tm2_remains(t), num);
   else
-    cli_msg(-1006, "  %-17s ---", name);
+    cli_msg(-1006, "  %-16s: ---", name);
 }
 
 static void
@@ -836,9 +836,9 @@ rpki_show_proto_info(struct proto *P)
       cli_msg(-1006, "  Last update:      ---");
     }
 
-    rpki_show_proto_info_timer("Refresh interval:", cache->refresh_interval, cache->refresh_timer);
-    rpki_show_proto_info_timer("Retry interval:", cache->retry_interval, cache->retry_timer);
-    rpki_show_proto_info_timer("Expire interval:", cache->expire_interval, cache->expire_timer);
+    rpki_show_proto_info_timer("Refresh timer", cache->refresh_interval, cache->refresh_timer);
+    rpki_show_proto_info_timer("Retry timer", cache->retry_interval, cache->retry_timer);
+    rpki_show_proto_info_timer("Expire timer", cache->expire_interval, cache->expire_timer);
 
     if (p->roa4_channel)
       channel_show_info(p->roa4_channel);