]> git.puffer.fish Git - matthieu/frr.git/commitdiff
* bgpd.texi: Document new "bgp bestpath as-path confed" command.
authorhasso <hasso>
Fri, 8 Apr 2005 15:40:36 +0000 (15:40 +0000)
committerhasso <hasso>
Fri, 8 Apr 2005 15:40:36 +0000 (15:40 +0000)
* 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.

bgpd/ChangeLog
bgpd/bgp_aspath.c
bgpd/bgp_aspath.h
bgpd/bgp_route.c
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h
doc/ChangeLog
doc/bgpd.texi

index 4c18fc39327cfcb87e0a255b1c3c409b5096710f..6dc1e7e01286ab77fa090388db4ecfba196e3ef2 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-08 Martin Ling <martin-quagga@earth.li>
+
+       * 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.
+
 2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
        * bgp_zebra.c: (bgp_interface_delete) After deleting, set ifp->ifindex
index 5d4977510917cf597dbde57cbfe62c0ec5b2f42d..0c50f6a6ab37d6e9b23687cadd589624cab92754 100644 (file)
@@ -138,6 +138,7 @@ aspath_make_str_count (struct aspath *as)
   int str_pnt;
   char *str_buf;
   int count = 0;
+  int confed_count = 0;
 
   /* Empty aspath. */
   if (as->length == 0)
@@ -145,6 +146,7 @@ aspath_make_str_count (struct aspath *as)
       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 @@ aspath_make_str_count (struct aspath *as)
 
       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 @@ aspath_make_str_count (struct aspath *as)
   str_buf[str_pnt] = '\0';
 
   as->count = count;
+  as->confed_count = confed_count;
 
   return str_buf;
 }
index 3f7858befe53005f319310a209dc49963ba3568a..bfe4f5e819fa927bb8bf3c8a17563987fa195e48 100644 (file)
@@ -42,6 +42,9 @@ struct aspath
   /* AS count.  */
   int count;
 
+  /* Confederation set/segment AS count. */
+  int confed_count;
+  
   /* Rawdata.  */
   caddr_t data;
 
index 4f3847d66fd6193a2bafc8e50c857126df51f76d..8d99249569beae7d30961b4a908d5d64d86130db 100644 (file)
@@ -213,10 +213,26 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist)
   /* 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. */
index 52025b76f8225f4e53268643b900409d39162682..f7a41f5bd06ea8071b925d619d7954cb85568ba1 100644 (file)
@@ -971,6 +971,38 @@ DEFUN (no_bgp_bestpath_aspath_ignore,
   return CMD_SUCCESS;
 }
 \f
+/* "bgp bestpath as-path confed" configuration.  */
+DEFUN (bgp_bestpath_aspath_confed,
+       bgp_bestpath_aspath_confed_cmd,
+       "bgp bestpath as-path confed",
+       "BGP specific commands\n"
+       "Change the default bestpath selection\n"
+       "AS-path attribute\n"
+       "Compare path lengths including confederation sets & sequences in selecting a route\n")
+{
+  struct bgp *bgp;
+
+  bgp = vty->index;
+  bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_bgp_bestpath_aspath_confed,
+       no_bgp_bestpath_aspath_confed_cmd,
+       "no bgp bestpath as-path confed",
+       NO_STR
+       "BGP specific commands\n"
+       "Change the default bestpath selection\n"
+       "AS-path attribute\n"
+       "Compare path lengths including confederation sets & sequences in selecting a route\n")
+{
+  struct bgp *bgp;
+
+  bgp = vty->index;
+  bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
+  return CMD_SUCCESS;
+}
+\f
 /* "bgp log-neighbor-changes" configuration.  */
 DEFUN (bgp_log_neighbor_changes,
        bgp_log_neighbor_changes_cmd,
@@ -8626,6 +8658,10 @@ bgp_vty_init ()
   install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
   install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
 
+  /* "bgp bestpath as-path confed" commands */
+  install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
+  install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
+
   /* "bgp log-neighbor-changes" commands */
   install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
   install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
index d1e8d9697010fec2ce76c778a1e6473fb0e3b2fd..0d1689ab3566a8359e439813f0162ab42e691068 100644 (file)
@@ -4751,6 +4751,8 @@ bgp_config_write (struct vty *vty)
       /* BGP bestpath method. */
       if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
        vty_out (vty, " bgp bestpath as-path ignore%s", VTY_NEWLINE);
+      if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
+       vty_out (vty, " bgp bestpath as-path confed%s", VTY_NEWLINE);
       if (bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID))
        vty_out (vty, " bgp bestpath compare-routerid%s", VTY_NEWLINE);
       if (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
index a6c11ffae7a8c9ec7a6ca1940703bbdd63bb8fff..a0cf7e8ea0e0152e5179a0435a8a402291e100aa 100644 (file)
@@ -101,6 +101,7 @@ struct bgp
 #define BGP_FLAG_NO_FAST_EXT_FAILOVER     (1 << 10)
 #define BGP_FLAG_LOG_NEIGHBOR_CHANGES     (1 << 11)
 #define BGP_FLAG_GRACEFUL_RESTART         (1 << 12)
+#define BGP_FLAG_ASPATH_CONFED            (1 << 13)
 
   /* BGP Per AF flags */
   u_int16_t af_flags[AFI_MAX][SAFI_MAX];
index f37341440ec4d724c9cad86b01cf69a9c2218927..f07f06ded78511258241ba9a7dca09d6a5c4626e 100644 (file)
@@ -1,3 +1,7 @@
+2005-04-08 Hasso Tepper <hasso at quagga.net>
+
+       * bgpd.texi: Document new "bgp bestpath as-path confed" command.
+
 2005-04-05 Paul Jakma <paul@dishone.st>
 
        * Makefile.am: Get rid of built_sources. It causes them to be added
index 0e0a2708a0f2327242345d3e02f17f062bcb4bd4..43d97028c0fc8202b51a1ecdd6d83116ba3bbe9d 100644 (file)
@@ -116,6 +116,12 @@ This command set distance value to
 @item 6. MED check.
 @end table
 
+@deffn {BGP} {bgp bestpath as-path confed} {}
+This command specifies that the length of confederation path sets and
+sequences should should be taken into account during the BGP best path
+decision process.
+@end deffn
+
 @node BGP network
 @section BGP network