]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Delay returning RPKI instance as running
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 5 Apr 2022 13:54:19 +0000 (16:54 +0300)
committermergify-bot <noreply@mergify.com>
Fri, 8 Apr 2022 12:00:04 +0000 (12:00 +0000)
Start a separate timer which does the sync with the RPKI manager until
returns the synced status.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 1b2095d120e984a8d64496ca7d60ce59b7b3baa0)

bgpd/bgp_rpki.c

index bbeba74970260a2928b69300c1e2d24d7989cfb4..76485cbce12a5034d2082409b9ceabfd12f87c5a 100644 (file)
@@ -64,6 +64,7 @@
 #endif
 
 static struct thread *t_rpki;
+static struct thread *t_rpki_start;
 
 DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE, "BGP RPKI Cache server");
 DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE_GROUP, "BGP RPKI Cache server group");
@@ -71,6 +72,7 @@ DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE_GROUP, "BGP RPKI Cache server group");
 #define POLLING_PERIOD_DEFAULT 3600
 #define EXPIRE_INTERVAL_DEFAULT 7200
 #define RETRY_INTERVAL_DEFAULT 600
+#define BGP_RPKI_CACHE_SERVER_SYNC_RETRY_TIMEOUT 3
 
 #define RPKI_DEBUG(...)                                                        \
        if (rpki_debug) {                                                      \
@@ -594,6 +596,18 @@ static int bgp_rpki_module_init(void)
        return 0;
 }
 
+static void start_expired(struct thread *thread)
+{
+       if (!rtr_mgr_conf_in_sync(rtr_config)) {
+               thread_add_timer(bm->master, start_expired, NULL,
+                                BGP_RPKI_CACHE_SERVER_SYNC_RETRY_TIMEOUT,
+                                &t_rpki_start);
+               return;
+       }
+
+       rtr_is_running = 1;
+}
+
 static int start(void)
 {
        int ret;
@@ -627,7 +641,8 @@ static int start(void)
                rtr_mgr_free(rtr_config);
                return ERROR;
        }
-       rtr_is_running = 1;
+
+       thread_add_timer(bm->master, start_expired, NULL, 0, &t_rpki_start);
 
        XFREE(MTYPE_BGP_RPKI_CACHE_GROUP, groups);
 
@@ -638,6 +653,7 @@ static void stop(void)
 {
        rtr_is_stopping = 1;
        if (is_running()) {
+               THREAD_OFF(t_rpki_start);
                rtr_mgr_stop(rtr_config);
                rtr_mgr_free(rtr_config);
                rtr_is_running = 0;
@@ -649,6 +665,9 @@ static int reset(bool force)
        if (is_running() && !force)
                return SUCCESS;
 
+       if (thread_is_scheduled(t_rpki_start))
+               return SUCCESS;
+
        RPKI_DEBUG("Resetting RPKI Session");
        stop();
        return start();