]> git.puffer.fish Git - mirror/frr.git/commitdiff
[ospfd] Ensure NSM state functions can redirect next_state accidently
authorPaul Jakma <paul.jakma@sun.com>
Tue, 4 Jul 2006 13:44:19 +0000 (13:44 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Tue, 4 Jul 2006 13:44:19 +0000 (13:44 +0000)
2006-07-02 Paul Jakma <paul.jakma@sun.com>

* ospf_nsm.c: (ospf_nsm_event) Don't allow action functions to
  change next_state if the NSM tables do not indicate
  next_state is conditional, log warning if one tries -
  existing code appears fine though.

ospfd/ChangeLog
ospfd/ospf_nsm.c

index 7486b0733eae816ab5bc1955b9e23d13e339a538..e3805c82af0c3304688811b52729e78c1d082721 100644 (file)
@@ -3,6 +3,10 @@
        * ospf_nsm.c: (nsm_should_adj) New function, just consolidate the
          10.4 adjacency check from nsm_twoway_received/nsm_adj_ok.
          (nsm_twoway_received/nsm_adj_ok) Use former.
+         (ospf_nsm_event) Don't allow action functions to change
+         next_state if the NSM tables do not indicate next_state is
+         conditional, log warning if one tries - existing code
+         appears fine though.
 
 2006-06-30 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
index c5a55367517a6d8a9ffd2baf0fd26de815cf8e67..73ed088f0a0fee5d71e220916492c0eb37933081 100644 (file)
@@ -878,6 +878,22 @@ ospf_nsm_event (struct thread *thread)
 
   if (! next_state)
     next_state = NSM [nbr->state][event].next_state;
+  else if (NSM [nbr->state][event].next_state != NSM_DependUpon)
+    {
+      /* There's a mismatch between the FSM tables and what an FSM
+       * action/state-change function returned. State changes which
+       * do not have conditional/DependUpon next-states should not
+       * try set next_state.
+       */
+      zlog_warn ("NSM[%s:%s]: %s (%s): "
+                 "Warning: action tried to change next_state to %s",
+                 IF_NAME (oi), inet_ntoa (nbr->router_id),
+                 LOOKUP (ospf_nsm_state_msg, nbr->state),
+                 ospf_nsm_event_str [event],
+                 LOOKUP (ospf_nsm_state_msg, next_state));
+      
+      next_state = NSM [nbr->state][event].next_state;
+    }
 
   if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
     zlog_debug ("NSM[%s:%s]: %s (%s)", IF_NAME (oi),