Install route into main routing table just if it's necessary.

This commit is contained in:
Ondrej Filip 2001-06-12 21:10:30 +00:00
parent c48b33292b
commit 24c00cb119
2 changed files with 51 additions and 30 deletions

View file

@ -14,7 +14,9 @@ init_infib(struct fib_node *fn)
struct infib *f=(struct infib *)fn; struct infib *f=(struct infib *)fn;
f->metric=LSINFINITY; f->metric=LSINFINITY;
f->oldmetric=LSINFINITY;
f->en=NULL; f->en=NULL;
f->olden=NULL;
} }
void void
@ -26,6 +28,9 @@ init_efib(struct fib_node *fn)
f->metric2=LSINFINITY; f->metric2=LSINFINITY;
f->nh=ipa_from_u32(0); f->nh=ipa_from_u32(0);
f->nhi=NULL; f->nhi=NULL;
f->oldmetric=LSINFINITY;
f->oldmetric2=LSINFINITY;
f->oldnh=ipa_from_u32(0);
} }
/** /**
@ -211,11 +216,12 @@ again:
en->nhi=nn->iface; en->nhi=nn->iface;
} }
if((nf->en!=nf->olden)||(nf->metric!=nf->oldmetric))
{ {
net *ne; net *ne;
rta a0; rta a0;
rte *e; rte *e;
struct top_hash_entry *en=nf->en; struct top_hash_entry *en=nf->en;
ln=en->lsa_body; ln=en->lsa_body;
bzero(&a0, sizeof(a0)); bzero(&a0, sizeof(a0));
@ -241,6 +247,9 @@ again:
DBG("Modifying rt entry %I\n (GW: %I, Iface: %s)\n", DBG("Modifying rt entry %I\n (GW: %I, Iface: %s)\n",
nf->fn.prefix,en->nh,en->nhi->name); nf->fn.prefix,en->nh,en->nhi->name);
rte_update(p->table, ne, p, e); rte_update(p->table, ne, p, e);
nf->olden=nf->en;
nf->oldmetric=nf->metric;
} }
} }
@ -480,34 +489,41 @@ noch:
goto noch; goto noch;
} }
else else
{ if((nf->metric!=nf->oldmetric)||(nf->metric2!=nf->oldmetric2)||
net *ne; (!ipa_equal(nf->nh,nf->oldnh))||(nf->tag!=nf->oldtag))
rta a0; {
rte *e; net *ne;
rta a0;
bzero(&a0, sizeof(a0)); rte *e;
a0.proto=p; bzero(&a0, sizeof(a0));
a0.source=RTS_OSPF_EXT;
a0.scope=SCOPE_UNIVERSE; a0.proto=p;
a0.cast=RTC_UNICAST; a0.source=RTS_OSPF_EXT;
a0.dest=RTD_ROUTER; a0.scope=SCOPE_UNIVERSE;
a0.flags=0; a0.cast=RTC_UNICAST;
a0.aflags=0; a0.dest=RTD_ROUTER;
a0.iface=nf->nhi; a0.flags=0;
a0.gw=nf->nh; a0.aflags=0;
ne=net_get(p->table, nf->fn.prefix, nf->fn.pxlen); a0.iface=nf->nhi;
e=rte_get_temp(&a0); a0.gw=nf->nh;
e->u.ospf.metric1=nf->metric; ne=net_get(p->table, nf->fn.prefix, nf->fn.pxlen);
e->u.ospf.metric2=nf->metric2; e=rte_get_temp(&a0);
e->u.ospf.tag=nf->tag; e->u.ospf.metric1=nf->metric;
e->pflags = 0; e->u.ospf.metric2=nf->metric2;
e->net=ne; e->u.ospf.tag=nf->tag;
e->pref = p->preference; e->pflags = 0;
DBG("Modifying rt entry %I\n (IP: %I, GW: %I)\n", e->net=ne;
nf->fn.prefix,ip,nf->nh); e->pref = p->preference;
rte_update(p->table, ne, p, e); DBG("Modifying rt entry %I\n (IP: %I, GW: %I)\n",
} nf->fn.prefix,ip,nf->nh);
rte_update(p->table, ne, p, e);
nf->oldmetric=nf->metric;
nf->oldmetric2=nf->metric2;
nf->oldnh=nf->nh;
nf->oldtag=nf->tag;
}
} }
let: let:
FIB_ITERATE_END(nftmp); FIB_ITERATE_END(nftmp);

View file

@ -13,8 +13,9 @@
struct infib { struct infib {
struct fib_node fn; struct fib_node fn;
u16 metric; u16 metric;
u16 pad; u16 oldmetric;
struct top_hash_entry *en; struct top_hash_entry *en;
struct top_hash_entry *olden;
}; };
struct extfib { struct extfib {
@ -24,6 +25,10 @@ struct extfib {
ip_addr nh; ip_addr nh;
u32 tag; u32 tag;
struct iface *nhi; struct iface *nhi;
u16 oldmetric;
u16 oldmetric2;
ip_addr oldnh;
u32 oldtag;
}; };
void ospf_rt_spfa(struct ospf_area *oa); void ospf_rt_spfa(struct ospf_area *oa);