From: Fernando Soto Date: Mon, 11 May 2015 20:52:00 +0000 (+0000) Subject: ospfd: trap on state change seems to send incorrect value for ospfNbrState X-Git-Tag: frr-2.0-rc1~722 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=66239ca6fe4e688b1069f293f3248004e4934d35;p=mirror%2Ffrr.git ospfd: trap on state change seems to send incorrect value for ospfNbrState 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) --- diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index baf01b22e4..23d1e3fc6c 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -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. */