]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: count iface up/down events and keep last time of their occurrence
authorChristian Franke <nobody@nowhere.ws>
Thu, 7 Apr 2016 19:43:44 +0000 (16:43 -0300)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 8 Apr 2016 00:41:43 +0000 (20:41 -0400)
It is quite useful to be able to assert whether specific interfaces have
flapped or also to verify that specific interfaces have not flapped.

By having counters for those events and storing the last time of their
occurrence, this is made possible.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Acked-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
zebra/interface.c
zebra/interface.h

index 38fe6988ebc6e7d3c8280591b0b8d96d426b90e4..9b6c04c294825cfb1846d23c0814a05e1e9375a5 100644 (file)
@@ -835,6 +835,12 @@ if_down_del_nbr_connected (struct interface *ifp)
 void
 if_up (struct interface *ifp)
 {
+  struct zebra_if *zif;
+
+  zif = ifp->info;
+  zif->up_count++;
+  quagga_timestamp (2, zif->up_last, sizeof (zif->up_last));
+
   /* Notify the protocol daemons. */
   if (ifp->ptm_enable && (ifp->ptm_status == ZEBRA_PTM_STATUS_DOWN)) {
     zlog_warn("%s: interface %s hasn't passed ptm check\n", __func__,
@@ -859,6 +865,12 @@ if_up (struct interface *ifp)
 void
 if_down (struct interface *ifp)
 {
+  struct zebra_if *zif;
+
+  zif = ifp->info;
+  zif->down_count++;
+  quagga_timestamp (2, zif->down_last, sizeof (zif->down_last));
+
   /* Notify to the protocol daemons. */
   zebra_interface_down_update (ifp);
 
@@ -1035,6 +1047,11 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
     vty_out (vty, "down%s", VTY_NEWLINE);
   }
 
+  vty_out (vty, "  Link ups:   %5u    last: %s%s", zebra_if->up_count,
+           zebra_if->up_last[0] ? zebra_if->up_last : "(never)", VTY_NEWLINE);
+  vty_out (vty, "  Link downs: %5u    last: %s%s", zebra_if->down_count,
+           zebra_if->down_last[0] ? zebra_if->down_last : "(never)", VTY_NEWLINE);
+
   zebra_ptm_show_status(vty, ifp);
 
   vrf = vrf_lookup(ifp->vrf_id);
index ed5150776321c289bf36da320c57ab34f215ad7e..8e8387eaf4e458f2ecae94627978e47b21ce8a58 100644 (file)
@@ -189,6 +189,12 @@ struct zebra_if
   /* Installed addresses chains tree. */
   struct route_table *ipv4_subnets;
 
+  /* Information about up/down changes */
+  unsigned int up_count;
+  char up_last[QUAGGA_TIMESTAMP_LEN];
+  unsigned int down_count;
+  char down_last[QUAGGA_TIMESTAMP_LEN];
+
 #if defined(HAVE_RTADV)
   struct rtadvconf rtadv;
 #endif /* HAVE_RTADV */