diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2010-07-31 01:04:32 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2010-07-31 01:04:32 +0200 |
commit | d1e146f2f8da303af7bbe0cec363cc15c58c37fd (patch) | |
tree | 7179724c7752d0c3ae5801736f8071b71243c60e /proto/bgp/attrs.c | |
parent | ac3ac49a71d4b290cfb28aecafc8ac4a69df7a64 (diff) |
Implements IGP metric comparison for BGP routes.
Diffstat (limited to 'proto/bgp/attrs.c')
-rw-r--r-- | proto/bgp/attrs.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 3e7c94a6..ef5d024e 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -1084,8 +1084,13 @@ bgp_rte_better(rte *new, rte *old) if (new_bgp->is_internal < old_bgp->is_internal) return 1; - /* Skipping RFC 4271 9.1.2.2. e) */ - /* We don't have interior distances */ + /* RFC 4271 9.1.2.2. e) Compare IGP metrics */ + n = new_bgp->cf->igp_metric ? new->attrs->igp_metric : 0; + o = old_bgp->cf->igp_metric ? old->attrs->igp_metric : 0; + if (n < o) + return 1; + if (n > o) + return 0; /* RFC 4271 9.1.2.2. f) Compare BGP identifiers */ /* RFC 4456 9. a) Use ORIGINATOR_ID instead of local neighor ID */ @@ -1494,7 +1499,18 @@ bgp_get_route_info(rte *e, byte *buf, ea_list *attrs) eattr *o = ea_find(attrs, EA_CODE(EAP_BGP, BA_ORIGIN)); u32 origas; - buf += bsprintf(buf, " (%d) [", e->pref); + buf += bsprintf(buf, " (%d", e->pref); + if (e->attrs->hostentry) + { + if (!e->attrs->iface) + buf += bsprintf(buf, "/-"); + else if (e->attrs->igp_metric >= IGP_METRIC_UNKNOWN) + buf += bsprintf(buf, "/?"); + else + buf += bsprintf(buf, "/%d", e->attrs->igp_metric); + } + buf += bsprintf(buf, ") ["); + if (p && as_path_get_last(p->u.ptr, &origas)) buf += bsprintf(buf, "AS%u", origas); if (o) |