]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
RPKI: Use the route refresh mechanism also for the first load
authorMaria Matejka <mq@jmq.cz>
Tue, 16 Nov 2021 21:14:24 +0000 (21:14 +0000)
committerMaria Matejka <mq@ucw.cz>
Mon, 22 Nov 2021 18:05:44 +0000 (19:05 +0100)
proto/rpki/packets.c
proto/rpki/rpki.c
proto/rpki/rpki.h

index 38830d2887d383f6b9a928f6d341504f427c7aa6..abe6abfcae64a67860f9eb9dfbf0c30c315cfb2d 100644 (file)
@@ -658,21 +658,7 @@ rpki_handle_cache_response_pdu(struct rpki_cache *cache, const struct pdu_cache_
 {
   if (cache->request_session_id)
   {
-    if (cache->last_update)
-    {
-      /*
-       * This isn't the first sync and we already received records. This point
-       * is after Reset Query and before importing new records from cache
-       * server. We need to load new ones and kick out missing ones.  So start
-       * a refresh cycle.
-       */
-      if (cache->p->roa4_channel)
-       rt_refresh_begin(&cache->p->roa4_channel->in_req);
-      if (cache->p->roa6_channel)
-       rt_refresh_begin(&cache->p->roa6_channel->in_req);
-
-      cache->p->refresh_channels = 1;
-    }
+    rpki_start_refresh(cache->p);
     cache->session_id = pdu->session_id;
     cache->request_session_id = 0;
   }
@@ -821,14 +807,7 @@ rpki_handle_end_of_data_pdu(struct rpki_cache *cache, const struct pdu_end_of_da
                (cf->keep_expire_interval ? "keeps " : ""),  cache->expire_interval);
   }
 
-  if (cache->p->refresh_channels)
-  {
-    cache->p->refresh_channels = 0;
-    if (cache->p->roa4_channel)
-      rt_refresh_end(&cache->p->roa4_channel->in_req);
-    if (cache->p->roa6_channel)
-      rt_refresh_end(&cache->p->roa6_channel->in_req);
-  }
+  rpki_stop_refresh(cache->p);
 
   cache->last_update = current_time();
   cache->serial_num = pdu->serial_num;
index 950664990d6bdd0c1e09fc9c72b98682bde19d3d..e3fccb485b121fb9d03e0679061020661f55f9eb 100644 (file)
@@ -139,6 +139,30 @@ rpki_table_remove_roa(struct rpki_cache *cache, struct channel *channel, const n
   rte_update(channel, &pfxr->n, NULL, p->p.main_source);
 }
 
+void
+rpki_start_refresh(struct rpki_proto *p)
+{
+  if (p->roa4_channel)
+    rt_refresh_begin(&p->roa4_channel->in_req);
+  if (p->roa6_channel)
+    rt_refresh_begin(&p->roa6_channel->in_req);
+
+  p->refresh_channels = 1;
+}
+
+void
+rpki_stop_refresh(struct rpki_proto *p)
+{
+  if (!p->refresh_channels)
+    return;
+
+  p->refresh_channels = 0;
+
+  if (p->roa4_channel)
+    rt_refresh_end(&p->roa4_channel->in_req);
+  if (p->roa6_channel)
+    rt_refresh_end(&p->roa6_channel->in_req);
+}
 
 /*
  *     RPKI Protocol Logic
@@ -626,6 +650,7 @@ rpki_close_connection(struct rpki_cache *cache)
 {
   CACHE_TRACE(D_EVENTS, cache, "Closing a connection");
   rpki_tr_close(cache->tr_sock);
+  rpki_stop_refresh(cache->p);
   proto_notify_state(&cache->p->p, PS_START);
 }
 
index 8a5c38fda4e1652dda2a5e502fc7574eb1be29c2..a70a2027b08841175c5675f8cec9730f87187c35 100644 (file)
@@ -83,6 +83,8 @@ const char *rpki_cache_state_to_str(enum rpki_cache_state state);
 void rpki_table_add_roa(struct rpki_cache *cache, struct channel *channel, const net_addr_union *pfxr);
 void rpki_table_remove_roa(struct rpki_cache *cache, struct channel *channel, const net_addr_union *pfxr);
 
+void rpki_start_refresh(struct rpki_proto *p);
+void rpki_stop_refresh(struct rpki_proto *p);
 
 /*
  *     RPKI Protocol Logic