Skip to content

Commit

Permalink
Merge pull request #15585 from opensourcerouting/feature/enable_dynam…
Browse files Browse the repository at this point in the history
…ic_capability_for_datacenter_profile

bgpd: Enable BGP dynamic capability by default for datacenter profile
  • Loading branch information
riw777 authored Mar 26, 2024
2 parents 67aaa4b + e2ac728 commit 73e0b7a
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bgpd/bgp_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ uint16_t bgp_open_capability(struct stream *s, struct peer *peer,
}

/* Dynamic capability. */
if (CHECK_FLAG(peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY)) {
if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) {
SET_FLAG(peer->cap, PEER_CAP_DYNAMIC_ADV);
stream_putc(s, BGP_OPEN_OPT_CAP);
ext_opt_params
Expand Down
49 changes: 46 additions & 3 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ FRR_CFG_DEFAULT_BOOL(BGP_SOFT_VERSION_CAPABILITY,
{ .val_bool = true, .match_profile = "datacenter", },
{ .val_bool = false },
);
FRR_CFG_DEFAULT_BOOL(BGP_DYNAMIC_CAPABILITY,
{ .val_bool = true, .match_profile = "datacenter", },
{ .val_bool = false },
);
FRR_CFG_DEFAULT_BOOL(BGP_ENFORCE_FIRST_AS,
{ .val_bool = false, .match_version = "< 9.1", },
{ .val_bool = true },
Expand Down Expand Up @@ -623,6 +627,9 @@ int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name,
if (DFLT_BGP_SOFT_VERSION_CAPABILITY)
SET_FLAG((*bgp)->flags,
BGP_FLAG_SOFT_VERSION_CAPABILITY);
if (DFLT_BGP_DYNAMIC_CAPABILITY)
SET_FLAG((*bgp)->flags,
BGP_FLAG_DYNAMIC_CAPABILITY);
if (DFLT_BGP_ENFORCE_FIRST_AS)
SET_FLAG((*bgp)->flags, BGP_FLAG_ENFORCE_FIRST_AS);

Expand Down Expand Up @@ -4298,6 +4305,24 @@ DEFPY (bgp_default_software_version_capability,
return CMD_SUCCESS;
}

DEFPY (bgp_default_dynamic_capability,
bgp_default_dynamic_capability_cmd,
"[no] bgp default dynamic-capability",
NO_STR
BGP_STR
"Configure BGP defaults\n"
"Advertise dynamic capability for all neighbors\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);

if (no)
UNSET_FLAG(bgp->flags, BGP_FLAG_DYNAMIC_CAPABILITY);
else
SET_FLAG(bgp->flags, BGP_FLAG_DYNAMIC_CAPABILITY);

return CMD_SUCCESS;
}

/* "bgp network import-check" configuration. */
DEFUN (bgp_network_import_check,
bgp_network_import_check_cmd,
Expand Down Expand Up @@ -18383,9 +18408,15 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
vty_out(vty, " neighbor %s timers delayopen %u\n", addr,
peer->bgp->default_delayopen);

/* capability dynamic */
if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY))
vty_out(vty, " neighbor %s capability dynamic\n", addr);
/* capability software-version */
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DYNAMIC_CAPABILITY)) {
if (!peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY))
vty_out(vty, " no neighbor %s capability dynamic\n",
addr);
} else {
if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY))
vty_out(vty, " neighbor %s capability dynamic\n", addr);
}

/* capability extended-nexthop */
if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) {
Expand Down Expand Up @@ -19076,6 +19107,15 @@ int bgp_config_write(struct vty *vty)
? ""
: "no ");

if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DYNAMIC_CAPABILITY) !=
SAVE_BGP_DYNAMIC_CAPABILITY)
vty_out(vty,
" %sbgp default dynamic-capability\n",
CHECK_FLAG(bgp->flags,
BGP_FLAG_DYNAMIC_CAPABILITY)
? ""
: "no ");

