diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 09f16bbce6ec..d6259d7cbb62 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -1896,7 +1896,8 @@ uint16_t bgp_open_capability(struct stream *s, struct peer *peer, } /* Hostname capability */ - if (cmd_hostname_get()) { + if (CHECK_FLAG(peer->bgp->flags, BGP_FLAG_HOSTNAME_CAPABILITY) && + cmd_hostname_get()) { SET_FLAG(peer->cap, PEER_CAP_HOSTNAME_ADV); stream_putc(s, BGP_OPEN_OPT_CAP); rcapp = stream_get_endp(s); /* Ptr to length placeholder */ diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 2a917155362b..1a8ebbe42a44 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -126,6 +126,7 @@ FRR_CFG_DEFAULT_BOOL(BGP_SOFT_VERSION_CAPABILITY, { .val_bool = true, .match_profile = "datacenter", }, { .val_bool = false }, ); +FRR_CFG_DEFAULT_BOOL(BGP_HOSTNAME_CAPABILITY, { .val_bool = true }, ); FRR_CFG_DEFAULT_BOOL(BGP_ENFORCE_FIRST_AS, { .val_bool = false, .match_version = "< 9.1", }, { .val_bool = true }, @@ -623,6 +624,8 @@ 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_HOSTNAME_CAPABILITY) + SET_FLAG((*bgp)->flags, BGP_FLAG_HOSTNAME_CAPABILITY); if (DFLT_BGP_ENFORCE_FIRST_AS) SET_FLAG((*bgp)->flags, BGP_FLAG_ENFORCE_FIRST_AS); @@ -4287,6 +4290,24 @@ DEFPY (bgp_default_software_version_capability, return CMD_SUCCESS; } +DEFPY (bgp_default_hostname_capability, + bgp_default_hostname_capability_cmd, + "[no] bgp default hostname-capability", + NO_STR + BGP_STR + "Configure BGP defaults\n" + "Advertise hostname capability for all neighbors\n") +{ + VTY_DECLVAR_CONTEXT(bgp, bgp); + + if (no) + UNSET_FLAG(bgp->flags, BGP_FLAG_HOSTNAME_CAPABILITY); + else + SET_FLAG(bgp->flags, BGP_FLAG_HOSTNAME_CAPABILITY); + + return CMD_SUCCESS; +} + /* "bgp network import-check" configuration. */ DEFUN (bgp_network_import_check, bgp_network_import_check_cmd, @@ -18829,6 +18850,14 @@ int bgp_config_write(struct vty *vty) ? "" : "no "); + if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_HOSTNAME_CAPABILITY) != + SAVE_BGP_HOSTNAME_CAPABILITY) + vty_out(vty, " %sbgp default hostname-capability\n", + CHECK_FLAG(bgp->flags, + BGP_FLAG_HOSTNAME_CAPABILITY) + ? "" + : "no "); + /* BGP default subgroup-pkt-queue-max. */ if (bgp->default_subgroup_pkt_queue_max != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) @@ -19877,6 +19906,9 @@ void bgp_vty_init(void) /* bgp default software-version-capability */ install_element(BGP_NODE, &bgp_default_software_version_capability_cmd); + /* bgp default hostname-capability */ + install_element(BGP_NODE, &bgp_default_hostname_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); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 4c12872ee9e0..991532268bdf 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -519,6 +519,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_HOSTNAME_CAPABILITY (1ULL << 36) /* BGP default address-families. * New peers inherit enabled afi/safis from bgp instance. diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index 050141203bb5..ce565981f645 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -1913,6 +1913,11 @@ 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 hostname-capability + + This command enables hostname capability advertisement by default + for all the neighbors. This is enabled by default. + .. clicmd:: bgp default software-version-capability This command enables software version capability advertisement by default