]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Add global `bgp suppress-fib-pending` command
authorDonald Sharp <sharpd@nvidia.com>
Thu, 3 Dec 2020 20:48:59 +0000 (15:48 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 10 Dec 2020 17:59:14 +0000 (12:59 -0500)
On top of the recent `bgp suppress-fib-pending which
was at a BGP_NODE level, add this command at the CONFIG_NODE
level as well and allow the command to apply to all instances
of bgp running.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h

index 955e73fcf323dedad48b89e7ba5b4c2f0740b1ad..e840f8bceb510ca2e6137eb32e4820a3a05a99e5 100644 (file)
@@ -1514,6 +1514,18 @@ void cli_show_router_bgp_router_id(struct vty *vty, struct lyd_node *dnode,
        vty_out(vty, " bgp router-id %s\n", yang_dnode_get_string(dnode, NULL));
 }
 
+DEFPY (bgp_global_suppress_fib_pending,
+       bgp_global_suppress_fib_pending_cmd,
+       "[no] bgp suppress-fib-pending",
+       NO_STR
+       BGP_STR
+       "Advertise only routes that are programmed in kernel to peers globally\n")
+{
+       bm_wait_for_fib_set(!no);
+
+       return CMD_SUCCESS;
+}
+
 DEFPY (bgp_suppress_fib_pending,
        bgp_suppress_fib_pending_cmd,
        "[no] bgp suppress-fib-pending",
@@ -16936,6 +16948,9 @@ int bgp_config_write(struct vty *vty)
                vty_out(vty, "\n");
        }
 
+       if (bm->wait_for_fib)
+               vty_out(vty, "bgp suppress-fib-pending\n");
+
        if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN))
                vty_out(vty, "bgp graceful-shutdown\n");
 
@@ -17464,6 +17479,9 @@ void bgp_vty_init(void)
        install_element(CONFIG_NODE, &bgp_local_mac_cmd);
        install_element(CONFIG_NODE, &no_bgp_local_mac_cmd);
 
+       /* "bgp suppress-fib-pending" global */
+       install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd);
+
        /* bgp route-map delay-timer commands. */
        install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd);
        install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd);
index d3db540871e56afb4105002fff2365a635889ef0..22c1caacade11888911797cb9573aaae8c22eb09 100644 (file)
@@ -393,6 +393,29 @@ void bgp_router_id_static_set(struct bgp *bgp, struct in_addr id)
                          true /* is config */);
 }
 
+void bm_wait_for_fib_set(bool set)
+{
+       bool send_msg = false;
+
+       if (bm->wait_for_fib == set)
+               return;
+
+       bm->wait_for_fib = set;
+       if (set) {
+               if (bgp_suppress_fib_count == 0)
+                       send_msg = true;
+               bgp_suppress_fib_count++;
+       } else {
+               bgp_suppress_fib_count--;
+               if (bgp_suppress_fib_count == 0)
+                       send_msg = true;
+       }
+
+       if (send_msg && zclient)
+               zebra_route_notify_send(ZEBRA_ROUTE_NOTIFY_REQUEST,
+                                       zclient, set);
+}
+
 /* Set the suppress fib pending for the bgp configuration */
 void bgp_suppress_fib_pending_set(struct bgp *bgp, bool set)
 {
@@ -7419,6 +7442,7 @@ void bgp_master_init(struct thread_master *master, const int buffer_size)
        bm->terminating = false;
        bm->socket_buffer = buffer_size;
        bm->send_extra_data_to_zebra = true;
+       bm->wait_for_fib = false;
 
        bgp_mac_init();
        /* init the rd id space.
index 3451a616a42be2e99ebb73a41c0276cfa0dcc8ef..ebc53fe192dfbfa5e09ed1c8e4ed77772052e535 100644 (file)
@@ -159,6 +159,9 @@ struct bgp_master {
        /* How big should we set the socket buffer size */
        uint32_t socket_buffer;
 
+       /* Should we do wait for fib install globally? */
+       bool wait_for_fib;
+
        /* EVPN multihoming */
        struct bgp_evpn_mh_info *mh_info;
 
@@ -719,8 +722,9 @@ struct afi_safi_info {
 #define BGP_SELECT_DEFER_DISABLE(bgp)                                          \
        (CHECK_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE))
 
-#define BGP_SUPPRESS_FIB_ENABLED(bgp)                                         \
-       (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING))
+#define BGP_SUPPRESS_FIB_ENABLED(bgp)                                          \
+       (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)                 \
+        || bm->wait_for_fib)
 
 /* BGP peer-group support. */
 struct peer_group {
@@ -1879,6 +1883,7 @@ extern int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf,
 extern void bgp_router_id_zebra_bump(vrf_id_t, const struct prefix *);
 extern void bgp_router_id_static_set(struct bgp *, struct in_addr);
 
+extern void bm_wait_for_fib_set(bool set);
 extern void bgp_suppress_fib_pending_set(struct bgp *bgp, bool set);
 extern int bgp_cluster_id_set(struct bgp *, struct in_addr *);
 extern int bgp_cluster_id_unset(struct bgp *);