Commit 70a38319 authored by Ondřej Filip's avatar Ondřej Filip

LSArt origination and routing table calculation is now not doing so

often. Instead of calculation I just schedule it latter.
parent aa185265
......@@ -130,7 +130,7 @@ ospf_int_sm(struct ospf_iface *ifa, int event)
}
addifa_rtlsa(ifa);
}
originate_rt_lsa(ifa->oa,po);
schedule_rt_lsa(ifa->oa);
break;
case ISM_BACKS:
case ISM_WAITF:
......@@ -144,22 +144,22 @@ ospf_int_sm(struct ospf_iface *ifa, int event)
(ifa->state==OSPF_IS_BACKUP))
{
bdr_election(ifa ,p);
originate_rt_lsa(ifa->oa,po);
schedule_rt_lsa(ifa->oa);
}
break;
case ISM_DOWN:
iface_chstate(ifa, OSPF_IS_DOWN);
downint(ifa);
originate_rt_lsa(ifa->oa,po);
schedule_rt_lsa(ifa->oa);
break;
case ISM_LOOP: /* Useless? */
iface_chstate(ifa, OSPF_IS_LOOP);
downint(ifa);
originate_rt_lsa(ifa->oa,po);
schedule_rt_lsa(ifa->oa);
break;
case ISM_UNLOOP:
iface_chstate(ifa, OSPF_IS_DOWN);
originate_rt_lsa(ifa->oa,po);
schedule_rt_lsa(ifa->oa);
break;
default:
die("%s: ISM - Unknown event?",p->name);
......
......@@ -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 */
if(oa->rt!=NULL)
{
DBG("Starting routing table calculation.\n");
ospf_rt_spfa(oa);
schedule_rtcalc(oa);
}
}
......
......@@ -42,14 +42,14 @@ neigh_chstate(struct ospf_neighbor *n, u8 state)
if(oldstate==NEIGHBOR_FULL) /* Decrease number of adjacencies */
{
ifa->fadj--;
originate_rt_lsa(ifa->oa,po);
schedule_rt_lsa(ifa->oa);
originate_net_lsa(ifa,po);
}
if(state==NEIGHBOR_FULL) /* Increase number of adjacencies */
{
ifa->fadj++;
originate_rt_lsa(ifa->oa,po);
schedule_rt_lsa(ifa->oa);
originate_net_lsa(ifa,po);
}
if(oldstate>=NEIGHBOR_EXSTART && state<NEIGHBOR_EXSTART)
......
......@@ -135,6 +135,47 @@ ospf_build_attrs(ea_list *next, struct linpool *pool, u32 m1, u32 m2, u32 tag)
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
ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool *pool)
{
......
......@@ -42,7 +42,7 @@
#define MINLSINTERVAL 5
#define MINLSARRIVAL 1
#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 proto_config c;
......@@ -324,8 +324,9 @@ struct ospf_neighbor
struct ospf_area {
node n;
u32 areaid;
bird_clock_t lage; /* A time of last aging */
timer *age_timer; /* A timer for aging */
timer *disp_timer; /* Area's dispatcher hear beat */
int calcrt; /* Routing table calculation scheduled? */
int origrt; /* Rt lsa origination scheduled? */
struct top_graph *gr; /* LSA graph */
slist lsal; /* List of all LSA's */
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);
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 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_METRIC2 EA_CODE(EAP_OSPF, 1)
......
......@@ -50,20 +50,11 @@ ospf_rt_spfa(struct ospf_area *oa)
debug("%s: Starting routing table calculation for area %I\n",p->name,
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)
{
en->color=OUTSPF;
en->dist=LSINFINITY;
en->nhi=NULL;
if(age) ospf_age(en,delta,flush,oa);
}
FIB_WALK(in,nftmp)
......
......@@ -150,24 +150,6 @@ originate_rt_lsa_body(struct ospf_area *oa, u16 *length, struct proto_ospf *p)
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
addifa_rtlsa(struct ospf_iface *ifa)
{
......@@ -196,14 +178,15 @@ addifa_rtlsa(struct ospf_iface *ifa)
oa->gr=ospf_top_new(po);
s_init_list(&(oa->lsal));
oa->rt=NULL;
oa->lage=now;
oa->po=po;
oa->age_timer=tm_new(po->proto.pool);
oa->age_timer->data=oa;
oa->age_timer->randomize=0;
oa->age_timer->hook=age_timer_hook;
oa->age_timer->recurrent=AGINGDELTA;
tm_start(oa->age_timer,AGINGDELTA);
oa->disp_timer=tm_new(po->proto.pool);
oa->disp_timer->data=oa;
oa->disp_timer->randomize=0;
oa->disp_timer->hook=area_disp;
oa->disp_timer->recurrent=DISPTICK;
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);
/* FIXME 16?? (Oh, sweet 16.... :-) */
po->areano++;
......@@ -212,15 +195,16 @@ addifa_rtlsa(struct ospf_iface *ifa)
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);
flood_lsa(NULL,NULL,&oa->rt->lsa,po,NULL,oa,1);
}
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 proto_ospf *po=oa->po;
u32 rtid=po->proto.cf->global->router_id;
struct top_hash_entry *en;
void *body;
......
......@@ -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);
void ospf_hash_delete(struct top_graph *, struct top_hash_entry *);
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);
int can_flush_lsa(struct ospf_area *oa);
void originate_ext_lsa(net *n, rte *e, struct proto_ospf *po, struct ea_list *attrs);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment