From f2ca5c5b952e9795c16d3e630cb61696a96d910c Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Wed, 4 May 2022 21:52:01 +0300 Subject: [PATCH] bgpd: Add CLI knob to enable graceful restart for BGP notifications N-bit flag should be exchanged in BGP OPEN messages, not only when the bgpd is restarted/started. Signed-off-by: Donatas Abraitis --- bgpd/bgp_open.c | 11 ++++++++--- bgpd/bgp_vty.c | 33 +++++++++++++++++++++++++++++++++ bgpd/bgpd.h | 2 ++ doc/user/bgp.rst | 9 +++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index bfa1506afe..fa3fa3fcee 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -1435,12 +1435,17 @@ static void bgp_peer_send_gr_capability(struct stream *s, struct peer *peer, restart_time = peer->bgp->restart_time; if (peer->bgp->t_startup) { SET_FLAG(restart_time, GRACEFUL_RESTART_R_BIT); - SET_FLAG(restart_time, GRACEFUL_RESTART_N_BIT); SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_ADV); - SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_ADV); + if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) + zlog_debug("[BGP_GR] Sending R-Bit for peer: %s", + peer->host); + } + if (CHECK_FLAG(peer->bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION)) { + SET_FLAG(restart_time, GRACEFUL_RESTART_N_BIT); + SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_ADV); if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) - zlog_debug("[BGP_GR] Sending R-Bit/N-Bit for peer: %s", + zlog_debug("[BGP_GR] Sending N-Bit for peer: %s", peer->host); } diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 0cbb341ff3..1002175619 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -123,6 +123,10 @@ FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, { .val_bool = false, .match_version = "< 7.6", }, { .val_bool = true }, ); +FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION, + { .val_bool = false, .match_version = "< 8.3", }, + { .val_bool = true }, +); DEFINE_HOOK(bgp_inst_config_write, (struct bgp *bgp, struct vty *vty), @@ -569,6 +573,8 @@ int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); if (DFLT_BGP_SUPPRESS_DUPLICATES) SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); + if (DFLT_BGP_GRACEFUL_NOTIFICATION) + SET_FLAG((*bgp)->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); ret = BGP_SUCCESS; } @@ -2868,6 +2874,24 @@ DEFUN (no_bgp_graceful_restart_preserve_fw, return CMD_SUCCESS; } +DEFPY (bgp_graceful_restart_notification, + bgp_graceful_restart_notification_cmd, + "[no$no] bgp graceful-restart notification", + NO_STR + BGP_STR + "Graceful restart capability parameters\n" + "Indicate Graceful Restart support for BGP NOTIFICATION messages\n") +{ + VTY_DECLVAR_CONTEXT(bgp, bgp); + + if (no) + UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); + else + SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); + + return CMD_SUCCESS; +} + DEFUN (bgp_graceful_restart_disable, bgp_graceful_restart_disable_cmd, "bgp graceful-restart-disable", @@ -17258,6 +17282,14 @@ int bgp_config_write(struct vty *vty) vty_out(vty, " bgp graceful-restart restart-time %u\n", bgp->restart_time); + if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION) != + SAVE_BGP_GRACEFUL_NOTIFICATION) + vty_out(vty, " %sbgp graceful-restart notification\n", + CHECK_FLAG(bgp->flags, + BGP_FLAG_GRACEFUL_NOTIFICATION) + ? "" + : "no "); + if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) vty_out(vty, " bgp graceful-restart select-defer-time %u\n", @@ -17890,6 +17922,7 @@ void bgp_vty_init(void) &no_bgp_graceful_restart_select_defer_time_cmd); install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); + install_element(BGP_NODE, &bgp_graceful_restart_notification_cmd); install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 59f05daf18..5d000f107c 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -488,6 +488,8 @@ struct bgp { #define BGP_FLAG_SUPPRESS_FIB_PENDING (1 << 26) #define BGP_FLAG_SUPPRESS_DUPLICATES (1 << 27) #define BGP_FLAG_PEERTYPE_MULTIPATH_RELAX (1 << 29) +/* Indicate Graceful Restart support for BGP NOTIFICATION messages */ +#define BGP_FLAG_GRACEFUL_NOTIFICATION (1 << 30) /* 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 6f99b41140..68d6d8714b 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -947,6 +947,15 @@ However, it MUST defer route selection for an address family until it either. expires. The stale path timer is started when the router receives a Route-Refresh BoRR message. +.. clicmd:: bgp graceful-restart notification + + Indicate Graceful Restart support for BGP NOTIFICATION messages. + + After changing this parameter, you have to reset the peers in order to advertise + N-bit in Graceful Restart capability. + + Enabled by default. + .. _bgp-per-peer-graceful-restart: BGP Per Peer Graceful Restart -- 2.39.5