0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 17:51:53 +00:00

Routing table calculation clean up.

This commit is contained in:
Ondrej Filip 2000-06-19 15:12:50 +00:00
parent ca00d4a13a
commit 972fdb4532

View File

@ -404,14 +404,15 @@ ospf_ext_spfa(struct proto_ospf *po) /* FIXME looking into inter-area */
nf->metric=met; nf->metric=met;
nf->metric2=met2; nf->metric2=met2;
nf->tag=tag; nf->tag=tag;
if(nnhi!=NULL)
if(ipa_compare(nnh,ipa_from_u32(0))!=0)
{ {
nf->nh=nnh; nf->nh=nnh;
nf->nhi=nnhi; nf->nhi=nnhi;
} }
else else
{ {
if(absr->nhi==NULL) if(ipa_compare(absr->nh,ipa_from_u32(0))==0)
{ {
struct ospf_neighbor *neigh; struct ospf_neighbor *neigh;
@ -559,61 +560,64 @@ calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en,
struct proto *p=&oa->po->proto; struct proto *p=&oa->po->proto;
struct proto_ospf *po=oa->po; struct proto_ospf *po=oa->po;
struct ospf_iface *ifa; struct ospf_iface *ifa;
u32 myrid=p->cf->global->router_id;
DBG(" Next hop called\n"); DBG(" Next hop called\n");
if(ipa_to_u32(par->nh)==0) if(ipa_to_u32(par->nh)==0)
{ {
neighbor *nn; neighbor *nn;
DBG(" Next hop calculating for id: %I rt: %I type: %u\n",en->lsa.id,en->lsa.rt,en->lsa.type); DBG(" Next hop calculating for id: %I rt: %I type: %u\n",
if(par->lsa.type!=LSA_T_RT) en->lsa.id,en->lsa.rt,en->lsa.type);
{
if((neigh=find_neigh_noifa(po,en->lsa.rt))==NULL) return;
nn=neigh_find(p,&neigh->ip,0);
DBG(" Next hop calculated: %I.\n", nn->addr);
en->nh=nn->addr;
en->nhi=nn->iface;
return;
}
else
{
if(par==oa->rt) if(par==oa->rt)
{ {
if(en->lsa.type==LSA_T_NET) if(en->lsa.type==LSA_T_NET)
{ {
struct ospf_lsa_net *ne; if(en->lsa.rt==myrid)
ne=en->lsa_body;
DBG("I'm parent (Net=%I)\n",(en->lsa.id & ipa_to_u32(ne->netmask)));
WALK_LIST(ifa, oa->po->iface_list)
{ {
if(ipa_to_u32(ipa_and(ifa->iface->addr->ip, WALK_LIST(ifa,po->iface_list)
ipa_mkmask(ifa->iface->addr->pxlen))) == if(ipa_compare(ifa->iface->addr->ip,ipa_from_u32(en->lsa.id))==0)
(en->lsa.id & ipa_to_u32(ne->netmask)))
{ {
en->nhi=ifa->iface; en->nhi=ifa->iface;
en->nh=ipa_from_u32(0); return;
DBG("Ifa: %s\n",en->nhi->name); }
bug("I didn't find interface for my self originated LSA!\n");
}
else
{
ip_addr ip=ipa_from_u32(en->lsa.id);
nn=neigh_find(p,&ip,0);
if(nn) en->nhi=nn->iface;
return; return;
} }
} }
else
{
if((neigh=find_neigh_noifa(po,en->lsa.rt))==NULL) return;
en->nhi=neigh->ifa->iface;
return;
}
}
if(par->lsa.type==LSA_T_NET)
{
if(en->lsa.type==LSA_T_NET) bug("Parent for net is net?");
en->nhi=par->nhi;
if((neigh=find_neigh_noifa(po,en->lsa.rt))==NULL) return;
en->nh=neigh->ip;
return;
} }
else else
{ {
if((neigh=find_neigh_noifa(po,par->lsa.rt))==NULL) return; if((neigh=find_neigh_noifa(po,par->lsa.rt))==NULL) return;
nn=neigh_find(p,&neigh->ip,0); nn=neigh_find(p,&neigh->ip,0);
en->nh=ipa_from_u32(0); if(nn)
{
en->nhi=nn->iface; en->nhi=nn->iface;
en->nh=neigh->ip;
} }
return; return;
} }
if((neigh=find_neigh_noifa(po,par->lsa.rt))==NULL) return;
nn=neigh_find(p,&neigh->ip,0);
DBG(" Next hop calculated: %I\n", nn->addr);
en->nh=nn->addr;
en->nhi=nn->iface;
return;
}
} }
en->nh=par->nh; en->nh=par->nh;
en->nhi=par->nhi; en->nhi=par->nhi;