summaryrefslogtreecommitdiffstats
path: root/proto/ospf
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2001-06-12 23:10:30 +0200
committerOndrej Filip <feela@network.cz>2001-06-12 23:10:30 +0200
commit24c00cb11915edb8c13dbc21f245a73fc34689ed (patch)
treeea132db069855dcf2271ced554e94a35c9acf841 /proto/ospf
parentc48b33292b6d39cdacd642565907c0d5b90adc68 (diff)
downloadbird-24c00cb11915edb8c13dbc21f245a73fc34689ed.tar
bird-24c00cb11915edb8c13dbc21f245a73fc34689ed.zip
Install route into main routing table just if it's necessary.
Diffstat (limited to 'proto/ospf')
-rw-r--r--proto/ospf/rt.c74
-rw-r--r--proto/ospf/rt.h7
2 files changed, 51 insertions, 30 deletions
diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c
index c7131fc..6298695 100644
--- a/proto/ospf/rt.c
+++ b/proto/ospf/rt.c
@@ -14,7 +14,9 @@ init_infib(struct fib_node *fn)
struct infib *f=(struct infib *)fn;
f->metric=LSINFINITY;
+ f->oldmetric=LSINFINITY;
f->en=NULL;
+ f->olden=NULL;
}
void
@@ -26,6 +28,9 @@ init_efib(struct fib_node *fn)
f->metric2=LSINFINITY;
f->nh=ipa_from_u32(0);
f->nhi=NULL;
+ f->oldmetric=LSINFINITY;
+ f->oldmetric2=LSINFINITY;
+ f->oldnh=ipa_from_u32(0);
}
/**
@@ -211,11 +216,12 @@ again:
en->nhi=nn->iface;
}
+ if((nf->en!=nf->olden)||(nf->metric!=nf->oldmetric))
{
net *ne;
rta a0;
rte *e;
- struct top_hash_entry *en=nf->en;
+ struct top_hash_entry *en=nf->en;
ln=en->lsa_body;
bzero(&a0, sizeof(a0));
@@ -241,6 +247,9 @@ again:
DBG("Modifying rt entry %I\n (GW: %I, Iface: %s)\n",
nf->fn.prefix,en->nh,en->nhi->name);
rte_update(p->table, ne, p, e);
+
+ nf->olden=nf->en;
+ nf->oldmetric=nf->metric;
}
}
@@ -480,34 +489,41 @@ noch:
goto noch;
}
else
- {
- net *ne;
- rta a0;
- rte *e;
-
- bzero(&a0, sizeof(a0));
-
- a0.proto=p;
- a0.source=RTS_OSPF_EXT;
- a0.scope=SCOPE_UNIVERSE;
- a0.cast=RTC_UNICAST;
- a0.dest=RTD_ROUTER;
- a0.flags=0;
- a0.aflags=0;
- a0.iface=nf->nhi;
- a0.gw=nf->nh;
- ne=net_get(p->table, nf->fn.prefix, nf->fn.pxlen);
- e=rte_get_temp(&a0);
- e->u.ospf.metric1=nf->metric;
- e->u.ospf.metric2=nf->metric2;
- e->u.ospf.tag=nf->tag;
- e->pflags = 0;
- e->net=ne;
- e->pref = p->preference;
- DBG("Modifying rt entry %I\n (IP: %I, GW: %I)\n",
- nf->fn.prefix,ip,nf->nh);
- rte_update(p->table, ne, p, e);
- }
+ if((nf->metric!=nf->oldmetric)||(nf->metric2!=nf->oldmetric2)||
+ (!ipa_equal(nf->nh,nf->oldnh))||(nf->tag!=nf->oldtag))
+ {
+ net *ne;
+ rta a0;
+ rte *e;
+
+ bzero(&a0, sizeof(a0));
+
+ a0.proto=p;
+ a0.source=RTS_OSPF_EXT;
+ a0.scope=SCOPE_UNIVERSE;
+ a0.cast=RTC_UNICAST;
+ a0.dest=RTD_ROUTER;
+ a0.flags=0;
+ a0.aflags=0;
+ a0.iface=nf->nhi;
+ a0.gw=nf->nh;
+ ne=net_get(p->table, nf->fn.prefix, nf->fn.pxlen);
+ e=rte_get_temp(&a0);
+ e->u.ospf.metric1=nf->metric;
+ e->u.ospf.metric2=nf->metric2;
+ e->u.ospf.tag=nf->tag;
+ e->pflags = 0;
+ e->net=ne;
+ e->pref = p->preference;
+ 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:
FIB_ITERATE_END(nftmp);
diff --git a/proto/ospf/rt.h b/proto/ospf/rt.h
index efd0906..ba78e62 100644
--- a/proto/ospf/rt.h
+++ b/proto/ospf/rt.h
@@ -13,8 +13,9 @@
struct infib {
struct fib_node fn;
u16 metric;
- u16 pad;
+ u16 oldmetric;
struct top_hash_entry *en;
+ struct top_hash_entry *olden;
};
struct extfib {
@@ -24,6 +25,10 @@ struct extfib {
ip_addr nh;
u32 tag;
struct iface *nhi;
+ u16 oldmetric;
+ u16 oldmetric2;
+ ip_addr oldnh;
+ u32 oldtag;
};
void ospf_rt_spfa(struct ospf_area *oa);