diff options
author | Ondrej Filip <feela@network.cz> | 2000-05-02 22:19:41 +0000 |
---|---|---|
committer | Ondrej Filip <feela@network.cz> | 2000-05-02 22:19:41 +0000 |
commit | c45f48fba5a0904f9c3512c3b42c38183fef348b (patch) | |
tree | 3679fc0a54a1bc3f316d6024d4c90d4997d065ff /proto/ospf | |
parent | a92847e78fabd637938f324c78d5eb41538a5692 (diff) |
Aging of lsa database added.
Diffstat (limited to 'proto/ospf')
-rw-r--r-- | proto/ospf/lsalib.c | 28 | ||||
-rw-r--r-- | proto/ospf/lsalib.h | 2 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 4 | ||||
-rw-r--r-- | proto/ospf/rt.c | 16 | ||||
-rw-r--r-- | proto/ospf/topology.c | 28 |
5 files changed, 70 insertions, 8 deletions
diff --git a/proto/ospf/lsalib.c b/proto/ospf/lsalib.c index 261ed341..8c5ec680 100644 --- a/proto/ospf/lsalib.c +++ b/proto/ospf/lsalib.c @@ -8,6 +8,34 @@ #include "ospf.h" +/* FIXME Go on */ +void +flush_lsa(struct top_hash_entry *en) +{ + return; +} + +void +ospf_age(struct top_hash_entry *en, bird_clock_t delta, int flush, + struct proto *p) +{ + if(en->lsa.age==LSA_MAXAGE) + { + if(flush) flush_lsa(en); + return; + } + if((en->lsa.rt==p->cf->global->router_id)&&(en->lsa.age>LSREFRESHTIME)) + { + /* FIXME Reflood again my self originated LSA */ + } + if((en->lsa.age+=delta)>LSA_MAXAGE) + { + if(flush) flush_lsa(en); + else en->lsa.age=LSA_MAXAGE; + return; + } +} + void htonlsah(struct ospf_lsa_header *h, struct ospf_lsa_header *n) { diff --git a/proto/ospf/lsalib.h b/proto/ospf/lsalib.h index b16ec78a..1b8699eb 100644 --- a/proto/ospf/lsalib.h +++ b/proto/ospf/lsalib.h @@ -23,5 +23,7 @@ u16 lsasum_check(struct ospf_lsa_header *h,void *body,struct proto_ospf *po); int lsa_comp(struct ospf_lsa_header *l1, struct ospf_lsa_header *l2); struct top_hash_entry *lsa_install_new(struct ospf_lsa_header *lsa, void *body, struct ospf_area *oa, struct proto *p); +void ospf_age(struct top_hash_entry *en, bird_clock_t delta, int flush, + struct proto *p); #endif /* _BIRD_OSPF_LSALIB_H_ */ diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 31024f35..40ac691f 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -43,6 +43,7 @@ #define MINLSINTERVAL 5 #define MINLSARRIVAL 1 #define LSINFINITY 0xffff /* RFC says 0xffffff ??? */ +#define AGINGDELTA 20 /* FIXME What's good value? */ struct ospf_config { struct proto_config c; @@ -322,12 +323,15 @@ 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 */ struct top_graph *gr; /* LSA graph */ slist lsal; /* List of all LSA's */ struct top_hash_entry *rt; /* My own router LSA */ list cand; /* List of candidates for RT calc. */ u8 stub; u8 trcap; /* Transit capability? */ + struct proto_ospf *po; }; struct proto_ospf { diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index d9ec0fdb..5a6aa373 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -26,17 +26,21 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p) struct ospf_lsa_rt_link *rtl,*rr; struct fib fib; struct stub_fib *sf; + bird_clock_t delta; + int age=0,flush=0; - /* - * First of all, mark all vertices as they are not in SPF - * Maybe I can join this work with Aging of structure - * FIXME look at it - */ + /* FIXME if I'm not in LOADING or EXCHANGE set flush=1 */ + if((delta=now-oa->lage)>=AGINGDELTA) + { + oa->lage=now; + age=1; + } - WALK_SLIST(SNODE en, oa->lsal) + WALK_SLIST_DELSAFE(SNODE en, nx, oa->lsal) /* FIXME Make it DELSAFE */ { en->color=OUTSPF; en->dist=LSINFINITY; + if(age) ospf_age(en,delta,flush,p); } init_list(&oa->cand); /* Empty list of candidates */ diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index b448f51f..a69c01a2 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -150,17 +150,33 @@ originate_rt_lsa_body(struct ospf_area *oa, u16 *length, struct proto_ospf *p) sizeof(struct ospf_lsa_header); 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; + + /* FIXME Fill flush! */ + + if((delta=now-oa->lage)>=AGINGDELTA) + { + WALK_SLIST_DELSAFE(en,nxt,oa->lsal) ospf_age(en,delta,flush,&oa->po->proto); + oa->lage=now; + } +} void addifa_rtlsa(struct ospf_iface *ifa) { struct ospf_area *oa; - struct proto_ospf *po; + struct proto_ospf *po=ifa->proto; u32 rtid; struct top_graph_rtlsa_link *li, *lih; - po=ifa->proto; rtid=po->proto.cf->global->router_id; DBG("%s: New OSPF area \"%d\" adding.\n", po->proto.name, ifa->an); oa=NULL; @@ -181,6 +197,14 @@ 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); po->areano++; DBG("%s: New OSPF area \"%d\" added.\n", po->proto.name, ifa->an); } |