ospfd: Unify router and network LSA refresh logic with general refresher

* (general) Get rid of the router and network LSA specific refresh timers
  and make the general refresher do this instead. Get rid of the twiddling
  of timers for router/network LSA that was spread across the code.

  This lays the foundations for future, general LSA refresh improvements,
  such as making sequence rollover work, and having generic LSA delays.

* ospfd.h: (struct ospf) Bye bye to the router-lsa update timer thread
  pointer.
  (struct ospf_area) and to the router-lsa refresh timer.
* ospf_interface.h: Remove the network_lsa_self timer thread pointer
* ospf_lsa.h: (struct ospf_lsa) oi field should always be there, for benefit
  of type-2/network LSA processing.
  (ospf_{router,network}_lsa_{update_timer,timer_add}) no timers for these
  more
  (ospf_{router,network}_lsa_update) more generic functions to indicate that some
  router/network LSAs need updating
  (ospf_router_lsa_update_area) update router lsa in a particular area alone.
  (ospf_{summary,summary_asbr,network}_lsa_refresh) replaced by the general
  ospf_lsa_refresh function.
  (ospf_lsa_refresh) general LSA refresh function
This commit is contained in:
Paul Jakma 2010-01-24 22:42:13 +00:00
parent 7eb5b47e54
commit c363d3861b
12 changed files with 107 additions and 201 deletions

View File

@ -565,8 +565,7 @@ ospf_check_abr_status (struct ospf *ospf)
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_check_abr_status(): new router flags: %x",new_flags); zlog_debug ("ospf_check_abr_status(): new router flags: %x",new_flags);
ospf->flags = new_flags; ospf->flags = new_flags;
OSPF_TIMER_ON (ospf->t_router_lsa_update, ospf_router_lsa_update (ospf);
ospf_router_lsa_update_timer, OSPF_LSA_UPDATE_DELAY);
} }
} }
@ -760,7 +759,7 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost,
zlog_debug ("ospf_abr_announce_network_to_area(): " zlog_debug ("ospf_abr_announce_network_to_area(): "
"refreshing summary"); "refreshing summary");
set_metric (old, cost); set_metric (old, cost);
lsa = ospf_summary_lsa_refresh (area->ospf, old); lsa = ospf_lsa_refresh (area->ospf, old);
if (!lsa) if (!lsa)
{ {
@ -1148,7 +1147,7 @@ ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost,
if (old) if (old)
{ {
set_metric (old, cost); set_metric (old, cost);
lsa = ospf_summary_asbr_lsa_refresh (area->ospf, old); lsa = ospf_lsa_refresh (area->ospf, old);
} }
else else
lsa = ospf_summary_asbr_lsa_originate (p, cost, area); lsa = ospf_summary_asbr_lsa_originate (p, cost, area);

View File

@ -264,8 +264,7 @@ ospf_asbr_status_update (struct ospf *ospf, u_char status)
/* Transition from/to status ASBR, schedule timer. */ /* Transition from/to status ASBR, schedule timer. */
ospf_spf_calculate_schedule (ospf); ospf_spf_calculate_schedule (ospf);
OSPF_TIMER_ON (ospf->t_router_lsa_update, ospf_router_lsa_update (ospf);
ospf_router_lsa_update_timer, OSPF_LSA_UPDATE_DELAY);
} }
void void

View File

@ -135,7 +135,7 @@ ospf_process_self_originated_lsa (struct ospf *ospf,
/* Originate a new instance and schedule flooding */ /* Originate a new instance and schedule flooding */
if (area->router_lsa_self) if (area->router_lsa_self)
area->router_lsa_self->data->ls_seqnum = new->data->ls_seqnum; area->router_lsa_self->data->ls_seqnum = new->data->ls_seqnum;
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
return; return;
case OSPF_NETWORK_LSA: case OSPF_NETWORK_LSA:
#ifdef HAVE_OPAQUE_LSA #ifdef HAVE_OPAQUE_LSA
@ -171,7 +171,7 @@ ospf_process_self_originated_lsa (struct ospf *ospf,
if (oi->network_lsa_self) if (oi->network_lsa_self)
oi->network_lsa_self->data->ls_seqnum = new->data->ls_seqnum; oi->network_lsa_self->data->ls_seqnum = new->data->ls_seqnum;
/* Schedule network-LSA origination. */ /* Schedule network-LSA origination. */
ospf_network_lsa_timer_add (oi); ospf_network_lsa_update (oi);
return; return;
} }
break; break;

View File

