LSArt origination and routing table calculation is now not doing so

often. Instead of calculation I just schedule it latter.
This commit is contained in:
Ondrej Filip 2000-05-31 14:06:33 +00:00
parent aa185265f1
commit 70a383198a
8 changed files with 68 additions and 49 deletions

View file

@ -130,7 +130,7 @@ ospf_int_sm(struct ospf_iface *ifa, int event)
} }
addifa_rtlsa(ifa); addifa_rtlsa(ifa);
} }
originate_rt_lsa(ifa->oa,po); schedule_rt_lsa(ifa->oa);
break; break;
case ISM_BACKS: case ISM_BACKS:
case ISM_WAITF: case ISM_WAITF:
@ -144,22 +144,22 @@ ospf_int_sm(struct ospf_iface *ifa, int event)
(ifa->state==OSPF_IS_BACKUP)) (ifa->state==OSPF_IS_BACKUP))
{ {
bdr_election(ifa ,p); bdr_election(ifa ,p);
originate_rt_lsa(ifa->oa,po); schedule_rt_lsa(ifa->oa);
} }
break; break;
case ISM_DOWN: case ISM_DOWN:
iface_chstate(ifa, OSPF_IS_DOWN); iface_chstate(ifa, OSPF_IS_DOWN);
downint(ifa); downint(ifa);
originate_rt_lsa(ifa->oa,po); schedule_rt_lsa(ifa->oa);
break; break;
case ISM_LOOP: /* Useless? */ case ISM_LOOP: /* Useless? */
iface_chstate(ifa, OSPF_IS_LOOP); iface_chstate(ifa, OSPF_IS_LOOP);
downint(ifa); downint(ifa);
originate_rt_lsa(ifa->oa,po); schedule_rt_lsa(ifa->oa);
break; break;
case ISM_UNLOOP: case ISM_UNLOOP:
iface_chstate(ifa, OSPF_IS_DOWN); iface_chstate(ifa, OSPF_IS_DOWN);
originate_rt_lsa(ifa->oa,po); schedule_rt_lsa(ifa->oa);
break; break;
default: default:
die("%s: ISM - Unknown event?",p->name); die("%s: ISM - Unknown event?",p->name);

View file

@ -400,8 +400,7 @@ lsa_install_new(struct ospf_lsa_header *lsa, void *body, struct ospf_area *oa,
/* FIXME decide if route calculation must be done and how */ /* FIXME decide if route calculation must be done and how */
if(oa->rt!=NULL) if(oa->rt!=NULL)
{ {
DBG("Starting routing table calculation.\n"); schedule_rtcalc(oa);
ospf_rt_spfa(oa);
} }
} }

View file

@ -42,14 +42,14 @@ neigh_chstate(struct ospf_neighbor *n, u8 state)
if(oldstate==NEIGHBOR_FULL) /* Decrease number of adjacencies */ if(oldstate==NEIGHBOR_FULL) /* Decrease number of adjacencies */
{ {
ifa->fadj--; ifa->fadj--;
originate_rt_lsa(ifa->oa,po); schedule_rt_lsa(ifa->oa);
originate_net_lsa(ifa,po); originate_net_lsa(ifa,po);
} }
if(state==NEIGHBOR_FULL) /* Increase number of adjacencies */ if(state==NEIGHBOR_FULL) /* Increase number of adjacencies */
{ {
ifa->fadj++; ifa->fadj++;
originate_rt_lsa(ifa->oa,po); schedule_rt_lsa(ifa->oa);
originate_net_lsa(ifa,po); originate_net_lsa(ifa,po);
} }
if(oldstate>=NEIGHBOR_EXSTART && state<NEIGHBOR_EXSTART) if(oldstate>=NEIGHBOR_EXSTART && state<NEIGHBOR_EXSTART)

View file

