]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
LSArt origination and routing table calculation is now not doing so
authorOndrej Filip <feela@network.cz>
Wed, 31 May 2000 14:06:33 +0000 (14:06 +0000)
committerOndrej Filip <feela@network.cz>
Wed, 31 May 2000 14:06:33 +0000 (14:06 +0000)
often. Instead of calculation I just schedule it latter.

proto/ospf/iface.c
proto/ospf/lsalib.c
proto/ospf/neighbor.c
proto/ospf/ospf.c
proto/ospf/ospf.h
proto/ospf/rt.c
proto/ospf/topology.c
proto/ospf/topology.h

index 6f0d1340e98f5fae523c6924d48cfc3d05f13757..6e370f8af7cf40afe70b2f2508ef7c3c6dfd18e4 100644 (file)
@@ -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);
index 91a73f0dac87927989963673fed3cdff4fce05ff..d462bbd051ff88372906f4fb38b051fd2f2478a3 100644 (file)
@@ -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);
     }
   }
   
index 3de40718f636b9a94e3eeb740e9baf22963be801..c4f457a01e9daeb29ea8c81dca23699e0da1f078 100644 (file)
@@ -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)
index 15e9ea452eb21cb2615d5fbec0598f756ff098ff..701c323026084cc8b95d25c08c7f9607ffc1f6b5 100644 (file)
@@ -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)
 {
index 63c4fc2219fce7bbfb22ad59cb1803ea3e9534ab..81760355fa03d1a8b919ec8ca4469a0b7bc7d7f4 100644 (file)
@@ -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)
index 9b85df74e74d196866d7425a09d7ecb22ab9fd4b..27c6efb64919829ec2d736fe3976f962e7d38428 100644 (file)
@@ -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)
index cf08ed7e83cf7f72797ae70c6d6d5d9195733286..901f4ae74644ace0d30c1a24c89c6a64990b3bd4 100644 (file)
@@ -150,24 +150,6 @@ originate_rt_lsa_body(struct ospf_area *oa, u16 *length, struct proto_ospf *p)
   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;
-
-  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)
 {
@@ -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;
index fe0d86ea7ed85b5e98a672d5a7c864cb1fdd4b10..786e97644d464cabbfb59cadf584881f57799fc4 100644 (file)
@@ -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);