@ -97,7 +97,7 @@ ospf_if_recalculate_output_cost (struct interface *ifp)
if (oi->output_cost != newcost) if (oi->output_cost != newcost)
{ {
oi->output_cost = newcost; oi->output_cost = newcost;
ospf_router_lsa_timer_add (oi->area); ospf_router_lsa_update_area (oi->area);
} }
} }
} }
@ -298,8 +298,6 @@ ospf_if_cleanup (struct ospf_interface *oi)
ospf_nbr_delete (oi->nbr_self); ospf_nbr_delete (oi->nbr_self);
oi->nbr_self = ospf_nbr_new (oi); oi->nbr_self = ospf_nbr_new (oi);
ospf_nbr_add_self (oi); ospf_nbr_add_self (oi);
OSPF_TIMER_OFF (oi->t_network_lsa_self);
} }
void void
@ -1121,8 +1119,8 @@ ospf_vl_up_check (struct ospf_area *area, struct in_addr rid,
if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
zlog_debug ("ospf_vl_up_check: VL cost change," zlog_debug ("ospf_vl_up_check: VL cost change,"
" scheduling router lsa refresh"); " scheduling router lsa refresh");
if(ospf->backbone) if (ospf->backbone)
ospf_router_lsa_timer_add (ospf->backbone); ospf_router_lsa_update_area (ospf->backbone);
else if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) else if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
zlog_debug ("ospf_vl_up_check: VL cost change, no backbone!"); zlog_debug ("ospf_vl_up_check: VL cost change, no backbone!");
} }

View File

@ -210,8 +210,6 @@ struct ospf_interface
struct thread *t_ls_ack; /* timer */ struct thread *t_ls_ack; /* timer */
struct thread *t_ls_ack_direct; /* event */ struct thread *t_ls_ack_direct; /* event */
struct thread *t_ls_upd_event; /* event */ struct thread *t_ls_upd_event; /* event */
struct thread *t_network_lsa_self; /* self-originated network-LSA
reflesh thread. timer */
#ifdef HAVE_OPAQUE_LSA #ifdef HAVE_OPAQUE_LSA
struct thread *t_opaque_lsa_self; /* Type-9 Opaque-LSAs */ struct thread *t_opaque_lsa_self; /* Type-9 Opaque-LSAs */
#endif /* HAVE_OPAQUE_LSA */ #endif /* HAVE_OPAQUE_LSA */

View File