@ -135,6 +135,47 @@ ospf_build_attrs(ea_list *next, struct linpool *pool, u32 m1, u32 m2, u32 tag)
return l; return l;
} }
void
schedule_rt_lsa(struct ospf_area *oa)
{
struct proto_ospf *po=oa->po;
struct proto *p=&po->proto;
debug("%s: Scheduling RT lsa origination for area %I.\n", p->name,
oa->areaid);
oa->origrt=1;
}
void
schedule_rtcalc(struct ospf_area *oa)
{
struct proto_ospf *po=oa->po;
struct proto *p=&po->proto;
debug("%s: Scheduling RT calculation for area %I.\n", p->name,
oa->areaid);
oa->calcrt=1;
}
void
area_disp(timer *timer)
{
struct ospf_area *oa=timer->data;
struct top_hash_entry *en,*nxt;
int flush=0;
/* First of all try to age LSA DB */
flush=can_flush_lsa(oa);
WALK_SLIST_DELSAFE(en,nxt,oa->lsal) ospf_age(en,DISPTICK,flush,oa);
/* Now try to originage rt_lsa */
if(oa->origrt) originate_rt_lsa(oa);
oa->origrt=0;
if(oa->calcrt) ospf_rt_spfa(oa);
oa->calcrt=0;
}
int int
ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool *pool) ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool *pool)
{ {

View file

@ -42,7 +42,7 @@
#define MINLSINTERVAL 5 #define MINLSINTERVAL 5
#define MINLSARRIVAL 1 #define MINLSARRIVAL 1
#define LSINFINITY 0xffff /* RFC says 0xffffff ??? */ #define LSINFINITY 0xffff /* RFC says 0xffffff ??? */
#define AGINGDELTA 7 /* FIXME What's good value? */ #define DISPTICK 7 /* FIXME What's good value? */
struct ospf_config { struct ospf_config {
struct proto_config c; struct proto_config c;
@ -324,8 +324,9 @@ struct ospf_neighbor
struct ospf_area { struct ospf_area {
node n; node n;
u32 areaid; u32 areaid;
bird_clock_t lage; /* A time of last aging */ timer *disp_timer; /* Area's dispatcher hear beat */
timer *age_timer; /* A timer for aging */ int calcrt; /* Routing table calculation scheduled? */
int origrt; /* Rt lsa origination scheduled? */
struct top_graph *gr; /* LSA graph */ struct top_graph *gr; /* LSA graph */
slist lsal; /* List of all LSA's */ slist lsal; /* List of all LSA's */
struct top_hash_entry *rt; /* My own router LSA */ struct top_hash_entry *rt; /* My own router LSA */
@ -356,6 +357,9 @@ int ospf_import_control(struct proto *p, rte **new, ea_list **attrs,
struct ea_list *ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool); struct ea_list *ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool);
void ospf_store_tmp_attrs(struct rte *rt, struct ea_list *attrs); void ospf_store_tmp_attrs(struct rte *rt, struct ea_list *attrs);
void ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old,ea_list *attrs); void ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old,ea_list *attrs);
void area_disp(timer *timer);
void schedule_rt_lsa(struct ospf_area *oa);
void schedule_rtcalc(struct ospf_area *oa);
#define EA_OSPF_METRIC1 EA_CODE(EAP_OSPF, 0) #define EA_OSPF_METRIC1 EA_CODE(EAP_OSPF, 0)
#define EA_OSPF_METRIC2 EA_CODE(EAP_OSPF, 1) #define EA_OSPF_METRIC2 EA_CODE(EAP_OSPF, 1)

View file

@ -50,20 +50,11 @@ ospf_rt_spfa(struct ospf_area *oa)
debug("%s: Starting routing table calculation for area %I\n",p->name, debug("%s: Starting routing table calculation for area %I\n",p->name,
oa->areaid); oa->areaid);
flush=can_flush_lsa(oa);
if((delta=now-oa->lage)>=AGINGDELTA)
{
oa->lage=now;
age=1;
}
WALK_SLIST_DELSAFE(SNODE en, nx, oa->lsal) WALK_SLIST_DELSAFE(SNODE en, nx, oa->lsal)
{ {
en->color=OUTSPF; en->color=OUTSPF;
en->dist=LSINFINITY; en->dist=LSINFINITY;
en->nhi=NULL; en->nhi=NULL;
if(age) ospf_age(en,delta,flush,oa);
} }
FIB_WALK(in,nftmp) FIB_WALK(in,nftmp)

View file

@ -150,24 +150,6 @@ originate_rt_lsa_body(struct ospf_area *oa, u16 *length, struct proto_ospf *p)
return rt; return rt;
} }
void
age_timer_hook(timer *timer)
{
struct ospf_area *oa=timer->data;
bird_clock_t delta;
struct top_hash_entry *en,*nxt;
int flush=0;
flush=can_flush_lsa(oa);
if((delta=now-oa->lage)>=AGINGDELTA)
{
WALK_SLIST_DELSAFE(en,nxt,oa->lsal) ospf_age(en,delta,flush,oa);
oa->lage=now;
}
}
void void
addifa_rtlsa(struct ospf_iface *ifa) addifa_rtlsa(struct ospf_iface *ifa)
{ {
@ -196,14 +178,15 @@ addifa_rtlsa(struct ospf_iface *ifa)
oa->gr=ospf_top_new(po); oa->gr=ospf_top_new(po);
s_init_list(&(oa->lsal)); s_init_list(&(oa->lsal));
oa->rt=NULL; oa->rt=NULL;
oa->lage=now;
oa->po=po; oa->po=po;
oa->age_timer=tm_new(po->proto.pool); oa->disp_timer=tm_new(po->proto.pool);
oa->age_timer->data=oa; oa->disp_timer->data=oa;
oa->age_timer->randomize=0; oa->disp_timer->randomize=0;
oa->age_timer->hook=age_timer_hook; oa->disp_timer->hook=area_disp;
oa->age_timer->recurrent=AGINGDELTA; oa->disp_timer->recurrent=DISPTICK;
tm_start(oa->age_timer,AGINGDELTA); tm_start(oa->disp_timer,DISPTICK);
oa->calcrt=1;
oa->origrt=0;
fib_init(&oa->infib,po->proto.pool,sizeof(struct infib),16,init_infib); fib_init(&oa->infib,po->proto.pool,sizeof(struct infib),16,init_infib);
/* FIXME 16?? (Oh, sweet 16.... :-) */ /* FIXME 16?? (Oh, sweet 16.... :-) */
po->areano++; po->areano++;
@ -212,15 +195,16 @@ addifa_rtlsa(struct ospf_iface *ifa)
ifa->oa=oa; ifa->oa=oa;
originate_rt_lsa(oa,po); originate_rt_lsa(oa);
DBG("RT LSA: rt: %I, id: %I, type: %u\n",oa->rt->lsa.rt,oa->rt->lsa.id,oa->rt->lsa.type); DBG("RT LSA: rt: %I, id: %I, type: %u\n",oa->rt->lsa.rt,oa->rt->lsa.id,oa->rt->lsa.type);
flood_lsa(NULL,NULL,&oa->rt->lsa,po,NULL,oa,1); flood_lsa(NULL,NULL,&oa->rt->lsa,po,NULL,oa,1);
} }
void void
originate_rt_lsa(struct ospf_area *oa, struct proto_ospf *po) originate_rt_lsa(struct ospf_area *oa)
{ {
struct ospf_lsa_header lsa; struct ospf_lsa_header lsa;
struct proto_ospf *po=oa->po;
u32 rtid=po->proto.cf->global->router_id; u32 rtid=po->proto.cf->global->router_id;
struct top_hash_entry *en; struct top_hash_entry *en;
void *body; void *body;

View file

@ -46,7 +46,7 @@ struct top_hash_entry *ospf_hash_find(struct top_graph *, u32 lsa, u32 rtr, u32
struct top_hash_entry *ospf_hash_get(struct top_graph *, u32 lsa, u32 rtr, u32 type); struct top_hash_entry *ospf_hash_get(struct top_graph *, u32 lsa, u32 rtr, u32 type);
void ospf_hash_delete(struct top_graph *, struct top_hash_entry *); void ospf_hash_delete(struct top_graph *, struct top_hash_entry *);
void addifa_rtlsa(struct ospf_iface *ifa); void addifa_rtlsa(struct ospf_iface *ifa);
void originate_rt_lsa(struct ospf_area *oa,struct proto_ospf *po); void originate_rt_lsa(struct ospf_area *oa);
void originate_net_lsa(struct ospf_iface *ifa,struct proto_ospf *po); void originate_net_lsa(struct ospf_iface *ifa,struct proto_ospf *po);
int can_flush_lsa(struct ospf_area *oa); int can_flush_lsa(struct ospf_area *oa);
void originate_ext_lsa(net *n, rte *e, struct proto_ospf *po, struct ea_list *attrs); void originate_ext_lsa(net *n, rte *e, struct proto_ospf *po, struct ea_list *attrs);