summaryrefslogtreecommitdiff
path: root/ospfd
diff options
context:
space:
mode:
authorPaul Jakma <paul.jakma@sun.com>2006-07-11 17:52:53 +0000
committerPaul Jakma <paul.jakma@sun.com>2006-07-11 17:52:53 +0000
commit3d63f38064f646129ddc67410cfdbbee8538f5cc (patch)
tree70d7eae92e0398a40e2858a7d9b3eaf8a71a6522 /ospfd
parent539e1523c7adfbe603535a64709e03650156c0b5 (diff)
[ospfd] trivial: NSM AdjChange should print event, declutter core functions
2006-07-10 Paul Jakma <paul.jakma@sun.com> * 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.
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ChangeLog7
-rw-r--r--ospfd/ospf_nsm.c90
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 <ajschorr@alumni.princeton.edu>
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);