]> git.puffer.fish Git - mirror/frr.git/commitdiff
[ospfd] trivial: NSM AdjChange should print event, declutter core functions
authorPaul Jakma <paul.jakma@sun.com>
Tue, 11 Jul 2006 17:52:53 +0000 (17:52 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Tue, 11 Jul 2006 17:52:53 +0000 (17:52 +0000)
2006-07-10 Paul Jakma <paul.jakma@sun.com>

* ospf_nsm.c: (nsm_notice_state_changes) Move state change
  logging code to new func to declutter nsm_change_state and
  ospf_nsm_event.
  Log event with AdjChange, it's useful to know.
  (nsm_change_state) move adjchange and snmp logging to previous.
  (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.

ospfd/ChangeLog
ospfd/ospf_nsm.c

index e84a470e218ce7051c45692e3df2cf1df0ad5138..79bb2bd1a422ce96af374183a90a23e444d7a517 100644 (file)
          (nsm_inactivity_timer)      "
          (nsm_ll_down)               "
          (NSM) replace removed action functions with NULL.
+         (nsm_notice_state_changes) Move state change logging code to new
+         func to declutter nsm_change_state and ospf_nsm_event.
+         Log event with AdjChange, it's useful to know.
+         (nsm_change_state) move adjchange and snmp logging to previous.
+         (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.
 
 2006-07-10 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
index a71cb74df1f9c36ec56097e53a2c176622d86224..1b4116d91cb41d9bc5ac28df4ed32cc5e209e31c 100644 (file)
@@ -594,6 +594,46 @@ const static char *ospf_nsm_event_str[] =
   "LLDown",
 };
 
+static void
+nsm_notice_state_change (struct ospf_neighbor *nbr, int next_state, int event)
+{
+  /* Logging change of status. */
+  if (IS_DEBUG_OSPF (nsm, NSM_STATUS))
+    zlog_debug ("NSM[%s:%s]: State change %s -> %s (%s)",
+               IF_NAME (nbr->oi), inet_ntoa (nbr->router_id),
+               LOOKUP (ospf_nsm_state_msg, nbr->state),
+               LOOKUP (ospf_nsm_state_msg, next_state),
+               ospf_nsm_event_str [event]);
+
+  /* Optionally notify about adjacency changes */
+  if (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES) &&
+      (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL) ||
+       (next_state == NSM_Full) || (next_state < nbr->state)))
+    zlog_notice("AdjChg: Nbr %s on %s: %s -> %s (%s)",
+                inet_ntoa (nbr->router_id), IF_NAME (nbr->oi),
+                LOOKUP (ospf_nsm_state_msg, nbr->state),
+                LOOKUP (ospf_nsm_state_msg, next_state),
+                ospf_nsm_event_str [event]);
+
+#ifdef HAVE_SNMP
+  /* Terminal state or regression */ 
+  if ((next_state == NSM_Full) 
+      || (next_state == NSM_TwoWay)
+      || (next_state < nbr->state))
+    {
+      /* ospfVirtNbrStateChange */
+      if (nbr->oi->type == OSPF_IFTYPE_VIRTUALLINK)
+        ospfTrapVirtNbrStateChange(nbr);
+      /* ospfNbrStateChange trap  */
+      else     
+        /* To/From FULL, only managed by DR */
+        if (((next_state != NSM_Full) && (nbr->state != NSM_Full)) 
+            || (nbr->oi->state == ISM_DR))
+          ospfTrapNbrStateChange(nbr);
+    }
+#endif
+}
+
 void
 nsm_change_state (struct ospf_neighbor *nbr, int state)
 {
@@ -603,13 +643,6 @@ nsm_change_state (struct ospf_neighbor *nbr, int state)
   int x;
   int force = 1;
   
-  /* Logging change of status. */
-  if (IS_DEBUG_OSPF (nsm, NSM_STATUS))
-    zlog_debug ("NSM[%s:%s]: State change %s -> %s",
-              IF_NAME (nbr->oi), inet_ntoa (nbr->router_id),
-              LOOKUP (ospf_nsm_state_msg, nbr->state),
-              LOOKUP (ospf_nsm_state_msg, state));
-
   /* Preserve old status. */
   old_state = nbr->state;
 
@@ -622,32 +655,6 @@ nsm_change_state (struct ospf_neighbor *nbr, int state)
   if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
     vl_area = ospf_area_lookup_by_area_id (oi->ospf, oi->vl_data->vl_area_id);
 
-  /* Optionally notify about adjacency changes */
-  if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES) &&
-      (old_state != state) &&
-      (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL) ||
-       (state == NSM_Full) || (state < old_state)))
-    zlog_notice("AdjChg: Nbr %s on %s: %s -> %s",
-                inet_ntoa (nbr->router_id), IF_NAME (nbr->oi),
-                LOOKUP (ospf_nsm_state_msg, old_state),
-                LOOKUP (ospf_nsm_state_msg, state));
-
-#ifdef HAVE_SNMP
-  /* Terminal state or regression */ 
-  if ((state == NSM_Full) || (state == NSM_TwoWay) || (state < old_state))
-    {
-      /* ospfVirtNbrStateChange */
-      if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
-        ospfTrapVirtNbrStateChange(nbr);
-      /* ospfNbrStateChange trap  */
-      else     
-        /* To/From FULL, only managed by DR */
-        if (((state != NSM_Full) && (old_state != NSM_Full)) ||
-            (oi->state == ISM_DR))
-          ospfTrapNbrStateChange(nbr);
-    }
-#endif
-
   /* One of the neighboring routers changes to/from the FULL state. */
   if ((old_state != NSM_Full && state == NSM_Full) ||
       (old_state == NSM_Full && state != NSM_Full))
@@ -781,6 +788,12 @@ ospf_nsm_event (struct thread *thread)
   event = THREAD_VAL (thread);
   router_id = nbr->router_id;
 
+  if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
+    zlog_debug ("NSM[%s:%s]: %s (%s)", IF_NAME (nbr->oi),
+              inet_ntoa (nbr->router_id),
+              LOOKUP (ospf_nsm_state_msg, nbr->state),
+              ospf_nsm_event_str [event]);
+  
   next_state = NSM [nbr->state][event].next_state;
 
   /* Call function. */
@@ -808,15 +821,12 @@ ospf_nsm_event (struct thread *thread)
 
   assert (next_state != NSM_DependUpon);
   
-  if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
-    zlog_debug ("NSM[%s:%s]: %s (%s)", IF_NAME (nbr->oi),
-              inet_ntoa (nbr->router_id),
-              LOOKUP (ospf_nsm_state_msg, nbr->state),
-              ospf_nsm_event_str [event]);
-  
   /* If state is changed. */
   if (next_state != nbr->state)
-    nsm_change_state (nbr, next_state);
+    {
+      nsm_notice_state_change (nbr, next_state, event);
+      nsm_change_state (nbr, next_state);
+    }
 
   /* Make sure timer is set. */
   nsm_timer_set (nbr);