mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 18:37:06 +00:00
Add a no-as-set option to multipath-relax
This commit is contained in:
parent
f992e2a98c
commit
16fc1eec45
107
bgpd/bgp_mpath.c
107
bgpd/bgp_mpath.c
@ -660,71 +660,76 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best,
|
|||||||
|
|
||||||
bgp_attr_dup (&attr, new_best->attr);
|
bgp_attr_dup (&attr, new_best->attr);
|
||||||
|
|
||||||
/* aggregate attribute from multipath constituents */
|
if (new_best->peer &&
|
||||||
aspath = aspath_dup (attr.aspath);
|
!bgp_flag_check (new_best->peer->bgp, BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET))
|
||||||
origin = attr.origin;
|
|
||||||
community = attr.community ? community_dup (attr.community) : NULL;
|
|
||||||
ae = attr.extra;
|
|
||||||
ecomm = (ae && ae->ecommunity) ? ecommunity_dup (ae->ecommunity) : NULL;
|
|
||||||
|
|
||||||
for (mpinfo = bgp_info_mpath_first (new_best); mpinfo;
|
|
||||||
mpinfo = bgp_info_mpath_next (mpinfo))
|
|
||||||
{
|
{
|
||||||
asmerge = aspath_aggregate (aspath, mpinfo->attr->aspath);
|
|
||||||
aspath_free (aspath);
|
|
||||||
aspath = asmerge;
|
|
||||||
|
|
||||||
if (origin < mpinfo->attr->origin)
|
/* aggregate attribute from multipath constituents */
|
||||||
origin = mpinfo->attr->origin;
|
aspath = aspath_dup (attr.aspath);
|
||||||
|
origin = attr.origin;
|
||||||
|
community = attr.community ? community_dup (attr.community) : NULL;
|
||||||
|
ae = attr.extra;
|
||||||
|
ecomm = (ae && ae->ecommunity) ? ecommunity_dup (ae->ecommunity) : NULL;
|
||||||
|
|
||||||
if (mpinfo->attr->community)
|
for (mpinfo = bgp_info_mpath_first (new_best); mpinfo;
|
||||||
|
mpinfo = bgp_info_mpath_next (mpinfo))
|
||||||
{
|
{
|
||||||
if (community)
|
asmerge = aspath_aggregate (aspath, mpinfo->attr->aspath);
|
||||||
|
aspath_free (aspath);
|
||||||
|
aspath = asmerge;
|
||||||
|
|
||||||
|
if (origin < mpinfo->attr->origin)
|
||||||
|
origin = mpinfo->attr->origin;
|
||||||
|
|
||||||
|
if (mpinfo->attr->community)
|
||||||
{
|
{
|
||||||
commerge = community_merge (community, mpinfo->attr->community);
|
if (community)
|
||||||
community = community_uniq_sort (commerge);
|
{
|
||||||
community_free (commerge);
|
commerge = community_merge (community, mpinfo->attr->community);
|
||||||
|
community = community_uniq_sort (commerge);
|
||||||
|
community_free (commerge);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
community = community_dup (mpinfo->attr->community);
|
||||||
|
}
|
||||||
|
|
||||||
|
ae = mpinfo->attr->extra;
|
||||||
|
if (ae && ae->ecommunity)
|
||||||
|
{
|
||||||
|
if (ecomm)
|
||||||
|
{
|
||||||
|
ecommerge = ecommunity_merge (ecomm, ae->ecommunity);
|
||||||
|
ecomm = ecommunity_uniq_sort (ecommerge);
|
||||||
|
ecommunity_free (&ecommerge);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ecomm = ecommunity_dup (ae->ecommunity);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
community = community_dup (mpinfo->attr->community);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ae = mpinfo->attr->extra;
|
attr.aspath = aspath;
|
||||||
if (ae && ae->ecommunity)
|
attr.origin = origin;
|
||||||
|
if (community)
|
||||||
{
|
{
|
||||||
if (ecomm)
|
attr.community = community;
|
||||||
{
|
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
|
||||||
ecommerge = ecommunity_merge (ecomm, ae->ecommunity);
|
}
|
||||||
ecomm = ecommunity_uniq_sort (ecommerge);
|
if (ecomm)
|
||||||
ecommunity_free (&ecommerge);
|
{
|
||||||
}
|
ae = bgp_attr_extra_get (&attr);
|
||||||
else
|
ae->ecommunity = ecomm;
|
||||||
ecomm = ecommunity_dup (ae->ecommunity);
|
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
attr.aspath = aspath;
|
/* Zap multipath attr nexthop so we set nexthop to self */
|
||||||
attr.origin = origin;
|
attr.nexthop.s_addr = 0;
|
||||||
if (community)
|
|
||||||
{
|
|
||||||
attr.community = community;
|
|
||||||
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
|
|
||||||
}
|
|
||||||
if (ecomm)
|
|
||||||
{
|
|
||||||
ae = bgp_attr_extra_get (&attr);
|
|
||||||
ae->ecommunity = ecomm;
|
|
||||||
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Zap multipath attr nexthop so we set nexthop to self */
|
|
||||||
attr.nexthop.s_addr = 0;
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (attr.extra)
|
if (attr.extra)
|
||||||
memset (&attr.extra->mp_nexthop_global, 0, sizeof (struct in6_addr));
|
memset (&attr.extra->mp_nexthop_global, 0, sizeof (struct in6_addr));
|
||||||
#endif /* HAVE_IPV6 */
|
#endif /* HAVE_IPV6 */
|
||||||
|
|
||||||
/* TODO: should we set ATOMIC_AGGREGATE and AGGREGATOR? */
|
/* TODO: should we set ATOMIC_AGGREGATE and AGGREGATOR? */
|
||||||
|
}
|
||||||
|
|
||||||
new_attr = bgp_attr_intern (&attr);
|
new_attr = bgp_attr_intern (&attr);
|
||||||
bgp_attr_extra_free (&attr);
|
bgp_attr_extra_free (&attr);
|
||||||
|
@ -1588,6 +1588,7 @@ DEFUN (bgp_bestpath_aspath_multipath_relax,
|
|||||||
|
|
||||||
bgp = vty->index;
|
bgp = vty->index;
|
||||||
bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
|
bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
|
||||||
|
bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1604,6 +1605,43 @@ DEFUN (no_bgp_bestpath_aspath_multipath_relax,
|
|||||||
|
|
||||||
bgp = vty->index;
|
bgp = vty->index;
|
||||||
bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
|
bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
|
||||||
|
bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* "bgp bestpath as-path multipath-relax no-as-set" configuration. */
|
||||||
|
DEFUN (bgp_bestpath_aspath_multipath_relax_no_as_set,
|
||||||
|
bgp_bestpath_aspath_multipath_relax_no_as_set_cmd,
|
||||||
|
"bgp bestpath as-path multipath-relax no-as-set",
|
||||||
|
"BGP specific commands\n"
|
||||||
|
"Change the default bestpath selection\n"
|
||||||
|
"AS-path attribute\n"
|
||||||
|
"Allow load sharing across routes that have different AS paths (but same length)\n"
|
||||||
|
"Do not generate an AS_SET\n")
|
||||||
|
{
|
||||||
|
struct bgp *bgp;
|
||||||
|
|
||||||
|
bgp = vty->index;
|
||||||
|
bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
|
||||||
|
bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN (no_bgp_bestpath_aspath_multipath_relax_no_as_set,
|
||||||
|
no_bgp_bestpath_aspath_multipath_relax_no_as_set_cmd,
|
||||||
|
"no bgp bestpath as-path multipath-relax no-as-set",
|
||||||
|
NO_STR
|
||||||
|
"BGP specific commands\n"
|
||||||
|
"Change the default bestpath selection\n"
|
||||||
|
"AS-path attribute\n"
|
||||||
|
"Allow load sharing across routes that have different AS paths (but same length)\n"
|
||||||
|
"Do not generate an AS_SET\n")
|
||||||
|
{
|
||||||
|
struct bgp *bgp;
|
||||||
|
|
||||||
|
bgp = vty->index;
|
||||||
|
bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
|
||||||
|
bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11419,6 +11457,10 @@ bgp_vty_init (void)
|
|||||||
install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
|
install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
|
||||||
install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
|
install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
|
||||||
|
|
||||||
|
/* "bgp bestpath as-path multipath-relax no-as-set" commands */
|
||||||
|
install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_no_as_set_cmd);
|
||||||
|
install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_no_as_set_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);
|
||||||
|
@ -6366,9 +6366,15 @@ bgp_config_write (struct vty *vty)
|
|||||||
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))
|
if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
|
||||||
vty_out (vty, " bgp bestpath as-path confed%s", VTY_NEWLINE);
|
vty_out (vty, " bgp bestpath as-path confed%s", VTY_NEWLINE);
|
||||||
|
|
||||||
if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
|
if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
|
||||||
vty_out (vty, " bgp bestpath as-path multipath-relax%s", VTY_NEWLINE);
|
if (bgp_flag_check (bgp, BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET)) {
|
||||||
|
vty_out (vty, " bgp bestpath as-path multipath-relax no-as-set%s", VTY_NEWLINE);
|
||||||
|
} else {
|
||||||
|
vty_out (vty, " bgp bestpath as-path multipath-relax%s", VTY_NEWLINE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bgp_flag_check (bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
|
if (bgp_flag_check (bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
|
||||||
vty_out (vty, " bgp route-reflector allow-outbound-policy%s",
|
vty_out (vty, " bgp route-reflector allow-outbound-policy%s",
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
|
@ -238,6 +238,7 @@ struct bgp
|
|||||||
#define BGP_FLAG_ASPATH_MULTIPATH_RELAX (1 << 14)
|
#define BGP_FLAG_ASPATH_MULTIPATH_RELAX (1 << 14)
|
||||||
#define BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY (1 << 15)
|
#define BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY (1 << 15)
|
||||||
#define BGP_FLAG_DISABLE_NH_CONNECTED_CHK (1 << 16)
|
#define BGP_FLAG_DISABLE_NH_CONNECTED_CHK (1 << 16)
|
||||||
|
#define BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET (1 << 17)
|
||||||
|
|
||||||
/* 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];
|
||||||
|
Loading…
Reference in New Issue
Block a user