]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: trap on state change seems to send incorrect value for ospfNbrState
authorFernando Soto <fsoto@bluecatnetworks.com>
Mon, 11 May 2015 20:52:00 +0000 (20:52 +0000)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Thu, 26 May 2016 15:33:31 +0000 (15:33 +0000)
The ospfNbrState in the ospf trap sent from ospfd shows an incorrect state.

For example, when the connection goes down, the ospfNbrState in the trap is
sent as '8' (full).  When the connection is reestablished, the state is sent
as '7' (loading).

The reason seems to be that the trap is sent from nsm_notice_state_change()
before the state is actually updated by calling nsm_change_state().

After applying the attached patch, the traps are sent with nbrState '1' when
the connection goes down and '8' when it goes back up.

Bugzilla #833 https://bugzilla.quagga.net/show_bug.cgi?id=833

(cherry picked from commit b6404390a713144252b62f49a328315d1952c6d8)

ospfd/ospf_nsm.c

index baf01b22e4fdf3349ad4a28d6dc77edd7f3434f0..23d1e3fc6cbb7281b742f7b65140aecde29b64f0 100644 (file)
@@ -644,23 +644,6 @@ nsm_notice_state_change (struct ospf_neighbor *nbr, int next_state, int event)
       nbr->last_regress_str = 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
 }
 
 static void
@@ -865,7 +848,34 @@ ospf_nsm_event (struct thread *thread)
   if (next_state != nbr->state)
     {
       nsm_notice_state_change (nbr, next_state, event);
+#ifdef HAVE_SNMP
+      int send_trap_virt = 0;
+      int send_trap = 0;
+      /* 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)
+             send_trap_virt = 1;
+         /* ospfNbrStateChange trap  */
+         else  
+             /* To/From FULL, only managed by DR */
+             if (((next_state != NSM_Full) && (nbr->state != NSM_Full)) 
+                     || (nbr->oi->state == ISM_DR))
+                 send_trap = 1;
+      }
+#endif
       nsm_change_state (nbr, next_state);
+
+#ifdef HAVE_SNMP
+      if (send_trap_virt) {
+         ospfTrapVirtNbrStateChange(nbr);
+      } else if (send_trap) {
+         ospfTrapNbrStateChange(nbr);
+      }
+#endif
     }
 
   /* Make sure timer is set. */