@ -578,20 +578,17 @@ ism_change_state (struct ospf_interface *oi, int state)
oi->area->act_ints++; oi->area->act_ints++;
/* schedule router-LSA originate. */ /* schedule router-LSA originate. */
ospf_router_lsa_timer_add (oi->area); ospf_router_lsa_update_area (oi->area);
/* Originate network-LSA. */ /* Originate network-LSA. */
if (old_state != ISM_DR && state == ISM_DR) if (old_state != ISM_DR && state == ISM_DR)
ospf_network_lsa_timer_add (oi); ospf_network_lsa_update (oi);
else if (old_state == ISM_DR && state != ISM_DR) else if (old_state == ISM_DR && state != ISM_DR)
{ {
/* Free self originated network LSA. */ /* Free self originated network LSA. */
lsa = oi->network_lsa_self; lsa = oi->network_lsa_self;
if (lsa) if (lsa)
{
ospf_lsa_flush_area (lsa, oi->area); ospf_lsa_flush_area (lsa, oi->area);
OSPF_TIMER_OFF (oi->t_network_lsa_self);
}
ospf_lsa_unlock (&oi->network_lsa_self); ospf_lsa_unlock (&oi->network_lsa_self);
oi->network_lsa_self = NULL; oi->network_lsa_self = NULL;

View File

@ -741,7 +741,7 @@ ospf_stub_router_timer (struct thread *t)
UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
return 0; return 0;
} }
@ -885,6 +885,9 @@ ospf_router_lsa_refresh (struct ospf_lsa *lsa)
/* Delete LSA from neighbor retransmit-list. */ /* Delete LSA from neighbor retransmit-list. */
ospf_ls_retransmit_delete_nbr_area (area, lsa); ospf_ls_retransmit_delete_nbr_area (area, lsa);
/* Unregister LSA from refresh-list */
ospf_refresher_unregister_lsa (area->ospf, lsa);
/* Create new router-LSA instance. */ /* Create new router-LSA instance. */
if ( (new = ospf_router_lsa_new (area)) == NULL) if ( (new = ospf_router_lsa_new (area)) == NULL)
{ {
@ -910,20 +913,15 @@ ospf_router_lsa_refresh (struct ospf_lsa *lsa)
return NULL; return NULL;
} }
static int int
ospf_router_lsa_timer (struct thread *t) ospf_router_lsa_update_area (struct ospf_area *area)
{ {
struct ospf_area *area;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("Timer[router-LSA]: (router-LSA Refresh expire)"); zlog_debug ("[router-LSA]: (router-LSA area update)");
area = THREAD_ARG (t);
area->t_router_lsa_self = NULL;
/* Now refresh router-LSA. */ /* Now refresh router-LSA. */
if (area->router_lsa_self) if (area->router_lsa_self)
ospf_router_lsa_refresh (area->router_lsa_self); ospf_lsa_refresh (area->ospf, area->router_lsa_self);
/* Newly originate router-LSA. */ /* Newly originate router-LSA. */
else else
ospf_router_lsa_originate (area); ospf_router_lsa_originate (area);
@ -931,50 +929,15 @@ ospf_router_lsa_timer (struct thread *t)
return 0; return 0;
} }
void
ospf_router_lsa_timer_add (struct ospf_area *area)
{
/* Keep area's self-originated router-LSA. */
struct ospf_lsa *lsa = area->router_lsa_self;
/* Cancel previously scheduled router-LSA timer. */
if (area->t_router_lsa_self)
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("LSA[Type1]: Cancel previous router-LSA timer");
OSPF_TIMER_OFF (area->t_router_lsa_self);
/* If router-LSA is originated previously, check the interval time. */
if (lsa)
{
int delay;
if ((delay = ospf_lsa_refresh_delay (lsa)) > 0)
{
OSPF_AREA_TIMER_ON (area->t_router_lsa_self,
ospf_router_lsa_timer, delay);
return;
}
}
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("LSA[Type1]: Scheduling router-LSA origination right away");
/* Immediately refresh router-LSA. */
OSPF_AREA_TIMER_ON (area->t_router_lsa_self, ospf_router_lsa_timer, 0);
}
int int
ospf_router_lsa_update_timer (struct thread *thread) ospf_router_lsa_update (struct ospf *ospf)
{ {
struct ospf *ospf = THREAD_ARG (thread);
struct listnode *node, *nnode; struct listnode *node, *nnode;
struct ospf_area *area; struct ospf_area *area;
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("Timer[router-LSA Update]: (timer expire)"); zlog_debug ("Timer[router-LSA Update]: (timer expire)");
ospf->t_router_lsa_update = NULL;
for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{ {
struct ospf_lsa *lsa = area->router_lsa_self; struct ospf_lsa *lsa = area->router_lsa_self;
@ -1004,14 +967,14 @@ ospf_router_lsa_update_timer (struct thread *thread)
area->router_lsa_self = NULL; area->router_lsa_self = NULL;
/* Refresh router-LSA, (not install) and flood through area. */ /* Refresh router-LSA, (not install) and flood through area. */
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
} }
else else
{ {
rl = (struct router_lsa *) lsa->data; rl = (struct router_lsa *) lsa->data;
/* Refresh router-LSA, (not install) and flood through area. */ /* Refresh router-LSA, (not install) and flood through area. */
if (rl->flags != ospf->flags) if (rl->flags != ospf->flags)
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
} }
} }
@ -1081,6 +1044,7 @@ ospf_network_lsa_new (struct ospf_interface *oi)
} }
new->area = oi->area; new->area = oi->area;
new->oi = oi;
SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED); SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
/* Copy LSA to store. */ /* Copy LSA to store. */
@ -1108,15 +1072,21 @@ ospf_network_lsa_new (struct ospf_interface *oi)
} }
/* Originate network-LSA. */ /* Originate network-LSA. */
static struct ospf_lsa * void
ospf_network_lsa_originate (struct ospf_interface *oi) ospf_network_lsa_update (struct ospf_interface *oi)
{ {
struct ospf_lsa *new; struct ospf_lsa *new;
if (oi->network_lsa_self != NULL)
{
ospf_lsa_refresh (oi->ospf, oi->network_lsa_self);
return;
}
/* Create new network-LSA instance. */ /* Create new network-LSA instance. */
new = ospf_network_lsa_new (oi); new = ospf_network_lsa_new (oi);
if (new == NULL) if (new == NULL)
return NULL; return;
/* Install LSA to LSDB. */ /* Install LSA to LSDB. */
new = ospf_lsa_install (oi->ospf, oi, new); new = ospf_lsa_install (oi->ospf, oi, new);
@ -1134,31 +1104,37 @@ ospf_network_lsa_originate (struct ospf_interface *oi)
ospf_lsa_header_dump (new->data); ospf_lsa_header_dump (new->data);
} }
return new; return;
} }
int static struct ospf_lsa *
ospf_network_lsa_refresh (struct ospf_lsa *lsa, struct ospf_interface *oi) ospf_network_lsa_refresh (struct ospf_lsa *lsa)
{ {
struct ospf_area *area = lsa->area; struct ospf_area *area = lsa->area;
struct ospf_lsa *new; struct ospf_lsa *new, *new2;
struct ospf_if_params *oip; struct ospf_if_params *oip;
struct ospf_interface *oi = lsa->oi;
assert (lsa->data); assert (lsa->data);
/* Delete LSA from neighbor retransmit-list. */ /* Delete LSA from neighbor retransmit-list. */
ospf_ls_retransmit_delete_nbr_area (area, lsa); ospf_ls_retransmit_delete_nbr_area (area, lsa);
/* Unregister LSA from refresh-list */
ospf_refresher_unregister_lsa (area->ospf, lsa);
/* Create new network-LSA instance. */ /* Create new network-LSA instance. */
new = ospf_network_lsa_new (oi); new = ospf_network_lsa_new (oi);
if (new == NULL) if (new == NULL)
return -1; return NULL;
oip = ospf_lookup_if_params (oi->ifp, oi->address->u.prefix4); oip = ospf_lookup_if_params (oi->ifp, oi->address->u.prefix4);
assert (oip != NULL); assert (oip != NULL);
oip->network_lsa_seqnum = new->data->ls_seqnum = lsa_seqnum_increment (lsa); oip->network_lsa_seqnum = new->data->ls_seqnum = lsa_seqnum_increment (lsa);
ospf_lsa_install (area->ospf, oi, new); new2 = ospf_lsa_install (area->ospf, oi, new);
assert (new2 == new);
/* Flood LSA through aera. */ /* Flood LSA through aera. */
ospf_flood_through_area (area, NULL, new); ospf_flood_through_area (area, NULL, new);
@ -1170,60 +1146,8 @@ ospf_network_lsa_refresh (struct ospf_lsa *lsa, struct ospf_interface *oi)
ospf_lsa_header_dump (new->data); ospf_lsa_header_dump (new->data);
} }
return 0; return new;
} }
static int
ospf_network_lsa_refresh_timer (struct thread *t)
{
struct ospf_interface *oi;
oi = THREAD_ARG (t);
oi->t_network_lsa_self = NULL;
if (oi->network_lsa_self)
/* Now refresh network-LSA. */
ospf_network_lsa_refresh (oi->network_lsa_self, oi);
else
/* Newly create network-LSA. */
ospf_network_lsa_originate (oi);
return 0;
}
void
ospf_network_lsa_timer_add (struct ospf_interface *oi)
{
/* Keep interface's self-originated network-LSA. */
struct ospf_lsa *lsa = oi->network_lsa_self;
/* Cancel previously schedules network-LSA timer. */
if (oi->t_network_lsa_self)
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("LSA[Type2]: Cancel previous network-LSA timer");
OSPF_TIMER_OFF (oi->t_network_lsa_self);
/* If network-LSA is originated previously, check the interval time. */
if (lsa)
{
int delay;
if ((delay = ospf_lsa_refresh_delay (lsa)) > 0)
{
oi->t_network_lsa_self =
thread_add_timer (master, ospf_network_lsa_refresh_timer,
oi, delay);
return;
}
}
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("Scheduling network-LSA origination right away");
/* Immediately refresh network-LSA. */
oi->t_network_lsa_self =
thread_add_event (master, ospf_network_lsa_refresh_timer, oi, 0);
}
static void static void
stream_put_ospf_metric (struct stream *s, u_int32_t metric_value) stream_put_ospf_metric (struct stream *s, u_int32_t metric_value)
@ -1347,7 +1271,7 @@ ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
return new; return new;
} }
struct ospf_lsa* static struct ospf_lsa*
ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa) ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
{ {
struct ospf_lsa *new; struct ospf_lsa *new;
@ -1494,7 +1418,7 @@ ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
return new; return new;
} }
struct ospf_lsa* static struct ospf_lsa*
ospf_summary_asbr_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa) ospf_summary_asbr_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
{ {
struct ospf_lsa *new; struct ospf_lsa *new;
@ -2348,7 +2272,7 @@ ospf_external_lsa_refresh_type (struct ospf *ospf, u_char type, int force)
} }
/* Refresh AS-external-LSA. */ /* Refresh AS-external-LSA. */
void struct ospf_lsa *
ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa, ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
struct external_info *ei, int force) struct external_info *ei, int force)
{ {
@ -2364,7 +2288,7 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
lsa->data->type, inet_ntoa (lsa->data->id)); lsa->data->type, inet_ntoa (lsa->data->id));
ospf_external_lsa_flush (ospf, ei->type, &ei->p, ospf_external_lsa_flush (ospf, ei->type, &ei->p,
ei->ifindex /*, ei->nexthop */); ei->ifindex /*, ei->nexthop */);
return; return NULL;
} }
if (!changed && !force) if (!changed && !force)
@ -2372,7 +2296,7 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("LSA[Type%d:%s]: Not refreshed, not changed/forced", zlog_debug ("LSA[Type%d:%s]: Not refreshed, not changed/forced",
lsa->data->type, inet_ntoa (lsa->data->id)); lsa->data->type, inet_ntoa (lsa->data->id));
return; return NULL;
} }
/* Delete LSA from neighbor retransmit-list. */ /* Delete LSA from neighbor retransmit-list. */
@ -2388,7 +2312,7 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("LSA[Type%d:%s]: Could not be refreshed", lsa->data->type, zlog_debug ("LSA[Type%d:%s]: Could not be refreshed", lsa->data->type,
inet_ntoa (lsa->data->id)); inet_ntoa (lsa->data->id));
return; return NULL;
} }
new->data->ls_seqnum = lsa_seqnum_increment (lsa); new->data->ls_seqnum = lsa_seqnum_increment (lsa);
@ -2417,7 +2341,7 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
ospf_lsa_header_dump (new->data); ospf_lsa_header_dump (new->data);
} }
return; return new;
} }
@ -2425,8 +2349,8 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
/* Install router-LSA to an area. */ /* Install router-LSA to an area. */
static struct ospf_lsa * static struct ospf_lsa *
ospf_router_lsa_install (struct ospf *ospf, ospf_router_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
struct ospf_lsa *new, int rt_recalc) int rt_recalc)
{ {
struct ospf_area *area = new->area; struct ospf_area *area = new->area;
@ -2445,15 +2369,11 @@ ospf_router_lsa_install (struct ospf *ospf,
if (CHECK_FLAG (new->flags, OSPF_LSA_RECEIVED)) if (CHECK_FLAG (new->flags, OSPF_LSA_RECEIVED))
return new; /* ignore stale LSA */ return new; /* ignore stale LSA */
/* Set router-LSA refresh timer. */
OSPF_TIMER_OFF (area->t_router_lsa_self);
OSPF_AREA_TIMER_ON (area->t_router_lsa_self,
ospf_router_lsa_timer, OSPF_LS_REFRESH_TIME);
/* Set self-originated router-LSA. */ /* Set self-originated router-LSA. */
ospf_lsa_unlock (&area->router_lsa_self); ospf_lsa_unlock (&area->router_lsa_self);
area->router_lsa_self = ospf_lsa_lock (new); area->router_lsa_self = ospf_lsa_lock (new);
ospf_refresher_register_lsa (ospf, new);
} }
if (rt_recalc) if (rt_recalc)
ospf_spf_calculate_schedule (ospf); ospf_spf_calculate_schedule (ospf);
@ -2486,15 +2406,9 @@ ospf_network_lsa_install (struct ospf *ospf,
if (CHECK_FLAG (new->flags, OSPF_LSA_RECEIVED)) if (CHECK_FLAG (new->flags, OSPF_LSA_RECEIVED))
return new; /* ignore stale LSA */ return new; /* ignore stale LSA */
/* Set LSRefresh timer. */
OSPF_TIMER_OFF (oi->t_network_lsa_self);
OSPF_INTERFACE_TIMER_ON (oi->t_network_lsa_self,
ospf_network_lsa_refresh_timer,
OSPF_LS_REFRESH_TIME);
ospf_lsa_unlock (&oi->network_lsa_self); ospf_lsa_unlock (&oi->network_lsa_self);
oi->network_lsa_self = ospf_lsa_lock (new); oi->network_lsa_self = ospf_lsa_lock (new);
ospf_refresher_register_lsa (ospf, new);
} }
if (rt_recalc) if (rt_recalc)
ospf_spf_calculate_schedule (ospf); ospf_spf_calculate_schedule (ospf);
@ -2742,7 +2656,8 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi,
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH)) if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
{ {
zlog_debug ("ospf_lsa_install() Premature Aging " zlog_debug ("ospf_lsa_install() Premature Aging "
"lsa 0x%lx", (u_long)lsa); "lsa 0x%p, seqnum 0x%x",
lsa, ntohl(lsa->data->ls_seqnum));
ospf_lsa_header_dump (lsa->data); ospf_lsa_header_dump (lsa->data);
} }
} }
@ -2954,12 +2869,11 @@ ospf_maxage_lsa_remover (struct thread *thread)
ospf_flood_through (ospf, NULL, lsa); ospf_flood_through (ospf, NULL, lsa);
#endif /* ORIGINAL_CODING */ #endif /* ORIGINAL_CODING */
if (lsa->flags & OSPF_LSA_PREMATURE_AGE) if (CHECK_FLAG (lsa->flags, OSPF_LSA_PREMATURE_AGE))
{ {
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
zlog_debug ("originating new router lsa for lsa 0x%lx \n", zlog_debug ("originating new lsa for lsa 0x%p\n", lsa);
(u_long)lsa); ospf_lsa_refresh (ospf, lsa);
ospf_router_lsa_originate(lsa->area);
} }
/* Remove from lsdb. */ /* Remove from lsdb. */
@ -3060,6 +2974,10 @@ ospf_lsa_maxage_walker_remover (struct ospf *ospf, struct ospf_lsa *lsa)
ospf_lsa_maxage (ospf, lsa); ospf_lsa_maxage (ospf, lsa);
} }
if (IS_LSA_MAXAGE (lsa) && !ospf_lsa_is_self_originated (ospf, lsa))
if (LS_AGE (lsa) > OSPF_LSA_MAXAGE + 30)
printf ("Eek! Shouldn't happen!\n");
return 0; return 0;
} }
@ -3413,7 +3331,6 @@ ospf_flush_self_originated_lsas_now (struct ospf *ospf)
ospf_lsa_flush_area (lsa, area); ospf_lsa_flush_area (lsa, area);
ospf_lsa_unlock (&area->router_lsa_self); ospf_lsa_unlock (&area->router_lsa_self);
area->router_lsa_self = NULL; area->router_lsa_self = NULL;
OSPF_TIMER_OFF (area->t_router_lsa_self);
} }
for (ALL_LIST_ELEMENTS (area->oiflist, node2, nnode2, oi)) for (ALL_LIST_ELEMENTS (area->oiflist, node2, nnode2, oi))
@ -3428,7 +3345,6 @@ ospf_flush_self_originated_lsas_now (struct ospf *ospf)
ospf_lsa_flush_area (oi->network_lsa_self, area); ospf_lsa_flush_area (oi->network_lsa_self, area);
ospf_lsa_unlock (&oi->network_lsa_self); ospf_lsa_unlock (&oi->network_lsa_self);
oi->network_lsa_self = NULL; oi->network_lsa_self = NULL;
OSPF_TIMER_OFF (oi->t_network_lsa_self);
} }
if (oi->type != OSPF_IFTYPE_VIRTUALLINK if (oi->type != OSPF_IFTYPE_VIRTUALLINK
@ -3628,10 +3544,11 @@ ospf_schedule_lsa_flush_area (struct ospf_area *area, struct ospf_lsa *lsa)
/* LSA Refreshment functions. */ /* LSA Refreshment functions. */
static void struct ospf_lsa *
ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa) ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
{ {
struct external_info *ei; struct external_info *ei;
struct ospf_lsa *new = NULL;
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF)); assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF));
assert (lsa->lock > 0); assert (lsa->lock > 0);
@ -3639,13 +3556,16 @@ ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
{ {
/* Router and Network LSAs are processed differently. */ /* Router and Network LSAs are processed differently. */
case OSPF_ROUTER_LSA: case OSPF_ROUTER_LSA:
new = ospf_router_lsa_refresh (lsa);
break;
case OSPF_NETWORK_LSA: case OSPF_NETWORK_LSA:
new = ospf_network_lsa_refresh (lsa);
break; break;
case OSPF_SUMMARY_LSA: case OSPF_SUMMARY_LSA:
ospf_summary_lsa_refresh (ospf, lsa); new = ospf_summary_lsa_refresh (ospf, lsa);
break; break;
case OSPF_ASBR_SUMMARY_LSA: case OSPF_ASBR_SUMMARY_LSA:
ospf_summary_asbr_lsa_refresh (ospf, lsa); new = ospf_summary_asbr_lsa_refresh (ospf, lsa);
break; break;
case OSPF_AS_EXTERNAL_LSA: case OSPF_AS_EXTERNAL_LSA:
/* Translated from NSSA Type-5s are refreshed when /* Translated from NSSA Type-5s are refreshed when
@ -3655,7 +3575,7 @@ ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
break; break;
ei = ospf_external_info_check (lsa); ei = ospf_external_info_check (lsa);
if (ei) if (ei)
ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_FORCE); new = ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_FORCE);
else else
ospf_lsa_flush_as (ospf, lsa); ospf_lsa_flush_as (ospf, lsa);
break; break;
@ -3663,12 +3583,13 @@ ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
case OSPF_OPAQUE_LINK_LSA: case OSPF_OPAQUE_LINK_LSA:
case OSPF_OPAQUE_AREA_LSA: case OSPF_OPAQUE_AREA_LSA:
case OSPF_OPAQUE_AS_LSA: case OSPF_OPAQUE_AS_LSA:
ospf_opaque_lsa_refresh (lsa); new = ospf_opaque_lsa_refresh (lsa);
break; break;
#endif /* HAVE_OPAQUE_LSA */ #endif /* HAVE_OPAQUE_LSA */
default: default:
break; break;
} }
return new;
} }
void void
@ -3695,8 +3616,8 @@ ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
if (delay < 0) if (delay < 0)
delay = 0; delay = 0;
current_index = ospf->lsa_refresh_queue.index + current_index = ospf->lsa_refresh_queue.index + (quagga_time (NULL)
(quagga_time (NULL) - ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY; - ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY;
index = (current_index + delay/OSPF_LSA_REFRESHER_GRANULARITY) index = (current_index + delay/OSPF_LSA_REFRESHER_GRANULARITY)
% (OSPF_LSA_REFRESHER_SLOTS); % (OSPF_LSA_REFRESHER_SLOTS);
@ -3756,8 +3677,9 @@ ospf_lsa_refresh_walker (struct thread *t)
modulus. */ modulus. */
ospf->lsa_refresh_queue.index = ospf->lsa_refresh_queue.index =
((unsigned long)(ospf->lsa_refresh_queue.index + ((unsigned long)(ospf->lsa_refresh_queue.index +
(quagga_time (NULL) - ospf->lsa_refresher_started) / (quagga_time (NULL) - ospf->lsa_refresher_started)
OSPF_LSA_REFRESHER_GRANULARITY)) % OSPF_LSA_REFRESHER_SLOTS; / OSPF_LSA_REFRESHER_GRANULARITY))
% OSPF_LSA_REFRESHER_SLOTS;
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH)) if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
zlog_debug ("LSA[Refresh]: ospf_lsa_refresh_walker(): next index %d", zlog_debug ("LSA[Refresh]: ospf_lsa_refresh_walker(): next index %d",

View File

@ -115,10 +115,8 @@ struct ospf_lsa
/* Refreshement List or Queue */ /* Refreshement List or Queue */
int refresh_list; int refresh_list;
#ifdef HAVE_OPAQUE_LSA /* For Type-9 Opaque-LSAs or Type-2 Network-LSAs */
/* For Type-9 Opaque-LSAs, reference to ospf-interface is required. */
struct ospf_interface *oi; struct ospf_interface *oi;
#endif /* HAVE_OPAQUE_LSA */
}; };
/* OSPF LSA Link Type. */ /* OSPF LSA Link Type. */
@ -254,19 +252,16 @@ extern struct lsa_header *ospf_lsa_data_dup (struct lsa_header *);
extern void ospf_lsa_data_free (struct lsa_header *); extern void ospf_lsa_data_free (struct lsa_header *);
/* Prototype for various LSAs */ /* Prototype for various LSAs */
extern int ospf_router_lsa_update_timer (struct thread *); extern int ospf_router_lsa_update (struct ospf *);
extern void ospf_router_lsa_timer_add (struct ospf_area *); extern int ospf_router_lsa_update_area (struct ospf_area *);
extern int ospf_network_lsa_refresh (struct ospf_lsa *, struct ospf_interface *); extern void ospf_network_lsa_update (struct ospf_interface *);
extern void ospf_network_lsa_timer_add (struct ospf_interface *);
extern struct ospf_lsa *ospf_summary_lsa_originate (struct prefix_ipv4 *, u_int32_t, extern struct ospf_lsa *ospf_summary_lsa_originate (struct prefix_ipv4 *, u_int32_t,
struct ospf_area *); struct ospf_area *);
extern struct ospf_lsa *ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *, extern struct ospf_lsa *ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *,
u_int32_t, u_int32_t,
struct ospf_area *); struct ospf_area *);
extern struct ospf_lsa *ospf_summary_lsa_refresh (struct ospf *, struct ospf_lsa *);
extern struct ospf_lsa *ospf_summary_asbr_lsa_refresh (struct ospf *, struct ospf_lsa *);
extern struct ospf_lsa *ospf_lsa_install (struct ospf *, extern struct ospf_lsa *ospf_lsa_install (struct ospf *,
struct ospf_interface *, struct ospf_lsa *); struct ospf_interface *, struct ospf_lsa *);
@ -300,12 +295,15 @@ extern void ospf_lsa_maxage (struct ospf *, struct ospf_lsa *);
extern u_int32_t get_metric (u_char *); extern u_int32_t get_metric (u_char *);
extern int ospf_lsa_maxage_walker (struct thread *); extern int ospf_lsa_maxage_walker (struct thread *);
extern struct ospf_lsa *ospf_lsa_refresh (struct ospf *, struct ospf_lsa *);
extern void ospf_external_lsa_refresh_default (struct ospf *); extern void ospf_external_lsa_refresh_default (struct ospf *);
extern void ospf_external_lsa_refresh_type (struct ospf *, u_char, int); extern void ospf_external_lsa_refresh_type (struct ospf *, u_char, int);
extern void ospf_external_lsa_refresh (struct ospf *, struct ospf_lsa *, extern struct ospf_lsa *ospf_external_lsa_refresh (struct ospf *,
struct external_info *, int); struct ospf_lsa *,
struct external_info *,
int);
extern struct in_addr ospf_lsa_unique_id (struct ospf *, struct ospf_lsdb *, u_char, extern struct in_addr ospf_lsa_unique_id (struct ospf *, struct ospf_lsdb *, u_char,
struct prefix_ipv4 *); struct prefix_ipv4 *);
extern void ospf_schedule_lsa_flood_area (struct ospf_area *, struct ospf_lsa *); extern void ospf_schedule_lsa_flood_area (struct ospf_area *, struct ospf_lsa *);

