]> git.puffer.fish Git - mirror/frr.git/commitdiff
[ospfd] record timestamp and event of last NSM state change for neighbour
authorPaul Jakma <paul.jakma@sun.com>
Tue, 11 Jul 2006 17:57:25 +0000 (17:57 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Tue, 11 Jul 2006 17:57:25 +0000 (17:57 +0000)
2006-07-10 Paul Jakma <paul.jakma@sun.com>

* ospf_nsm.c: (ospf_nsm_event) Record state change timestamp
  and event in nbr struct.
* ospf_neighbor.h: (struct ospf_neighbor) Add fields to record
  timestamp of last NSM change and event.
* ospf_vty.c: (show_ip_ospf_neighbor_detail_sub) Print
  last state change timestamp and event, if available.

ospfd/ChangeLog
ospfd/ospf_neighbor.h
ospfd/ospf_nsm.c
ospfd/ospf_vty.c

index 79bb2bd1a422ce96af374183a90a23e444d7a517..1564bdbf738e3157597e81b77c587fabde7331e1 100644 (file)
          (ospf_nsm_event) call nsm_notice_state_changes from here.
          Move the debug message to entry of function, so it gets out
          even if something goes wrong.
+         Record state change timestamp and event in nbr struct.
+       * ospf_neighbor.h: (struct ospf_neighbor) Add fields to record
+         timestamp of last NSM change and event.
+       * ospf_vty.c: (show_ip_ospf_neighbor_detail_sub) Print 
+         last state change timestamp and event, if available.
 
 2006-07-10 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
index cbfbc2d8ad8458ea107e8a32d05af53ec2ec0319..9b7ff36e179a13020b0e629cc572a15564a1e12e 100644 (file)
@@ -82,6 +82,8 @@ struct ospf_neighbor
 
   /* Statistics Field */
   u_int32_t state_change;
+  struct timeval ts_last_change;
+  const char *last_event_str;
   struct ospf_nbr_nbma *nbr_nbma;
 };
 
index 1b4116d91cb41d9bc5ac28df4ed32cc5e209e31c..ff0a52d09ce14ad89c8b1edf0978932c64827889 100644 (file)
@@ -615,6 +615,9 @@ nsm_notice_state_change (struct ospf_neighbor *nbr, int next_state, int event)
                 LOOKUP (ospf_nsm_state_msg, next_state),
                 ospf_nsm_event_str [event]);
 
+  nbr->ts_last_change = recent_time;
+  nbr->last_event_str = ospf_nsm_event_str [event];
+
 #ifdef HAVE_SNMP
   /* Terminal state or regression */ 
   if ((next_state == NSM_Full) 
index ec002017574a047e38552a8f7785104981acecdc..44049d8c469f31da769c1db5b9144ede0345fd05 100644 (file)
@@ -3155,7 +3155,14 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
           nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
   /* Show state changes. */
   vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
-
+  if (nbr->ts_last_change.tv_sec || nbr->ts_last_change.tv_usec)
+    {
+      struct timeval res = tv_sub (recent_time, nbr->ts_last_change);
+      vty_out (vty, "    Last state change %s ago, due to %s%s",
+               ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
+               (nbr->last_event_str ? nbr->last_event_str : "??"),
+               VTY_NEWLINE);
+    }
   /* Show Designated Rotuer ID. */
   vty_out (vty, "    DR is %s,", inet_ntoa (nbr->d_router));
   /* Show Backup Designated Rotuer ID. */