]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
You can decide if add LSA into lsrth during flood_lsa().
authorOndrej Filip <feela@network.cz>
Tue, 30 May 2000 17:51:22 +0000 (17:51 +0000)
committerOndrej Filip <feela@network.cz>
Tue, 30 May 2000 17:51:22 +0000 (17:51 +0000)
proto/ospf/lsupd.c
proto/ospf/lsupd.h
proto/ospf/topology.c

index 1e701597d963fb73dbf349ce43aa6eb48cd11f29..d306fd4540fb65912715c0cb796104ec6caf9161 100644 (file)
@@ -11,7 +11,7 @@
 int
 flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
   struct ospf_lsa_header *hh, struct proto_ospf *po, struct ospf_iface *iff,
-  struct ospf_area *oa)
+  struct ospf_area *oa, int rtl)
 {
   struct ospf_iface *ifa;
   struct ospf_neighbor *nn;
@@ -70,19 +70,30 @@ flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
        }
       }
       if(nn==n) continue;
-      if((en=ospf_hash_find_header(nn->lsrth, hh))==NULL)
+      if(rtl!=0)
       {
-        en=ospf_hash_get_header(nn->lsrth, hh);
+        if((en=ospf_hash_find_header(nn->lsrth, hh))==NULL)
+        {
+          en=ospf_hash_get_header(nn->lsrth, hh);
+        }
+        else
+        {
+          s_rem_node(SNODE en);
+        }
+        s_add_tail(&nn->lsrtl, SNODE en);
+        memcpy(&en->lsa,hh,sizeof(struct ospf_lsa_header));
+        ret=1;
+        DBG("Adding LSA lsrt RT: %I, Id: %I, Type: %u for n: %I\n",
+          en->lsa.rt,en->lsa.id, en->lsa.type, nn->ip);
       }
       else
       {
-        s_rem_node(SNODE en);
+        if((en=ospf_hash_find_header(nn->lsrth, hh))!=NULL)
+        {
+          s_rem_node(SNODE en);
+          ospf_hash_delete(nn->lsrth, en);
+        }
       }
-      s_add_tail(&nn->lsrtl, SNODE en);
-      memcpy(&en->lsa,hh,sizeof(struct ospf_lsa_header));
-      ret=1;
-      DBG("Adding LSA lsrt RT: %I, Id: %I, Type: %u for n: %I\n",
-        en->lsa.rt,en->lsa.id, en->lsa.type, nn->ip);
     }
     if(ret==0) continue;
     if(ifa==iff)
@@ -347,8 +358,10 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
        {
          lsa->age=(htons(LSA_MAXAGE));
         lsatmp.age=LSA_MAXAGE;
-        debug("Premature aging self originated lsa.\n");
-         flood_lsa(NULL,lsa,&lsatmp,po,NULL,oa);
+        debug("%s: Premature aging self originated lsa.\n",p->name);
+         debug("%s: Type: %d, Id: %I, Rt: %I\n", lsatmp.type, lsatmp.id,
+           lsatmp.rt);
+         flood_lsa(NULL,lsa,&lsatmp,po,NULL,oa,0);
         continue;
        }
 
@@ -362,7 +375,7 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
       }
         
 
-      if(flood_lsa(n,lsa,&lsatmp,po,ifa,ifa->oa)==0)
+      if(flood_lsa(n,lsa,&lsatmp,po,ifa,ifa->oa,1)==0)
       {
         DBG("Wasn't flooded back\n");
         if(ifa->state==OSPF_IS_BACKUP)
@@ -446,7 +459,9 @@ net_flush_lsa(struct top_hash_entry *en, struct proto_ospf *po,
   struct ospf_lsa_header *lsa=&en->lsa;
 
   lsa->age=LSA_MAXAGE;
-  debug("Premature aging self originated lsa.\n");
-  flood_lsa(NULL,NULL,lsa,po,NULL,oa);
+  debug("%s: Premature aging self originated lsa!\n",po->proto.name);
+  debug("%s: Type: %d, Id: %I, Rt: %I\n", lsa->type, lsa->id,
+    lsa->rt);
+  flood_lsa(NULL,NULL,lsa,po,NULL,oa,0);
 }
 
index 56368bab717bf1e055e134d7dccb6f57df8f830e..61dd5d0e37f3872956041c2e4f38d49155aee916 100644 (file)
@@ -15,7 +15,7 @@ void ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
   struct ospf_iface *ifa, u16 size);
 int flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
   struct ospf_lsa_header *hh, struct proto_ospf *po, struct ospf_iface *iff,
