diff options
-rw-r--r-- | proto/ospf/iface.c | 10 | ||||
-rw-r--r-- | proto/ospf/lsalib.c | 3 | ||||
-rw-r--r-- | proto/ospf/neighbor.c | 4 | ||||
-rw-r--r-- | proto/ospf/ospf.c | 41 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 10 | ||||
-rw-r--r-- | proto/ospf/rt.c | 9 | ||||
-rw-r--r-- | proto/ospf/topology.c | 38 | ||||
-rw-r--r-- | proto/ospf/topology.h | 2 |
8 files changed, 68 insertions, 49 deletions
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index 6f0d1340..6e370f8a 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -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); diff --git a/proto/ospf/lsalib.c b/proto/ospf/lsalib.c index 91a73f0d..d462bbd0 100644 --- a/proto/ospf/lsalib.c +++ b/proto/ospf/lsalib.c @@ -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); } } diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c index 3de40718..c4f457a0 100644 --- a/proto/ospf/neighbor.c +++ b/proto/ospf/neighbor.c @@ -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) diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 15e9ea45..701c3230 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -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) { diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 63c4fc22..81760355 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -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) diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index 9b85df74..27c6efb6 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -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) diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index cf08ed7e..901f4ae7 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -151,24 +151,6 @@ originate_rt_lsa_body(struct ospf_area *oa, u16 *length, struct proto_ospf *p) } 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) { struct ospf_area *oa; @@ -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; diff --git a/proto/ospf/topology.h b/proto/ospf/topology.h index fe0d86ea..786e9764 100644 --- a/proto/ospf/topology.h +++ b/proto/ospf/topology.h @@ -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); |