You can decide if add LSA into lsrth during flood_lsa().
This commit is contained in:
parent
3d410fdfa1
commit
3dd8f983b6
3 changed files with 44 additions and 29 deletions
|
@ -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,6 +70,8 @@ flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
|
|||
}
|
||||
}
|
||||
if(nn==n) continue;
|
||||
if(rtl!=0)
|
||||
{
|
||||
if((en=ospf_hash_find_header(nn->lsrth, hh))==NULL)
|
||||
{
|
||||
en=ospf_hash_get_header(nn->lsrth, hh);
|
||||
|
@ -84,6 +86,15 @@ flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
|
|||
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
|
||||
{
|
||||
if((en=ospf_hash_find_header(nn->lsrth, hh))!=NULL)
|
||||
{
|
||||
s_rem_node(SNODE en);
|
||||
ospf_hash_delete(nn->lsrth, en);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue