From: Babis Chalios Date: Thu, 1 Oct 2020 09:07:54 +0000 (+0200) Subject: ospfd: fix invocation of ospfTrapNbrStateChange X-Git-Tag: base_7.6~408^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8ab046a480e8287e0451ed746bc1e37428816942;p=matthieu%2Ffrr.git ospfd: fix invocation of ospfTrapNbrStateChange 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 --- diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 63191d5cb5..8e5cb5bb36 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -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; }