]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Add CLI knob to enable graceful restart for BGP notifications
authorDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 4 May 2022 18:52:01 +0000 (21:52 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 5 May 2022 09:35:03 +0000 (12:35 +0300)
N-bit flag should be exchanged in BGP OPEN messages, not only when the
bgpd is restarted/started.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_open.c
bgpd/bgp_vty.c
bgpd/bgpd.h
doc/user/bgp.rst

index bfa1506afee7c0498997494c19155f586ec737d5..fa3fa3fcee35655f531a24c337414cd6c69bec41 100644 (file)
@@ -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);
        }
 
index 0cbb341ff3910afe7e1ed7c1024ce9c3fdc0fde8..1002175619cfb2079e898c298c5509a64e3e508f 100644 (file)
@@ -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);
index 59f05daf181a495234768270cef59ab09e8da468..5d000f107ce5832d9541575a170533b96d5e859d 100644 (file)
@@ -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.
index 6f99b41140412efa5939723881dcdd263d71b9f9..68d6d8714b44d25ceb1ffa9e3a0082865afe700f 100644 (file)
@@ -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