View File

@ -711,7 +711,7 @@ nsm_change_state (struct ospf_neighbor *nbr, int state)
LOOKUP(ospf_nsm_state_msg, old_state), LOOKUP(ospf_nsm_state_msg, old_state),
LOOKUP(ospf_nsm_state_msg, state)); LOOKUP(ospf_nsm_state_msg, state));
ospf_router_lsa_timer_add (oi->area); ospf_router_lsa_update_area (oi->area);
if (oi->type == OSPF_IFTYPE_VIRTUALLINK) if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
{ {
@ -719,7 +719,7 @@ nsm_change_state (struct ospf_neighbor *nbr, int state)
ospf_area_lookup_by_area_id (oi->ospf, oi->vl_data->vl_area_id); ospf_area_lookup_by_area_id (oi->ospf, oi->vl_data->vl_area_id);
if (vl_area) if (vl_area)
ospf_router_lsa_timer_add (vl_area); ospf_router_lsa_update_area (vl_area);
} }
/* Originate network-LSA. */ /* Originate network-LSA. */
@ -730,10 +730,9 @@ nsm_change_state (struct ospf_neighbor *nbr, int state)
ospf_lsa_flush_area (oi->network_lsa_self, oi->area); ospf_lsa_flush_area (oi->network_lsa_self, oi->area);
ospf_lsa_unlock (&oi->network_lsa_self); ospf_lsa_unlock (&oi->network_lsa_self);
oi->network_lsa_self = NULL; oi->network_lsa_self = NULL;
OSPF_TIMER_OFF (oi->t_network_lsa_self);
} }
else else
ospf_network_lsa_timer_add (oi); ospf_network_lsa_update (oi);
} }
} }

