From f321a61f77262d33dd43d50136c8116ebf8139c6 Mon Sep 17 00:00:00 2001 From: Ondrej Filip Date: Fri, 18 Aug 2000 16:44:37 +0000 Subject: Fixed bug in nex hop calculation of external routes. --- proto/ospf/rt.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'proto/ospf') diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index 743b585..a7b541d 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -263,6 +263,7 @@ ospf_ext_spfa(struct proto_ospf *po) /* FIXME looking into inter-area */ struct top_hash_entry *en,*etmp,*absr; struct fib *ef=&po->efib; struct extfib *nf; + struct infib *inf; struct fib_iterator fit; struct ospf_area *oa=NULL,*atmp,*absroa; struct proto *p=&po->proto; @@ -366,18 +367,18 @@ ospf_ext_spfa(struct proto_ospf *po) /* FIXME looking into inter-area */ } tag=lt->tag; } - else + else /* FW address !=0 */ { - nf=NULL; /* FW address !=0 */ + inf=NULL; WALK_LIST(atmp,po->area_list) { - if((nf=fib_route(&atmp->infib,lt->fwaddr,32))!=NULL) + if((inf=fib_route(&atmp->infib,lt->fwaddr,32))!=NULL) { break; } } - if(nf==NULL) + if(inf==NULL) { DBG("Cannot find network route (GW=%I)\n",lt->fwaddr); continue; @@ -385,42 +386,46 @@ ospf_ext_spfa(struct proto_ospf *po) /* FIXME looking into inter-area */ if(lt->etos>0) { - met=nf->metric; + met=inf->metric; met2=lt->metric; } else { - met=nf->metric+lt->metric; + met=inf->metric+lt->metric; met2=LSINFINITY; } tag=lt->tag; if((nn=neigh_find(p,<->fwaddr,0))!=NULL) { - nnh=nn->addr; + nnh=IPA_NONE; nnhi=nn->iface; } else { - nnh=nf->nh; - nnhi=nf->nhi; + nnh=inf->en->nh; + nnhi=inf->en->nhi; } - } nf=fib_get(ef,&ip, mlen); - if(((nf->metric>met)&&(nf->metric2==met2)) || /* both E1 or E2 + if((nf->metric==LSINFINITY) || /* nf is new */ + ((metmetric)&&(nf->metric2==met2)) || /* both E1 or E2 * with same metric */ - ((nf->metric2>met2)&&(nf->metric2!=LSINFINITY)) || /* E2 smaller and + ((met2metric2)&&(nf->metric2!=LSINFINITY)) || /* E2 smaller and * 1st is not E1 */ ((nf->metric2!=LSINFINITY)&&(met2==LSINFINITY))) /* 2nd is E1 and * 1st is E2 */ { + if(nf->metric!=LSINFINITY) + OSPF_TRACE(D_EVENTS, + "Rewritting %I/%d met=%d, met2=%d, nmet=%d, nmet2=%d", + ip, mlen, nf->metric, nf->metric2, met, met2); nf->metric=met; nf->metric2=met2; nf->tag=tag; - if(ipa_compare(nnh,ipa_from_u32(0))!=0) + if(nnhi!=NULL) { nf->nh=nnh; nf->nhi=nnhi; -- cgit v1.2.3