]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospfd: fix invocation of ospfTrapNbrStateChange
authorBabis Chalios <mail@bchalios.io>
Thu, 1 Oct 2020 09:07:54 +0000 (11:07 +0200)
committerBabis Chalios <mail@bchalios.io>
Thu, 15 Oct 2020 09:16:01 +0000 (11:16 +0200)
ospfNbrStateChange is generated when the state of neighbor regresses or
it progresses to a terminal state. When transitioning to or from Full
state on non-broadcast multi-access and broadcast networks the trap
should be sent by the designated router. This last condition was not
taken into account when checking for the conditions of generating the
trap.

Fixes volta/volta-stack#1811

Signed-off-by: Babis Chalios <mail@bchalios.io>
ospfd/ospf_snmp.c

index 63191d5cb58ac7619f25b7bb4bb8ca6821815dda..8e5cb5bb36dd6ce48c7f2f64dfc2e00384ad70b8 100644 (file)
@@ -2486,20 +2486,25 @@ static void ospfTrapVirtNbrStateChange(struct ospf_neighbor *on)
 static int ospf_snmp_nsm_change(struct ospf_neighbor *nbr, int next_state,
                                int old_state)
 {
-       /* Terminal state or regression */
-       if ((next_state == NSM_Full) || (next_state == NSM_TwoWay)
-           || (next_state < old_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);
-       }
+       /* Transition to/from state Full should be handled only by
+        * DR when in Broadcast or Non-Brodcast Multi-Access networks
+        */
+       if ((next_state == NSM_Full || old_state == NSM_Full)
+           && (nbr->oi->state != ISM_DR)
+           && (nbr->oi->type == OSPF_IFTYPE_BROADCAST
+               || nbr->oi->type == OSPF_IFTYPE_NBMA))
+               return 0;
+
+       /* State progression to non-terminal state */
+       if (next_state > old_state && next_state != NSM_Full
+           && next_state != NSM_TwoWay)
+               return 0;
+
+       if (nbr->oi->type == OSPF_IFTYPE_VIRTUALLINK)
+               ospfTrapVirtNbrStateChange(nbr);
+       else
+               ospfTrapNbrStateChange(nbr);
+
        return 0;
 }