* 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_aspath.c b/bgpd/bgp_aspath.c
index 5d49775..0c50f6a 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -138,6 +138,7 @@
   int str_pnt;
   char *str_buf;
   int count = 0;
+  int confed_count = 0;
 
   /* Empty aspath. */
   if (as->length == 0)
@@ -145,6 +146,7 @@
       str_buf = XMALLOC (MTYPE_AS_STR, 1);
       str_buf[0] = '\0';
       as->count = count;
+      as->confed_count = confed_count;
       return str_buf;
     }
 
@@ -208,14 +210,21 @@
 
       space = 0;
 
-      /* Increment count - ignoring CONFED SETS/SEQUENCES */
-      if (assegment->type != AS_CONFED_SEQUENCE
-	  && assegment->type != AS_CONFED_SET)
+      /* Increment counts */
+      switch (assegment->type)
 	{
-	  if (assegment->type == AS_SEQUENCE)
-	    count += assegment->length;
-	  else if (assegment->type == AS_SET)
-	    count++;
+	case AS_SEQUENCE:
+	  count += assegment->length;
+	  break;
+	case AS_SET:
+	  count++;
+	  break;
+	case AS_CONFED_SEQUENCE:
+	  confed_count += assegment->length;
+	  break;
+	case AS_CONFED_SET:
+	  confed_count++;
+	  break;
 	}
 
       for (i = 0; i < assegment->length; i++)
@@ -247,6 +256,7 @@
   str_buf[str_pnt] = '\0';
 
   as->count = count;
+  as->confed_count = confed_count;
 
   return str_buf;
 }