summaryrefslogtreecommitdiffstats
path: root/proto/ospf
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2000-08-16 21:03:06 +0200
committerOndrej Filip <feela@network.cz>2000-08-16 21:03:06 +0200
commitd6a7e2fb8590660c00e984ff41d2e668d2ead69b (patch)
tree1f9c67e4aa113245ccdfa6a2b5bd2a491ec844b7 /proto/ospf
parente7894eceded6ea1f757829a8845863c57660c9dd (diff)
downloadbird-d6a7e2fb8590660c00e984ff41d2e668d2ead69b.tar
bird-d6a7e2fb8590660c00e984ff41d2e668d2ead69b.zip
Bug in rte_better.
Diffstat (limited to 'proto/ospf')
-rw-r--r--proto/ospf/ospf.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index 589e371..0a151c4 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -175,24 +175,32 @@ ospf_rte_better(struct rte *new, struct rte *old)
if(new->u.ospf.metric1=LSINFINITY) return 0;
+ /* External paths are always longer that internal */
if(((new->attrs->source==RTS_OSPF) || (new->attrs->source==RTS_OSPF_IA))
&& (old->attrs->source==RTS_OSPF_EXT)) return 1;
-
if(((old->attrs->source==RTS_OSPF) || (old->attrs->source==RTS_OSPF_IA))
&& (new->attrs->source==RTS_OSPF_EXT)) return 0;
- if(new->u.ospf.metric2!=0)
+ if(new->u.ospf.metric2<old->u.ospf.metric2)
{
- if(old->u.ospf.metric2==0) return 0;
- if(new->u.ospf.metric2<old->u.ospf.metric2) return 1;
- return 0;
+ if(old->u.ospf.metric2==LSINFINITY) return 0; /* Old is E1, new is E2 */
+ return 1; /* Both are E2 */
}
- else
+
+ if(new->u.ospf.metric2>old->u.ospf.metric2)
{
- if(old->u.ospf.metric2!=0) return 1;
- if(new->u.ospf.metric1<old->u.ospf.metric1) return 1;
- return 0;
+ if(new->u.ospf.metric2==LSINFINITY) return 1; /* New is E1, old is E2 */
+ return 0; /* Both are E2 */
}
+
+ /*
+ * E2 metrics are the same. It means that:
+ * 1) Paths are E2 with same metric
+ * 2) Paths are E1.
+ */
+
+ if(new->u.ospf.metric1<old->u.ospf.metric1) return 1;
+ return 0; /* Old is shorter or same */
}
static int
@@ -419,9 +427,9 @@ ospf_get_route_info(rte *rte, byte *buf, ea_list *attrs)
if(rte->attrs->source==RTS_OSPF) type='I';
buf += bsprintf(buf, " %c", type);
if(met!=' ') buf += bsprintf(buf, "%c", met);
- buf += bsprintf(buf, " (%d/%d)", rte->pref,
- (rte->u.ospf.metric2==LSINFINITY) ? rte->u.ospf.metric1 :
- rte->u.ospf.metric2);
+ buf += bsprintf(buf, " (%d/%d", rte->pref, rte->u.ospf.metric1);
+ if(rte->u.ospf.metric2!=LSINFINITY) buf += bsprintf(buf, "/%d", rte->u.ospf.metric2);
+ buf += bsprintf(buf, ")");
if(rte->attrs->source==RTS_OSPF_EXT && rte->u.ospf.tag)
{
buf += bsprintf(buf, " [%x]", rte->u.ospf.tag);