From 3d63f38064f646129ddc67410cfdbbee8538f5cc Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Tue, 11 Jul 2006 17:52:53 +0000 Subject: [ospfd] trivial: NSM AdjChange should print event, declutter core functions 2006-07-10 Paul Jakma * ospf_nsm.c: (nsm_notice_state_changes) Move state change logging code to new func to declutter nsm_change_state and ospf_nsm_event. Log event with AdjChange, it's useful to know. (nsm_change_state) move adjchange and snmp logging to previous. (ospf_nsm_event) call nsm_notice_state_changes from here. Move the debug message to entry of function, so it gets out even if something goes wrong. --- ospfd/ChangeLog | 7 +++++ ospfd/ospf_nsm.c | 90 +++++++++++++++++++++++++++++++------------------------- 2 files changed, 57 insertions(+), 40 deletions(-) diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog index e84a470e..79bb2bd1 100644 --- a/ospfd/ChangeLog +++ b/ospfd/ChangeLog @@ -15,6 +15,13 @@ (nsm_inactivity_timer) " (nsm_ll_down) " (NSM) replace removed action functions with NULL. + (nsm_notice_state_changes) Move state change logging code to new + func to declutter nsm_change_state and ospf_nsm_event. + Log event with AdjChange, it's useful to know. + (nsm_change_state) move adjchange and snmp logging to previous. + (ospf_nsm_event) call nsm_notice_state_changes from here. + Move the debug message to entry of function, so it gets out + even if something goes wrong. 2006-07-10 Andrew J. Schorr diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index a71cb74d..1b4116d9 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -594,6 +594,46 @@ const static char *ospf_nsm_event_str[] = "LLDown", }; +static void +nsm_notice_state_change (struct ospf_neighbor *nbr, int next_state, int event) +{ + /* Logging change of status. */ + if (IS_DEBUG_OSPF (nsm, NSM_STATUS)) + zlog_debug ("NSM[%s:%s]: State change %s -> %s (%s)", + IF_NAME (nbr->oi), inet_ntoa (nbr->router_id), + LOOKUP (ospf_nsm_state_msg, nbr->state), + LOOKUP (ospf_nsm_state_msg, next_state), + ospf_nsm_event_str [event]); + + /* Optionally notify about adjacency changes */ + if (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES) && + (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL) || + (next_state == NSM_Full) || (next_state < nbr->state))) + zlog_notice("AdjChg: Nbr %s on %s: %s -> %s (%s)", + inet_ntoa (nbr->router_id), IF_NAME (nbr->oi), + LOOKUP (ospf_nsm_state_msg, nbr->state), + LOOKUP (ospf_nsm_state_msg, next_state), + 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 +} + void nsm_change_state (struct ospf_neighbor *nbr, int state) { @@ -603,13 +643,6 @@ nsm_change_state (struct ospf_neighbor *nbr, int state) int x; int force = 1; - /* Logging change of status. */ - if (IS_DEBUG_OSPF (nsm, NSM_STATUS)) - zlog_debug ("NSM[%s:%s]: State change %s -> %s", - IF_NAME (nbr->oi), inet_ntoa (nbr->router_id), - LOOKUP (ospf_nsm_state_msg, nbr->state), - LOOKUP (ospf_nsm_state_msg, state)); - /* Preserve old status. */ old_state = nbr->state; @@ -622,32 +655,6 @@ nsm_change_state (struct ospf_neighbor *nbr, int state) if (oi->type == OSPF_IFTYPE_VIRTUALLINK) vl_area = ospf_area_lookup_by_area_id (oi->ospf, oi->vl_data->vl_area_id); - /* Optionally notify about adjacency changes */ - if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES) && - (old_state != state) && - (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL) || - (state == NSM_Full) || (state < old_state))) - zlog_notice("AdjChg: Nbr %s on %s: %s -> %s", - inet_ntoa (nbr->router_id), IF_NAME (nbr->oi), - LOOKUP (ospf_nsm_state_msg, old_state), - LOOKUP (ospf_nsm_state_msg, state)); - -#ifdef HAVE_SNMP - /* Terminal state or regression */ - if ((state == NSM_Full) || (state == NSM_TwoWay) || (state < old_state)) - { - /* ospfVirtNbrStateChange */ - if (oi->type == OSPF_IFTYPE_VIRTUALLINK) - ospfTrapVirtNbrStateChange(nbr); - /* ospfNbrStateChange trap */ - else - /* To/From FULL, only managed by DR */ - if (((state != NSM_Full) && (old_state != NSM_Full)) || - (oi->state == ISM_DR)) - ospfTrapNbrStateChange(nbr); - } -#endif - /* One of the neighboring routers changes to/from the FULL state. */ if ((old_state != NSM_Full && state == NSM_Full) || (old_state == NSM_Full && state != NSM_Full)) @@ -781,6 +788,12 @@ ospf_nsm_event (struct thread *thread) event = THREAD_VAL (thread); router_id = nbr->router_id; + if (IS_DEBUG_OSPF (nsm, NSM_EVENTS)) + zlog_debug ("NSM[%s:%s]: %s (%s)", IF_NAME (nbr->oi), + inet_ntoa (nbr->router_id), + LOOKUP (ospf_nsm_state_msg, nbr->state), + ospf_nsm_event_str [event]); + next_state = NSM [nbr->state][event].next_state; /* Call function. */ @@ -808,15 +821,12 @@ ospf_nsm_event (struct thread *thread) assert (next_state != NSM_DependUpon); - if (IS_DEBUG_OSPF (nsm, NSM_EVENTS)) - zlog_debug ("NSM[%s:%s]: %s (%s)", IF_NAME (nbr->oi), - inet_ntoa (nbr->router_id), - LOOKUP (ospf_nsm_state_msg, nbr->state), - ospf_nsm_event_str [event]); - /* If state is changed. */ if (next_state != nbr->state) - nsm_change_state (nbr, next_state); + { + nsm_notice_state_change (nbr, next_state, event); + nsm_change_state (nbr, next_state); + } /* Make sure timer is set. */ nsm_timer_set (nbr); -- cgit v1.2.1