diff options
-rw-r--r-- | proto/ospf/rt.c | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index cbda6c0c..9b1b5faa 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -289,6 +289,11 @@ ospf_ext_spfa(struct proto_ospf *po) /* FIXME looking into inter-area */ if(lt->metric==LSINFINITY) continue; ip=ipa_and(ipa_from_u32(en->lsa.id),le->netmask); mlen=ipa_mklen(le->netmask); + if((mlen<0)||(mlen>32)) + { + die("Invalid length of prefix! ID: %I, RT: %I, Type: %u, mask %I", + en->lsa.id,en->lsa.rt,en->lsa.type,le->netmask); + } nf=NULL; @@ -304,32 +309,57 @@ ospf_ext_spfa(struct proto_ospf *po) /* FIXME looking into inter-area */ met=0;met2=0; + WALK_LIST(atmp,po->area_list) + { + if((etmp=ospf_hash_find(atmp->gr,en->lsa.rt,en->lsa.rt,LSA_T_RT))!=NULL) + { + if((absr==NULL) || (absr->dist>etmp->dist) || + ((etmp->dist==absr->dist) && (absroa->areaid<atmp->areaid))) + { + absr=etmp; + absroa=atmp; + break; + } + } + } + if(absr==NULL) continue; + if(1 || ipa_compare(lt->fwaddr,ipa_from_u32(0))==0) /* FIXME add fwaddr */ { + if(lt->etos>0) + { + met=absr->dist; + met2=lt->metric; + } + else + { + met=absr->dist+lt->metric; + met2=0; + } + } + else + { + nf=NULL; WALK_LIST(atmp,po->area_list) { - if((etmp=ospf_hash_find(atmp->gr,en->lsa.rt,en->lsa.rt,LSA_T_RT))!=NULL) + if((nf=fib_route(&atmp->infib,lt->fwaddr,32))!=NULL) { - if((absr==NULL) || (absr->dist>etmp->dist) || - ((etmp->dist==absr->dist) && (absroa->areaid<atmp->areaid))) - { - absr=etmp; - absroa=atmp; - } + break; } } - if(absr==NULL) continue; + if(nf==NULL) continue; if(lt->etos>0) { - met=absr->dist; + met=nf->metric; met2=lt->metric; } else { - met=absr->dist+lt->metric; + met=nf->metric+lt->metric; met2=0; } } + nf=fib_get(ef,&ip, mlen); if((nf->metric>met) || ((nf->metric==met)&&(nf->metric2>met2))) { |