From 6d31b866e7d7afecc5e0ba8143b1001579fbbb4a Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sun, 10 Mar 2024 18:25:30 +0200 Subject: [PATCH] bgpd: Allow dynamically disable graceful-restart/long-lived graceful-restart If we enter `bgp graceful-restart-disable`, make sure we disable the capabilities. Signed-off-by: Donatas Abraitis (cherry picked from commit 78757362f23f947527fe60327cf813b187fe0bdb) --- bgpd/bgp_packet.c | 7 ------- bgpd/bgp_vty.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 9f3a0ef375ba..7d6a6b55e8d8 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1291,10 +1291,6 @@ void bgp_capability_send(struct peer *peer, afi_t afi, safi_t safi, iana_safi2str(pkt_safi)); break; case CAPABILITY_CODE_RESTART: - if (!CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART) && - !CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART_HELPER)) - return; - stream_putc(s, action); stream_putc(s, CAPABILITY_CODE_RESTART); cap_len = stream_get_endp(s); @@ -1347,9 +1343,6 @@ void bgp_capability_send(struct peer *peer, afi_t afi, safi_t safi, action == CAPABILITY_ACTION_SET); break; case CAPABILITY_CODE_LLGR: - if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV)) - return; - stream_putc(s, action); stream_putc(s, CAPABILITY_CODE_LLGR); cap_len = stream_get_endp(s); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 31524e2221b9..b322e4ddde52 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -3260,6 +3260,8 @@ DEFUN (bgp_graceful_restart_disable, GR_DISABLE) { int ret = BGP_GR_FAILURE; + struct listnode *node, *nnode; + struct peer *peer; if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) zlog_debug( @@ -3278,6 +3280,15 @@ DEFUN (bgp_graceful_restart_disable, vty_out(vty, "Graceful restart configuration changed, reset all peers to take effect\n"); + for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { + bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, + CAPABILITY_CODE_RESTART, + CAPABILITY_ACTION_UNSET); + bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, + CAPABILITY_CODE_LLGR, + CAPABILITY_ACTION_UNSET); + } + return bgp_vty_return(vty, ret); }