0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-09 20:58:44 +00:00

Aging of lsa database added.

This commit is contained in:
Ondrej Filip 2000-05-02 22:19:41 +00:00
parent a92847e78f
commit c45f48fba5
5 changed files with 70 additions and 8 deletions

View File

@ -8,6 +8,34 @@
#include "ospf.h" #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 void
htonlsah(struct ospf_lsa_header *h, struct ospf_lsa_header *n) htonlsah(struct ospf_lsa_header *h, struct ospf_lsa_header *n)
{ {

View File

@ -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); 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 top_hash_entry *lsa_install_new(struct ospf_lsa_header *lsa, void *body,
struct ospf_area *oa, struct proto *p); 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_ */ #endif /* _BIRD_OSPF_LSALIB_H_ */

View File

@ -43,6 +43,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 20 /* FIXME What's good value? */
struct ospf_config { struct ospf_config {
struct proto_config c; struct proto_config c;
@ -322,12 +323,15 @@ 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 *age_timer; /* A timer for aging */
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 */
list cand; /* List of candidates for RT calc. */ list cand; /* List of candidates for RT calc. */
u8 stub; u8 stub;
u8 trcap; /* Transit capability? */ u8 trcap; /* Transit capability? */
struct proto_ospf *po;
}; };
struct proto_ospf { struct proto_ospf {

View File

@ -26,17 +26,21 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
struct ospf_lsa_rt_link *rtl,*rr; struct ospf_lsa_rt_link *rtl,*rr;
struct fib fib; struct fib fib;
struct stub_fib *sf; struct stub_fib *sf;
bird_clock_t delta;
int age=0,flush=0;
/* /* FIXME if I'm not in LOADING or EXCHANGE set flush=1 */
* First of all, mark all vertices as they are not in SPF if((delta=now-oa->lage)>=AGINGDELTA)
* Maybe I can join this work with Aging of structure {
* FIXME look at it 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->color=OUTSPF;
en->dist=LSINFINITY; en->dist=LSINFINITY;
if(age) ospf_age(en,delta,flush,p);
} }
init_list(&oa->cand); /* Empty list of candidates */ init_list(&oa->cand); /* Empty list of candidates */

View File

@ -151,16 +151,32 @@ 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;
/* 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 void
addifa_rtlsa(struct ospf_iface *ifa) addifa_rtlsa(struct ospf_iface *ifa)
{ {
struct ospf_area *oa; struct ospf_area *oa;
struct proto_ospf *po; struct proto_ospf *po=ifa->proto;
u32 rtid; u32 rtid;
struct top_graph_rtlsa_link *li, *lih; struct top_graph_rtlsa_link *li, *lih;
po=ifa->proto;
rtid=po->proto.cf->global->router_id; rtid=po->proto.cf->global->router_id;
DBG("%s: New OSPF area \"%d\" adding.\n", po->proto.name, ifa->an); DBG("%s: New OSPF area \"%d\" adding.\n", po->proto.name, ifa->an);
oa=NULL; oa=NULL;
@ -181,6 +197,14 @@ 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->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++; po->areano++;
DBG("%s: New OSPF area \"%d\" added.\n", po->proto.name, ifa->an); DBG("%s: New OSPF area \"%d\" added.\n", po->proto.name, ifa->an);
} }