/* BGP default subgroup-pkt-queue-max. */
if (bgp->default_subgroup_pkt_queue_max
!= BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX)
Expand Down Expand Up @@ -20124,6 +20164,9 @@ void bgp_vty_init(void)
/* bgp default software-version-capability */
install_element(BGP_NODE, &bgp_default_software_version_capability_cmd);

/* bgp default dynamic-capability */
install_element(BGP_NODE, &bgp_default_dynamic_capability_cmd);

/* "bgp default subgroup-pkt-queue-max" commands. */
install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);
Expand Down
10 changes: 10 additions & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,9 @@ struct peer *peer_new(struct bgp *bgp)
if (CHECK_FLAG(bgp->flags, BGP_FLAG_SOFT_VERSION_CAPABILITY))
SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_SOFT_VERSION);

if (CHECK_FLAG(bgp->flags, BGP_FLAG_DYNAMIC_CAPABILITY))
SET_FLAG(peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY);

SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_FQDN);
SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_FQDN);

Expand Down Expand Up @@ -2919,6 +2922,13 @@ static void peer_group2peer_config_copy(struct peer_group *group,
SET_FLAG(peer->flags,
PEER_FLAG_CAPABILITY_SOFT_VERSION);

/* capability dynamic apply */
if (!CHECK_FLAG(peer->flags_override,
PEER_FLAG_DYNAMIC_CAPABILITY))
if (CHECK_FLAG(conf->flags, PEER_FLAG_DYNAMIC_CAPABILITY))
SET_FLAG(peer->flags,
PEER_FLAG_DYNAMIC_CAPABILITY);

/* password apply */
if (!CHECK_FLAG(peer->flags_override, PEER_FLAG_PASSWORD))
PEER_STR_ATTR_INHERIT(peer, group, password,
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ struct bgp {
#define BGP_FLAG_LU_IPV6_EXPLICIT_NULL (1ULL << 34)
#define BGP_FLAG_SOFT_VERSION_CAPABILITY (1ULL << 35)
#define BGP_FLAG_ENFORCE_FIRST_AS (1ULL << 36)
#define BGP_FLAG_DYNAMIC_CAPABILITY (1ULL << 37)

/* BGP default address-families.
* New peers inherit enabled afi/safis from bgp instance.
Expand Down
13 changes: 10 additions & 3 deletions doc/user/bgp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ Configuring Peers
This includes changing graceful-restart (LLGR also) timers,
enabling/disabling add-path, and other supported capabilities.

.. clicmd:: neighbor PEER capability fqdn
.. clicmd:: neighbor PEER capability fqdn

Allow BGP to negotiate the FQDN Capability with its peers.

Expand All @@ -1825,7 +1825,7 @@ Configuring Peers

This capability is activated by default. The ``no neighbor PEER capability
fqdn`` avoid negotiation of that capability. This is useful for peers who
are not supporting this capability or supporting BGP Capabilities
are not supporting this capability or supporting BGP Capabilities
Negotiation RFC 2842.

.. clicmd:: neighbor <A.B.C.D|X:X::X:X|WORD> accept-own
Expand Down Expand Up @@ -1949,6 +1949,13 @@ Configuring Peers
outputs. It's easier to troubleshoot if you have a number of BGP peers
and a number of routes to check.

.. clicmd:: bgp default dynamic-capability

This command enables dynamic capability advertisement by default
for all the neighbors.

For ``datacenter`` profile, this is enabled by default.

.. clicmd:: bgp default software-version-capability

This command enables software version capability advertisement by default
Expand Down Expand Up @@ -3219,7 +3226,7 @@ that the 2001:db8:2:2:: prefix is valid.

.. code-block:: frr
r1# show bgp nexthop detail
r1# show bgp nexthop detail
Current BGP nexthop cache:
2001:db8:2:2:: valid [IGP metric 0], #paths 4
gate 2001:db8:12::2, if eth0
Expand Down

0 comments on commit 73e0b7a

Please sign in to comment.