]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Aging of lsa database added.
authorOndrej Filip <feela@network.cz>
Tue, 2 May 2000 22:19:41 +0000 (22:19 +0000)
committerOndrej Filip <feela@network.cz>
Tue, 2 May 2000 22:19:41 +0000 (22:19 +0000)
proto/ospf/lsalib.c
proto/ospf/lsalib.h
proto/ospf/ospf.h
proto/ospf/rt.c
proto/ospf/topology.c

index 261ed341f83a9c321b3c223f402922ff99b941f5..8c5ec6801e6f0c434e12c3aae2884a442d0fb8ec 100644 (file)
@@ -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)
 {
index b16ec78a45e282cc89fc5a3d50ffecc12c6778e3..1b8699eb87fd9550b781078ef0c52b3a117fae9e 100644 (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);
 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_ */
index 31024f356c89cf105c1c5ac326be216e69865385..40ac691f5d42ecb4007099223e2c3f17d54ab1d6 100644 (file)
@@ -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 {
index d9ec0fdb730dab8b29e9a43627eab887cd4c27dd..5a6aa3737508cda06f6d5ab9680a15a37a9dda8d 100644 (file)
@@ -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 */
index b448f51f736572cce238aec1181a9729b19b4342..a69c01a22b9e4a433f1d28516e37a204ebb4c0a4 100644 (file)
@@ -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);
   }