* 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.
This commit is contained in:
hasso 2005-04-08 15:40:36 +00:00
parent 4a8164e5b3
commit 6811845b67
9 changed files with 95 additions and 11 deletions

View 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> 2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* bgp_zebra.c: (bgp_interface_delete) After deleting, set ifp->ifindex * bgp_zebra.c: (bgp_interface_delete) After deleting, set ifp->ifindex

View File

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

View File

@ -42,6 +42,9 @@ struct aspath
/* AS count. */ /* AS count. */
int count; int count;
/* Confederation set/segment AS count. */
int confed_count;
/* Rawdata. */ /* Rawdata. */
caddr_t data; caddr_t data;

View File

@ -213,10 +213,26 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist)
/* 4. AS path length check. */ /* 4. AS path length check. */
if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
{ {
if (new->attr->aspath->count < exist->attr->aspath->count) if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
return 1; {
if (new->attr->aspath->count > exist->attr->aspath->count) if ((new->attr->aspath->count +
return 0; 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. */ /* 5. Origin check. */

View File

@ -971,6 +971,38 @@ DEFUN (no_bgp_bestpath_aspath_ignore,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
/* "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;
}
/* "bgp log-neighbor-changes" configuration. */ /* "bgp log-neighbor-changes" configuration. */
DEFUN (bgp_log_neighbor_changes, DEFUN (bgp_log_neighbor_changes,
bgp_log_neighbor_changes_cmd, 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, &bgp_bestpath_aspath_ignore_cmd);
install_element (BGP_NODE, &no_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 */ /* "bgp log-neighbor-changes" commands */
install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);

View File

@ -4751,6 +4751,8 @@ bgp_config_write (struct vty *vty)
/* BGP bestpath method. */ /* BGP bestpath method. */
if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
vty_out (vty, " bgp bestpath as-path ignore%s", VTY_NEWLINE); 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)) if (bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID))
vty_out (vty, " bgp bestpath compare-routerid%s", VTY_NEWLINE); vty_out (vty, " bgp bestpath compare-routerid%s", VTY_NEWLINE);
if (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) if (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)

View File

@ -101,6 +101,7 @@ struct bgp
#define BGP_FLAG_NO_FAST_EXT_FAILOVER (1 << 10) #define BGP_FLAG_NO_FAST_EXT_FAILOVER (1 << 10)
#define BGP_FLAG_LOG_NEIGHBOR_CHANGES (1 << 11) #define BGP_FLAG_LOG_NEIGHBOR_CHANGES (1 << 11)
#define BGP_FLAG_GRACEFUL_RESTART (1 << 12) #define BGP_FLAG_GRACEFUL_RESTART (1 << 12)
#define BGP_FLAG_ASPATH_CONFED (1 << 13)
/* BGP Per AF flags */ /* BGP Per AF flags */
u_int16_t af_flags[AFI_MAX][SAFI_MAX]; u_int16_t af_flags[AFI_MAX][SAFI_MAX];

View 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> 2005-04-05 Paul Jakma <paul@dishone.st>
* Makefile.am: Get rid of built_sources. It causes them to be added * Makefile.am: Get rid of built_sources. It causes them to be added

View File

@ -116,6 +116,12 @@ This command set distance value to
@item 6. MED check. @item 6. MED check.
@end table @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 @node BGP network
@section BGP network @section BGP network