From d1b1cd8fb9309d89f10b95d59fb5b1420248895d Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Tue, 4 Jul 2006 13:50:44 +0000 Subject: [ospfd] Clear adjacency state for NSM changes down to TwoWay/ExStart 2006-07-02 Paul Jakma * ospf_nsm.c: (nsm_clear_adj) clear adjacency related state for a neighbour, needed for some state changes from > ExStart down to ExStart or less, which need not go through nsm_reset_nbr. (nsm_reset_nbr) move code to former. Should be static. (ospf_nsm_event) Remove long dead code. Use nsm_clear_adj for state changes that take down adjacencies to TwoWay/ExStart. (nsm_kill_nbr) Oops, action function shouldn't try return 1 for error. --- ospfd/ChangeLog | 9 +++++++++ ospfd/ospf_nsm.c | 42 +++++++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 15 deletions(-) (limited to 'ospfd') diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog index e6d04f32..e22b7a42 100644 --- a/ospfd/ChangeLog +++ b/ospfd/ChangeLog @@ -3,14 +3,23 @@ * ospf_nsm.c: (nsm_should_adj) New function, just consolidate the 10.4 adjacency check from nsm_twoway_received/nsm_adj_ok. (nsm_twoway_received/nsm_adj_ok) Use former. + (nsm_clear_adj) clear adjacency related state for a + neighbour, needed for some state changes from > ExStart down + to ExStart or less, which need not go through nsm_reset_nbr. + (nsm_reset_nbr) move code to former. Should be static. (ospf_nsm_event) Don't allow action functions to change next_state if the NSM tables do not indicate next_state is conditional, log warning if one tries - existing code appears fine though. + Remove long dead code. + Use nsm_clear_adj for state changes that take down + adjacencies to TwoWay/ExStart. (nsm_timer_set) ls_req timer should be OFF in early states. Compact several identical sections. Set inactivity timer to OFF for Down, for documentary purposes. + (nsm_kill_nbr) Oops, action function shouldn't try return + 1 for error. 2006-06-30 Andrew J. Schorr diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index 8c7c11a8..149ff7cb 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -49,8 +49,8 @@ #include "ospfd/ospf_abr.h" #include "ospfd/ospf_snmp.h" -void nsm_reset_nbr (struct ospf_neighbor *); - +static void nsm_reset_nbr (struct ospf_neighbor *); +static void nsm_clear_adj (struct ospf_neighbor *); /* OSPF NSM Timer functions. */ static int @@ -397,8 +397,12 @@ nsm_oneway_received (struct ospf_neighbor *nbr) return 0; } -void -nsm_reset_nbr (struct ospf_neighbor *nbr) +/* Clear adjacency related state for a neighbour, intended where nbr + * transitions from > ExStart (i.e. a Full or forming adjacency) + * to <= ExStart. + */ +static void +nsm_clear_adj (struct ospf_neighbor *nbr) { /* Clear Database Summary list. */ if (!ospf_db_summary_isempty (nbr)) @@ -411,6 +415,12 @@ nsm_reset_nbr (struct ospf_neighbor *nbr) /* Clear Link State Retransmission list. */ if (!ospf_ls_retransmit_isempty (nbr)) ospf_ls_retransmit_clear (nbr); +} + +static void +nsm_reset_nbr (struct ospf_neighbor *nbr) +{ + nsm_clear_adj (nbr); /* Cancel thread. */ OSPF_NSM_TIMER_OFF (nbr->t_db_desc); @@ -433,7 +443,7 @@ nsm_kill_nbr (struct ospf_neighbor *nbr) /* killing nbr_self is invalid */ assert (nbr != nbr->oi->nbr_self); if (nbr == nbr->oi->nbr_self) - return 1; + return 0; /* Reset neighbor. */ nsm_reset_nbr (nbr); @@ -748,10 +758,6 @@ nsm_change_state (struct ospf_neighbor *nbr, int state) if (vl_area->full_vls > 0) if (--vl_area->full_vls == 0) ospf_schedule_abr_task (oi->ospf); - - /* clear neighbor retransmit list */ - if (!ospf_ls_retransmit_isempty (nbr)) - ospf_ls_retransmit_clear (nbr); } zlog_info ("nsm_change_state(%s, %s -> %s): " @@ -790,6 +796,18 @@ nsm_change_state (struct ospf_neighbor *nbr, int state) ospf_opaque_nsm_change (nbr, old_state); #endif /* HAVE_OPAQUE_LSA */ + /* State changes from > ExStart to <= ExStart should clear any Exchange + * or Full/LSA Update related lists and state. + * Potential causal events: BadLSReq, SeqNumberMismatch, AdjOK? + * + * Note that transitions from > ExStart to < 2-Way (e.g. due to + * KillNbr or 1-Way) must and will do the same, but via + * nsm_reset_nbr. + */ + if (old_state > NSM_ExStart + && (state == NSM_ExStart || state == NSM_TwoWay)) + nsm_clear_adj (nbr); + /* Start DD exchange protocol */ if (state == NSM_ExStart) { @@ -807,11 +825,6 @@ nsm_change_state (struct ospf_neighbor *nbr, int state) nbr->crypt_seqnum = 0; /* Generete NeighborChange ISM event. */ -#ifdef BUGGY_ISM_TRANSITION - if ((old_state < NSM_TwoWay && state >= NSM_TwoWay) || - (old_state >= NSM_TwoWay && state < NSM_TwoWay)) - OSPF_ISM_EVENT_EXECUTE (oi, ISM_NeighborChange); -#else /* BUGGY_ISM_TRANSITION */ switch (oi->state) { case ISM_DROther: case ISM_Backup: @@ -824,7 +837,6 @@ nsm_change_state (struct ospf_neighbor *nbr, int state) /* ISM_PointToPoint -> ISM_Down, ISM_Loopback -> ISM_Down, etc. */ break; } -#endif /* BUGGY_ISM_TRANSITION */ /* Performance hack. Send hello immideately when some neighbor enter Init state. This whay we decrease neighbor discovery time. Gleb.*/ -- cgit v1.2.1