]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: add knob to config cond-adv scanner period
authorQuentin Young <qlyoung@nvidia.com>
Fri, 14 May 2021 18:57:06 +0000 (14:57 -0400)
committerQuentin Young <qlyoung@nvidia.com>
Tue, 13 Jul 2021 17:19:14 +0000 (13:19 -0400)
Adds a knob that sets the time between loc-rib scans for conditional
advertisement.

I chose the range (5-240) because 1 second seems dumb and too easy to
hurt yourself at even moderate scale, 5 seconds you can still hurt
yourself but I could see a use case for it, and 4 minutes should be
enough for anyone (tm)

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
bgpd/bgp_conditional_adv.c
bgpd/bgp_conditional_adv.h
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h
doc/user/bgp.rst

index 49bc38be662f28ce7ebcc2c2a57a69b5ecccb50b..329bd3d696cadd11c172a609d95fe1b936c79284 100644 (file)
@@ -184,7 +184,7 @@ static int bgp_conditional_adv_timer(struct thread *t)
        assert(bgp);
 
        thread_add_timer(bm->master, bgp_conditional_adv_timer, bgp,
-                        CONDITIONAL_ROUTES_POLL_TIME, &bgp->t_condition_check);
+                        bgp->condition_check_period, &bgp->t_condition_check);
 
        /* loop through each peer and advertise or withdraw routes if
         * advertise-map is configured and prefix(es) in condition-map
@@ -315,7 +315,7 @@ void bgp_conditional_adv_enable(struct peer *peer, afi_t afi, safi_t safi)
 
        /* Register for conditional routes polling timer */
        thread_add_timer(bm->master, bgp_conditional_adv_timer, bgp,
-                        CONDITIONAL_ROUTES_POLL_TIME, &bgp->t_condition_check);
+                        bgp->condition_check_period, &bgp->t_condition_check);
 }
 
 void bgp_conditional_adv_disable(struct peer *peer, afi_t afi, safi_t safi)
index 7b5053de7602848243e96ff1fbe674776c47173c..371ae856c2cd02962c45bbaa66acee2aa0bfcd54 100644 (file)
@@ -34,7 +34,7 @@ extern "C" {
 #endif
 
 /* Polling time for monitoring condition-map routes in route table */
-#define CONDITIONAL_ROUTES_POLL_TIME 60
+#define DEFAULT_CONDITIONAL_ROUTES_POLL_TIME 60
 
 extern void bgp_conditional_adv_enable(struct peer *peer, afi_t afi,
                                       safi_t safi);
index 9d7e88bb1ca08348378d90e45a117e56ef6f7abf..576ced34734e3f99fec24781e3400df21f413c19 100644 (file)
@@ -72,6 +72,7 @@
 #include "bgpd/bgp_addpath.h"
 #include "bgpd/bgp_mac.h"
 #include "bgpd/bgp_flowspec.h"
+#include "bgpd/bgp_conditional_adv.h"
 #ifdef ENABLE_BGP_VNC
 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
 #endif
@@ -8116,6 +8117,23 @@ static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str,
        return bgp_vty_return(vty, ret);
 }
 
+DEFPY (bgp_condadv_period,
+       bgp_condadv_period_cmd,
+       "[no$no] bgp conditional-advertisement timer (5-240)$period",
+       NO_STR
+       BGP_STR
+       "Conditional advertisement settings\n"
+       "Set period to rescan BGP table to check if condition is met\n"
+       "Period between BGP table scans, in seconds; default 60\n")
+{
+       VTY_DECLVAR_CONTEXT(bgp, bgp);
+
+       bgp->condition_check_period =
+               no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period;
+
+       return CMD_SUCCESS;
+}
+
 DEFPY (neighbor_advertise_map,
        neighbor_advertise_map_cmd,
        "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str",
@@ -18146,6 +18164,13 @@ int bgp_config_write(struct vty *vty)
                        vty_out(vty, " timers bgp %u %u\n",
                                bgp->default_keepalive, bgp->default_holdtime);
 
+               /* Conditional advertisement timer configuration */
+               if (bgp->condition_check_period
+                   != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME)
+                       vty_out(vty,
+                               " bgp conditional-advertisement timer %u\n",
+                               bgp->condition_check_period);
+
                /* peer-group */
                for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) {
                        bgp_config_write_peer_global(vty, bgp, group->conf);
@@ -19434,6 +19459,7 @@ void bgp_vty_init(void)
        install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd);
 
        /* "neighbor advertise-map" commands. */
+       install_element(BGP_NODE, &bgp_condadv_period_cmd);
        install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd);
        install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd);
        install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd);
index acade16ef27fb8cebf0de2e67def58ec6621731f..18755248c394ce8b10cd8762edbababb86192d7d 100644 (file)
@@ -3180,6 +3180,7 @@ static struct bgp *bgp_create(as_t *as, const char *name,
        bgp->lb_ref_bw = BGP_LINK_BW_REF_BW;
        bgp->lb_handling = BGP_LINK_BW_ECMP;
        bgp->reject_as_sets = false;
+       bgp->condition_check_period = DEFAULT_CONDITIONAL_ROUTES_POLL_TIME;
        bgp_addpath_init_bgp_data(&bgp->tx_addpath);
 
        bgp->as = *as;
index d2e8cce997b9aab54e2bc27262ecdd18ea4872cc..e6a828a2c0696134d5fdd6434053854d1636cf39 100644 (file)
@@ -748,6 +748,7 @@ struct bgp {
        struct work_queue *process_queue;
 
        /* BGP Conditional advertisement */
+       uint32_t condition_check_period;
        uint32_t condition_filter_count;
        struct thread *t_condition_check;
 
index b5950538dd25b8a858706f361d1202104c7e9afa..c93a2833c062aef7241d23580144cfb86316e41b 100644 (file)
@@ -3016,10 +3016,13 @@ The conditional BGP announcements are sent in addition to the normal
 announcements that a BGP router sends to its peer.
 
 The conditional advertisement process is triggered by the BGP scanner process,
-which runs every 60 seconds. This means that the maximum time for the conditional
-advertisement to take effect is 60 seconds. The conditional advertisement can take
-effect depending on when the tracked route is removed from the BGP table and
-when the next instance of the BGP scanner occurs.
+which runs every 60 by default. This means that the maximum time for the
+conditional advertisement to take effect is the value of the process timer.
+
+As an optimization, while the process always runs on each timer expiry, it
+determines whether or not the conditional advertisement policy or the routing
+table has changed; if neither have changed, no processing is necessary and the
+scanner exits early.
 
 .. clicmd:: neighbor A.B.C.D advertise-map NAME [exist-map|non-exist-map] NAME
 
@@ -3027,6 +3030,11 @@ when the next instance of the BGP scanner occurs.
    exist-map or non-exist-map command in BGP table and conditionally advertises
    the routes specified by advertise-map command.
 
+.. clicmd:: bgp conditional-advertisement timer (5-240)
+
+   Set the period to rerun the conditional advertisement scanner process. The
+   default is 60 seconds.
+
 Sample Configuration
 ^^^^^^^^^^^^^^^^^^^^^
 .. code-block:: frr