Aging of lsa database added.
This commit is contained in:
parent
a92847e78f
commit
c45f48fba5
5 changed files with 70 additions and 8 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue