summaryrefslogtreecommitdiff
path: root/proto/bgp/attrs.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2009-11-17 11:41:29 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2009-11-17 11:41:29 +0100
commit3228c72cc030f409914134440a7e55bbcfc9ff6a (patch)
tree19a1ee75446e86e620dc0322e5e50e3c4a4eba27 /proto/bgp/attrs.c
parent2eece54a04d95f534b935ccac4c3959b25516bd5 (diff)
Implements RFC 5004 - prefer older external routes.
Diffstat (limited to 'proto/bgp/attrs.c')
-rw-r--r--proto/bgp/attrs.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index d839ed09..9c7bc30a 100644
--- a/proto/bgp/attrs.c
+++ b/proto/bgp/attrs.c
@@ -1044,7 +1044,6 @@ bgp_rte_better(rte *new, rte *old)
return 0;
/* RFC 4271 9.1.2.2. c) Compare MED's */
-
if (bgp_get_neighbor(new) == bgp_get_neighbor(old))
{
x = ea_find(new->attrs->eattrs, EA_CODE(EAP_BGP, BA_MULTI_EXIT_DISC));
@@ -1082,12 +1081,19 @@ bgp_rte_better(rte *new, rte *old)
y = ea_find(old->attrs->eattrs, EA_CODE(EAP_BGP, BA_ORIGINATOR_ID));
n = x ? x->u.data : new_bgp->remote_id;
o = y ? y->u.data : old_bgp->remote_id;
+
+ /* RFC 5004 - prefer older routes */
+ /* (if both are external and from different peer) */
+ if ((new_bgp->cf->prefer_older || old_bgp->cf->prefer_older) &&
+ !new_bgp->is_internal && n != o)
+ return 0;
+
+ /* rest of RFC 4271 9.1.2.2. f) */
if (n < o)
return 1;
if (n > o)
return 0;
-
/* RFC 4271 9.1.2.2. g) Compare peer IP adresses */
return (ipa_compare(new_bgp->cf->remote_ip, old_bgp->cf->remote_ip) < 0);
}