From: bisdhdh Date: Thu, 24 Oct 2019 10:21:18 +0000 (+0530) Subject: bgpd: Added hidden CLI command to disable sending of End-of-Rib. X-Git-Tag: frr-7.5.1~848^2~10 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=d6e3c15b6294acc52ba8078000ed12dd13f25034;p=mirror_frr.git bgpd: Added hidden CLI command to disable sending of End-of-Rib. BGP disable EOR sending is a useful command for testing various scenarios of BGP graceful restart. * Added the hidden CLI command : bgp graceful-restart disable-eor * The CLI will not be displayed in "show running-config" and will not be stored in configuration file. * When enabled, EOR will not be sent to peer Signed-off-by: Biswajit Sadhu Signed-off-by: Soman K S --- diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 49b6f2f27..88b95496e 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -439,29 +439,32 @@ int bgp_generate_updgrp_packets(struct thread *thread) */ if (!next_pkt || !next_pkt->buffer) { if (CHECK_FLAG(peer->cap, - PEER_CAP_RESTART_RCV)) { + PEER_CAP_RESTART_RCV)) { if (!(PAF_SUBGRP(paf))->t_coalesce - && peer->afc_nego[afi][safi] - && peer->synctime - && !CHECK_FLAG( - peer->af_sflags[afi] - [safi], - PEER_STATUS_EOR_SEND)) { - SET_FLAG(peer->af_sflags[afi] - [safi], - PEER_STATUS_EOR_SEND); - - if ((s = bgp_update_packet_eor( - peer, afi, - safi))) { - bgp_packet_add(peer, s); + && peer->afc_nego[afi][safi] + && peer->synctime + && !CHECK_FLAG( + peer->af_sflags[afi][safi], + PEER_STATUS_EOR_SEND)) { + /* If EOR is disabled, + * the message is not sent + */ + if (!bgp_flag_check(peer->bgp, + BGP_FLAG_GR_DISABLE_EOR + )) { + SET_FLAG( + peer->af_sflags + [afi][safi], + PEER_STATUS_EOR_SEND); + + BGP_UPDATE_EOR_PKT( + peer, afi, + safi, s); } } } continue; } - - /* Found a packet template to send, overwrite * packet with appropriate attributes from peer * and advance peer */ @@ -1675,7 +1678,8 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) */ if (gr_info->eor_required == gr_info->eor_received) { - if (bgp_debug_neighbor_events(peer)) + if (bgp_debug_neighbor_events( + peer)) zlog_debug("%s %d, %s %d", "EOR REQ", gr_info->eor_required, diff --git a/bgpd/bgp_packet.h b/bgpd/bgp_packet.h index 49e401790..1c2bafcb7 100644 --- a/bgpd/bgp_packet.h +++ b/bgpd/bgp_packet.h @@ -48,6 +48,14 @@ DECLARE_HOOK(bgp_packet_send, #define ORF_COMMON_PART_PERMIT 0x00 #define ORF_COMMON_PART_DENY 0x20 +#define BGP_UPDATE_EOR_PKT(_peer, _afi, _safi, _s) \ + do { \ + _s = bgp_update_packet_eor(_peer, _afi, _safi); \ + if (_s) { \ + bgp_packet_add(_peer, _s); \ + } \ + } while (0) + /* Packet send and receive function prototypes. */ extern void bgp_keepalive_send(struct peer *); extern void bgp_open_send(struct peer *); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index bca28150e..71a41cd68 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -2586,6 +2586,31 @@ DEFUN (no_bgp_neighbor_graceful_restart_disable, return bgp_vty_return(vty, ret); } +DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, + bgp_graceful_restart_disable_eor_cmd, + "bgp graceful-restart disable-eor", + "BGP specific commands\n" + "Graceful restart configuration parameters\n" + "Disable EOR Check\n") +{ + VTY_DECLVAR_CONTEXT(bgp, bgp); + bgp_flag_set(bgp, BGP_FLAG_GR_DISABLE_EOR); + return CMD_SUCCESS; +} + +DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, + no_bgp_graceful_restart_disable_eor_cmd, + "no bgp graceful-restart disable-eor", + NO_STR + "BGP specific commands\n" + "Graceful restart configuration parameters\n" + "Disable EOR Check\n") +{ + VTY_DECLVAR_CONTEXT(bgp, bgp); + bgp_flag_unset(bgp, BGP_FLAG_GR_DISABLE_EOR); + return CMD_SUCCESS; +} + /* "bgp graceful-shutdown" configuration */ DEFUN (bgp_graceful_shutdown, bgp_graceful_shutdown_cmd, @@ -15446,6 +15471,9 @@ void bgp_vty_init(void) 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_disable_eor_cmd); + install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); + /* "bgp graceful-shutdown" commands */ install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index a8ba6ad25..9b4f8d3eb 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -408,6 +408,7 @@ struct bgp { #define BGP_FLAG_GRACEFUL_SHUTDOWN (1 << 21) #define BGP_FLAG_DELETE_IN_PROGRESS (1 << 22) #define BGP_FLAG_SELECT_DEFER_DISABLE (1 << 23) +#define BGP_FLAG_GR_DISABLE_EOR (1 << 24) enum global_mode GLOBAL_GR_FSM[GLOBAL_MODE][EVENT_CMD]; enum global_mode global_gr_present_state;