* bgpd.texi: Document new "bgp bestpath as-path confed" command.
* bgp_aspath.[ch], bgp_route.c, bgp_vty.c, bgpd.[ch]: Allow to enable
the length of confederation path segments to be included during the
as-path length check in the best path decision.
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 4f3847d..8d99249 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -213,10 +213,26 @@
/* 4. AS path length check. */
if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
{
- if (new->attr->aspath->count < exist->attr->aspath->count)
- return 1;
- if (new->attr->aspath->count > exist->attr->aspath->count)
- return 0;
+ if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
+ {
+ if ((new->attr->aspath->count +
+ new->attr->aspath->confed_count)
+ < (exist->attr->aspath->count +
+ exist->attr->aspath->confed_count))
+ return 1;
+ if ((new->attr->aspath->count +
+ new->attr->aspath->confed_count)
+ > (exist->attr->aspath->count +
+ exist->attr->aspath->confed_count))
+ return 0;
+ }
+ else
+ {
+ if (new->attr->aspath->count < exist->attr->aspath->count)
+ return 1;
+ if (new->attr->aspath->count > exist->attr->aspath->count)
+ return 0;
+ }
}
/* 5. Origin check. */