summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_snmp.c
diff options
context:
space:
mode:
authorBabis Chalios <mail@bchalios.io>2020-10-01 11:07:54 +0200
committerBabis Chalios <mail@bchalios.io>2020-10-15 11:16:01 +0200
commit8ab046a480e8287e0451ed746bc1e37428816942 (patch)
tree816c4287f97c4a1aedae6fdde6874cd366660652 /ospfd/ospf_snmp.c
parentMerge pull request #7278 from donaldsharp/fix_blame_code (diff)
downloadfrr-8ab046a480e8287e0451ed746bc1e37428816942.tar.xz
frr-8ab046a480e8287e0451ed746bc1e37428816942.zip
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 <mail@bchalios.io>
Diffstat (limited to '')
-rw-r--r--ospfd/ospf_snmp.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index 63191d5cb..8e5cb5bb3 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;
}