From 3dd8f983b649c83f50d44ca2093ab1f931eaba4d Mon Sep 17 00:00:00 2001 From: Ondrej Filip Date: Tue, 30 May 2000 17:51:22 +0000 Subject: You can decide if add LSA into lsrth during flood_lsa(). --- proto/ospf/lsupd.c | 43 +++++++++++++++++++++++++++++-------------- proto/ospf/lsupd.h | 2 +- proto/ospf/topology.c | 28 ++++++++++++++-------------- 3 files changed, 44 insertions(+), 29 deletions(-) (limited to 'proto') diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c index 1e70159..d306fd4 100644 --- a/proto/ospf/lsupd.c +++ b/proto/ospf/lsupd.c @@ -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); } diff --git a/proto/ospf/lsupd.h b/proto/ospf/lsupd.h index 56368ba..61dd5d0 100644 --- a/proto/ospf/lsupd.h +++ b/proto/ospf/lsupd.h @@ -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); diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index f54c63b..053ea4b 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -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); } -- cgit v1.2.3