From 3e99dcc62667bdf5d72c9ba06af894b17679532d Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 5 Feb 2024 08:22:46 +0200 Subject: [PATCH 1/3] bgpd: Send FQDN capability via dynamic capability if enabled Since we have a knob to disable sending FQDN capability, it MUST be checked before sending it using dynamic capabilities. Signed-off-by: Donatas Abraitis --- bgpd/bgp_packet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index f94b64d0bda4..9d484d901ac1 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1534,7 +1534,8 @@ void bgp_capability_send(struct peer *peer, afi_t afi, safi_t safi, iana_safi2str(pkt_safi)); break; case CAPABILITY_CODE_FQDN: - if (hostname) { + if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_FQDN) && + hostname) { SET_FLAG(peer->cap, PEER_CAP_HOSTNAME_ADV); stream_putc(s, action); stream_putc(s, CAPABILITY_CODE_FQDN); From 04e2401d2019852ccc08f91cfb6c4a5eaf5a0575 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 5 Feb 2024 10:40:24 +0200 Subject: [PATCH 2/3] bgpd: Do not reset the session if turning on/off FQDN capability Allow BGP dynamic capabilities handle this gracefully. Signed-off-by: Donatas Abraitis --- bgpd/bgpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 58514566ef8f..b8517199af19 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -4574,7 +4574,7 @@ static const struct peer_flag_action peer_flag_action_list[] = { {PEER_FLAG_AIGP, 0, peer_change_none}, {PEER_FLAG_GRACEFUL_SHUTDOWN, 0, peer_change_none}, {PEER_FLAG_CAPABILITY_SOFT_VERSION, 0, peer_change_none}, - {PEER_FLAG_CAPABILITY_FQDN, 0, peer_change_reset}, + {PEER_FLAG_CAPABILITY_FQDN, 0, peer_change_none}, {0, 0, 0}}; static const struct peer_flag_action peer_af_flag_action_list[] = { From c8acc6709cff0b376a2a477aabe99849661ef336 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 5 Feb 2024 10:55:22 +0200 Subject: [PATCH 3/3] bgpd: Send dynamic capability when on/off FQDN capability Signed-off-by: Donatas Abraitis --- bgpd/bgp_vty.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 09f9667a9a09..33884d045226 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -5746,17 +5746,24 @@ DEFPY (neighbor_capability_fqdn, "Advertise fqdn capability to the peer\n") { struct peer *peer; + int ret; peer = peer_and_group_lookup_vty(vty, neighbor); if (!peer) return CMD_WARNING_CONFIG_FAILED; if (no) - return peer_flag_unset_vty(vty, neighbor, + ret = peer_flag_unset_vty(vty, neighbor, PEER_FLAG_CAPABILITY_FQDN); else - return peer_flag_set_vty(vty, neighbor, + ret = peer_flag_set_vty(vty, neighbor, PEER_FLAG_CAPABILITY_FQDN); + + bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, CAPABILITY_CODE_FQDN, + no ? CAPABILITY_ACTION_UNSET + : CAPABILITY_ACTION_SET); + + return ret; } /* neighbor capability extended next hop encoding */