View File

@ -7029,7 +7029,7 @@ DEFUN (ospf_max_metric_router_lsa_admin,
SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
} }
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -7055,7 +7055,7 @@ DEFUN (no_ospf_max_metric_router_lsa_admin,
&& !area->t_stub_router) && !area->t_stub_router)
{ {
UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
} }
} }
return CMD_SUCCESS; return CMD_SUCCESS;
@ -7108,7 +7108,7 @@ DEFUN (no_ospf_max_metric_router_lsa_startup,
if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
{ {
UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
} }
} }
return CMD_SUCCESS; return CMD_SUCCESS;

View File

@ -131,8 +131,8 @@ ospf_router_id_update (struct ospf *ospf)
ospf->external_origin = 0; ospf->external_origin = 0;
} }
OSPF_TIMER_ON (ospf->t_router_lsa_update, /* update router-lsa's for each area */
ospf_router_lsa_update_timer, OSPF_LSA_UPDATE_DELAY); ospf_router_lsa_update (ospf);
/* update ospf_interface's */ /* update ospf_interface's */
for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
@ -337,7 +337,7 @@ ospf_deferred_shutdown_check (struct ospf *ospf)
SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
} }
timeout = ospf->stub_router_shutdown_time; timeout = ospf->stub_router_shutdown_time;
} }
@ -473,7 +473,6 @@ ospf_finish_final (struct ospf *ospf)
/* Cancel all timers. */ /* Cancel all timers. */
OSPF_TIMER_OFF (ospf->t_external_lsa); OSPF_TIMER_OFF (ospf->t_external_lsa);
OSPF_TIMER_OFF (ospf->t_router_lsa_update);
OSPF_TIMER_OFF (ospf->t_spf_calc); OSPF_TIMER_OFF (ospf->t_spf_calc);
OSPF_TIMER_OFF (ospf->t_ase_calc); OSPF_TIMER_OFF (ospf->t_ase_calc);
OSPF_TIMER_OFF (ospf->t_maxage); OSPF_TIMER_OFF (ospf->t_maxage);
@ -631,7 +630,6 @@ ospf_area_free (struct ospf_area *area)
free (IMPORT_NAME (area)); free (IMPORT_NAME (area));
/* Cancel timer. */ /* Cancel timer. */
OSPF_TIMER_OFF (area->t_router_lsa_self);
OSPF_TIMER_OFF (area->t_stub_router); OSPF_TIMER_OFF (area->t_stub_router);
#ifdef HAVE_OPAQUE_LSA #ifdef HAVE_OPAQUE_LSA
OSPF_TIMER_OFF (area->t_opaque_lsa_self); OSPF_TIMER_OFF (area->t_opaque_lsa_self);
@ -1041,7 +1039,7 @@ ospf_area_type_set (struct ospf_area *area, int type)
break; break;
} }
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
ospf_schedule_abr_task (area->ospf); ospf_schedule_abr_task (area->ospf);
} }
@ -1052,7 +1050,7 @@ ospf_area_shortcut_set (struct ospf *ospf, struct ospf_area *area, int mode)
return 0; return 0;
area->shortcut_configured = mode; area->shortcut_configured = mode;
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
ospf_schedule_abr_task (ospf); ospf_schedule_abr_task (ospf);
ospf_area_check_free (ospf, area->area_id); ospf_area_check_free (ospf, area->area_id);
@ -1064,7 +1062,7 @@ int
ospf_area_shortcut_unset (struct ospf *ospf, struct ospf_area *area) ospf_area_shortcut_unset (struct ospf *ospf, struct ospf_area *area)
{ {
area->shortcut_configured = OSPF_SHORTCUT_DEFAULT; area->shortcut_configured = OSPF_SHORTCUT_DEFAULT;
ospf_router_lsa_timer_add (area); ospf_router_lsa_update_area (area);
ospf_area_check_free (ospf, area->area_id); ospf_area_check_free (ospf, area->area_id);
ospf_schedule_abr_task (ospf); ospf_schedule_abr_task (ospf);

View File

@ -251,7 +251,6 @@ struct ospf
int redistribute; /* Num of redistributed protocols. */ int redistribute; /* Num of redistributed protocols. */
/* Threads. */ /* Threads. */
struct thread *t_router_lsa_update; /* router-LSA update timer. */
struct thread *t_abr_task; /* ABR task timer. */ struct thread *t_abr_task; /* ABR task timer. */
struct thread *t_asbr_check; /* ASBR check timer. */ struct thread *t_asbr_check; /* ASBR check timer. */
struct thread *t_distribute_update; /* Distirbute list update timer. */ struct thread *t_distribute_update; /* Distirbute list update timer. */
@ -433,7 +432,6 @@ struct ospf_area
struct vertex *spf; struct vertex *spf;
/* Threads. */ /* Threads. */
struct thread *t_router_lsa_self;/* Self-originated router-LSA timer. */
struct thread *t_stub_router; /* Stub-router timer */ struct thread *t_stub_router; /* Stub-router timer */
#ifdef HAVE_OPAQUE_LSA #ifdef HAVE_OPAQUE_LSA
struct thread *t_opaque_lsa_self; /* Type-10 Opaque-LSAs origin. */ struct thread *t_opaque_lsa_self; /* Type-10 Opaque-LSAs origin. */