-  struct ospf_area *oa);
+  struct ospf_area *oa, int rtl);
 void net_flush_lsa(struct top_hash_entry *en, struct proto_ospf *po,
                  struct ospf_area *oa);
 
index f54c63b28466533b0de21eb8ed115eb19c65eaf4..053ea4bc42f59906b978aaf86b2f6268174df286 100644 (file)
@@ -214,7 +214,7 @@ addifa_rtlsa(struct ospf_iface *ifa)
 
   originate_rt_lsa(oa,po);
   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);
+  flood_lsa(NULL,NULL,&oa->rt->lsa,po,NULL,oa,1);
 }
 
 void
@@ -231,6 +231,7 @@ originate_rt_lsa(struct ospf_area *oa, struct proto_ospf *po)
   lsa.id=rtid;
   lsa.type=LSA_T_RT;
   lsa.rt=rtid;
+  lsa.options=0;
   if(oa->rt==NULL)
   {
     lsa.sn=LSA_INITSEQNO;
@@ -243,7 +244,7 @@ originate_rt_lsa(struct ospf_area *oa, struct proto_ospf *po)
   lsasum_calculate(&lsa,body,po);
   en=lsa_install_new(&lsa, body, oa, &po->proto);
   oa->rt=en;
-  flood_lsa(NULL,NULL,&oa->rt->lsa,po,NULL,oa);
+  flood_lsa(NULL,NULL,&oa->rt->lsa,po,NULL,oa,1);
 }
 
 void *
@@ -283,40 +284,39 @@ originate_net_lsa(struct ospf_iface *ifa, struct proto_ospf *po)
   struct top_hash_entry *en;
   void *body;
 
-
-  if(ifa->state!=OSPF_IS_DR) return;
-
   debug("%s: Originating Net lsa for iface \"%s\".\n", po->proto.name,
     ifa->iface->name);
 
-  if(ifa->fadj==0)
+  if((ifa->state!=OSPF_IS_DR)||(ifa->fadj==0))
   {
     if(ifa->nlsa==NULL) return;
 
-    lsa.sn+=1;
-    lsa.age=LSA_MAXAGE;
-    flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa);
-    /* FIXME delete LSA */
+    ifa->nlsa->lsa.sn+=1;
+    ifa->nlsa->lsa.age=LSA_MAXAGE;
+    flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa,0);
+    ospf_hash_delete(ifa->oa->gr, ifa->nlsa);
     ifa->nlsa=NULL;
     return ;
   }
 
   lsa.age=0;
-  lsa.id=rtid;
+  lsa.id=ipa_to_u32(ifa->iface->addr->ip);
   lsa.type=LSA_T_NET;
   lsa.rt=rtid;
+  lsa.options=0;
   if(ifa->nlsa==NULL)
   {
     lsa.sn=LSA_INITSEQNO;
   }
   else
   {
-    lsa.sn+=1;
+    lsa.sn=ifa->nlsa->lsa.sn+1;
   }
+
   body=originate_net_lsa_body(ifa, &lsa.length, po);
   lsasum_calculate(&lsa,body,po);
   ifa->nlsa=lsa_install_new(&lsa, body, ifa->oa, &po->proto);
-  flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa);
+  flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa,1);
 }
 
 void *
@@ -375,7 +375,7 @@ originate_ext_lsa(net *n, rte *e, struct proto_ospf *po)
     en=lsa_install_new(&lsa, body, ifa->oa, &po->proto);
   }
   if(en==NULL) die("Some bug in Ext lsa generating\n");
-  flood_lsa(NULL,NULL,&en->lsa,po,NULL,ifa->oa);
+  flood_lsa(NULL,NULL,&en->lsa,po,NULL,ifa->oa,1);
 }