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 <sadhub@vmware.com>
Signed-off-by: Soman K S <somanks@vmware.com>
This commit is contained in:
bisdhdh 2019-10-24 15:51:18 +05:30
parent 34aa744869
commit d6e3c15b62
4 changed files with 58 additions and 17 deletions

View File

@ -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);
&& 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);
if ((s = bgp_update_packet_eor(
peer, afi,
safi))) {
bgp_packet_add(peer, s);
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,

View File

@ -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 *);

View File

@ -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);

View File

@ -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;