]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Added hidden CLI command to disable sending of End-of-Rib.
authorbisdhdh <biswajit.sadhu@gmail.com>
Thu, 24 Oct 2019 10:21:18 +0000 (15:51 +0530)
committerbisdhdh <biswajit.sadhu@gmail.com>
Thu, 23 Jan 2020 04:04:25 +0000 (09:34 +0530)
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>
bgpd/bgp_packet.c
bgpd/bgp_packet.h
bgpd/bgp_vty.c
bgpd/bgpd.h

index 49b6f2f27916986958a0c5b0122715457e2fa67f..88b95496e6714b3f029fb776ea51e695a76d869c 100644 (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);
-
-                                               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,
index 49e401790f18c44da490337aa19e385a1560a15e..1c2bafcb742d5af84d10047d2ec4d50ddbf0105a 100644 (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 *);
index bca28150e4feae97d0f2d7c708602102674245dc..71a41cd688f094d1193f55f484fe24628655e53b 100644 (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);
index a8ba6ad2581953c99f98add9bb68f5ea40854d8a..9b4f8d3eb486190b7ac7be1652318d6e37ea4e33 100644 (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;