]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Partial import reload looks working
authorKaterina Kubecova <katerina.kubecova@nic.cz>
Fri, 13 Oct 2023 07:44:16 +0000 (09:44 +0200)
committerKaterina Kubecova <katerina.kubecova@nic.cz>
Fri, 13 Oct 2023 07:44:16 +0000 (09:44 +0200)
filter/trie.c
nest/proto.c
nest/rt-table.c
nest/rt.h

index 0bfbfdd64ec7f25025b9ee873df2f9574c3e3f82..12ba0b82b10bf4b89c760f8efbe751d12a5bc0dc 100644 (file)
@@ -496,7 +496,6 @@ trie_add_prefix(struct f_trie *t, const net_addr *net, uint l, uint h)
 static int
 trie_match_net4(const struct f_trie *t, ip4_addr px, uint plen)
 {
-  log("net4 compare");
   if (plen == 0)
     return t->zero;
 
@@ -533,7 +532,6 @@ trie_match_net4(const struct f_trie *t, ip4_addr px, uint plen)
 static int
 trie_match_net6(const struct f_trie *t, ip6_addr px, uint plen)
 {
-  log("net6 compare");
   if (plen == 0)
     return t->zero;
 
@@ -579,7 +577,6 @@ trie_match_net6(const struct f_trie *t, ip6_addr px, uint plen)
 int
 trie_match_net(const struct f_trie *t, const net_addr *n)
 {
-  log(L_DEBUG "trie match net - types %i %i", t->ipv4, n->type);
   switch (n->type)
   {
   case NET_IP4:
index 34cbbfcbef1585d71dd493233abfacfcb7319fd5..cfca3db3acd62bb6f696a8da44cf55947b40bc8d 100644 (file)
@@ -58,6 +58,8 @@ static void channel_stop_export(struct channel *c);
 static void channel_export_stopped(struct rt_export_request *req);
 static void channel_refeed_stopped(struct rt_export_request *req);
 static void channel_check_stopped(struct channel *c);
+static void channel_reload_in_done(struct channel_import_request *cir);
+static void channel_request_partial_reload(struct channel *c, struct channel_import_request *cir);
 
 static inline int proto_is_done(struct proto *p)
 { return (p->proto_state == PS_DOWN) && proto_is_inactive(p); }
@@ -355,7 +357,15 @@ channel_roa_in_changed(struct settle *se)
   struct channel *c = s->c;
 
   CD(c, "Reload triggered by RPKI change");
-  channel_request_reload(c);
+
+  struct channel_import_request *cir = lp_alloc(s->trie->lp, sizeof *cir);
+  *cir = (struct channel_import_request) {
+    .trie = s->trie,
+  };
+  if (s->trie)
+    cir->done = channel_reload_in_done;
+
+  channel_request_partial_reload(c, cir);
 }
 
 static void
@@ -371,7 +381,7 @@ channel_roa_out_changed(struct settle *se)
   struct channel *c = s->c;
 
   CD(c, "Feeding triggered by RPKI change");
-  
+
   /* Setup feeding request */
   struct channel_feeding_request *cfr = lp_alloc(s->trie->lp, sizeof *cfr);
   *cfr = (struct channel_feeding_request) {
@@ -558,10 +568,6 @@ channel_start_import(struct channel *c)
     .dump_req = channel_dump_import_req,
     .log_state_change = channel_import_log_state_change,
     .preimport = channel_preimport,
-    .prefilter = {
-      .mode = c->out_subprefix ? TE_ADDR_IN : TE_ADDR_NONE,
-      .addr = c->out_subprefix,
-    },
   };
 
   ASSERT(c->channel_state == CS_UP);
@@ -775,12 +781,8 @@ channel_import_prefilter(const struct rt_prefilter *p, const net_addr *n)
   ASSERT_DIE(c->importing);
   for (struct channel_import_request *cir = c->importing; cir; cir = cir->next)
   {
-    log(L_DEBUG "in for cycle %x %x", cir->trie, cir->trie->root);
     if (!cir->trie || trie_match_net(cir->trie, n))
-     {
-      log(L_TRACE "Export this one");
       return 1;
-     }
   }
   log(L_TRACE "%N filtered out of import", n);
   return 0;
@@ -838,7 +840,6 @@ channel_feed_end(struct channel *c)
 void
 channel_schedule_reload(struct channel *c, struct channel_import_request *cir)
 {
-  log(L_TRACE "channel_schedule_reload %i %i",cir, (cir && cir->trie));
   ASSERT(c->in_req.hook);
   int no_trie = 0;
   if (cir)
@@ -846,8 +847,8 @@ channel_schedule_reload(struct channel *c, struct channel_import_request *cir)
     cir->next = c->import_pending;
     c->import_pending = cir;
   }
-  
-  if (c->reload_req.hook) 
+
+  if (c->reload_req.hook)
   {
     CD(c, "Reload triggered before the previous one has finished");
     c->reload_pending = 1;
@@ -860,7 +861,7 @@ channel_schedule_reload(struct channel *c, struct channel_import_request *cir)
       no_trie = 1;
     last = last->next;
   }
-  
+
   c->importing = c->import_pending;
   c->import_pending = NULL;
 
@@ -1129,6 +1130,12 @@ channel_stop_export(struct channel *c)
     rt_stop_export(&c->out_req, channel_export_stopped);
 }
 
+static void
+channel_import_request_done_dynamic(struct channel_import_request *req)
+{
+  mb_free(req);
+}
+
 static void
 channel_request_reload(struct channel *c)
 {
@@ -1140,6 +1147,7 @@ channel_request_reload(struct channel *c)
   if ((c->in_keep & RIK_PREFILTER) == RIK_PREFILTER) {
     struct channel_import_request* cir = mb_alloc(c->proto->pool, sizeof *cir);;
     cir->trie = NULL;
+    cir->done = channel_import_request_done_dynamic;
     channel_schedule_reload(c, cir);
   }
   else
@@ -1153,10 +1161,10 @@ channel_request_partial_reload(struct channel *c, struct channel_import_request
   ASSERT(channel_reloadable(c));
 
   CD(c, "Partial import reload requested");
-  
+
   if ((c->in_keep & RIK_PREFILTER) == RIK_PREFILTER)
     channel_schedule_reload(c, cir);
-    /* TODO*/
+    /* TODO */
   else
     CD(c, "Partial import reload requested, but with ric cosi");
     /*c->proto->reload_routes(c);
index 668ee747c7fc364be88a019c457ceaeaf4277653..cbd2821e718ebb517653b9c0deaecc1ddc0521c0 100644 (file)
@@ -4402,7 +4402,6 @@ rt_process_feed(struct rt_table_export_hook *c, rt_feed_block *b)
 static void
 rt_feed_by_fib(void *data)
 {
-  log(L_TRACE "rt_feed_by_fib_function - here filtering starts");
   struct rt_table_export_hook *c = data;
   struct fib_iterator *fit = &c->feed_fit;
   rt_feed_block block = {};
@@ -4416,10 +4415,8 @@ rt_feed_by_fib(void *data)
     {
       if (rt_prefilter_net(&c->h.req->prefilter, n->n.addr))
       {
-        log("route passed");
        if (!rt_prepare_feed(c, n, &block))
        {
-         log("inside ifs");
          FIB_ITERATE_PUT(fit);
          RT_UNLOCK(tab);
          rt_process_feed(c, &block);
index 721a7325afb1625701f678bc82d6ec7d0e4f82d2..65da04a1a856945c822f4d6c53bda7320564b32e 100644 (file)
--- a/nest/rt.h
+++ b/nest/rt.h
@@ -274,7 +274,6 @@ struct rt_import_request {
   struct rt_import_hook *hook;         /* The table part of importer */
   char *name;
   u8 trace_routes;
-  struct rt_prefilter prefilter;
 
   event_list *list;                    /* Where to schedule announce events */