Skip to content

Commit

Permalink
bgpd: Allow dynamically disable graceful-restart/long-lived graceful-…
Browse files Browse the repository at this point in the history
…restart

If we enter `bgp graceful-restart-disable`, make sure we disable the capabilities.

Signed-off-by: Donatas Abraitis <[email protected]>
(cherry picked from commit 7875736)
  • Loading branch information
ton31337 committed Mar 12, 2024
1 parent 66f0565 commit 6d31b86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 0 additions & 7 deletions bgpd/bgp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
}

Expand Down

0 comments on commit 6d31b86

Please sign in to comment.