]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Channel: Replacing refeed status trie by bitmap
authorMaria Matejka <mq@ucw.cz>
Mon, 8 Jan 2024 11:02:25 +0000 (12:02 +0100)
committerMaria Matejka <mq@ucw.cz>
Mon, 8 Jan 2024 11:02:25 +0000 (12:02 +0100)
This fixes a bug with reloading non-IP channels.

nest/proto.c
nest/protocol.h

index 70cfad5217e9fa5d1834c92313b966705d2c0931..72d94a282646a4bc6879633bfc477b1bcfb4b082 100644 (file)
@@ -705,6 +705,7 @@ channel_start_export(struct channel *c)
 
   bmap_init(&c->export_map, p, 16);
   bmap_init(&c->export_reject_map, p, 16);
+  bmap_init(&c->refeed_map, p, 16);
 
   channel_reset_limit(c, &c->out_limit, PLD_OUT);
 
@@ -791,6 +792,7 @@ channel_export_stopped(struct rt_export_request *req)
 
     bmap_reset(&c->export_map, 16);
     bmap_reset(&c->export_reject_map, 16);
+    bmap_reset(&c->refeed_map, 16);
 
     rt_request_export(c->table, req);
     return;
@@ -833,7 +835,7 @@ channel_init_feeding(struct channel *c)
   /* No direct feeding, running auxiliary refeed. */
   c->refeeding = c->refeed_pending;
   c->refeed_pending = NULL;
-  c->refeed_trie = f_new_trie(lp_new(c->proto->pool), 0);
+  bmap_reset(&c->refeed_map, 16);
 
   if (no_trie)
   {
@@ -924,11 +926,6 @@ channel_feed_end(struct channel *c)
 
   /* Drop the refeed batch */
   c->refeeding = NULL;
-  if (c->refeed_trie)
-  {
-    rfree(c->refeed_trie->lp);
-    c->refeed_trie = NULL;
-  }
 
   /* Run the pending batch */
   if (c->refeed_pending)
index a63305acb20354e0b6141bc7a63f0343ebaa834f..9b8b837d1fd6180d698d73a9dd582bf28e2b9580 100644 (file)
@@ -583,7 +583,7 @@ struct channel {
   struct rt_export_request out_req;    /* Table export connection */
 
   struct rt_export_request refeed_req; /* Auxiliary refeed request */
-  struct f_trie *refeed_trie;          /* Auxiliary refeed trie */
+  struct bmap refeed_map;              /* Auxiliary refeed netindex bitmap */
   struct channel_feeding_request *refeeding;   /* Refeeding the channel */
   struct channel_feeding_request *refeed_pending;      /* Scheduled refeeds */
   struct channel_import_request *importing;    /* Importing the channel */
@@ -718,11 +718,12 @@ void channel_request_feeding_dynamic(struct channel *c, enum channel_feeding_req
 static inline int channel_net_is_refeeding(struct channel *c, const net_addr *n)
 {
   /* Not refeeding if not refeeding at all */
-  if (!c->refeeding || !c->refeed_trie)
+  if (!c->refeeding)
     return 0;
 
   /* Not refeeding if already refed */
-  if (trie_match_net(c->refeed_trie, n))
+  struct netindex *ni = NET_TO_INDEX(n);
+  if (bmap_test(&c->refeed_map, ni->index))
     return 0;
 
   /* Refeeding if matching any request */
@@ -735,8 +736,10 @@ static inline int channel_net_is_refeeding(struct channel *c, const net_addr *n)
 }
 static inline void channel_net_mark_refed(struct channel *c, const net_addr *n)
 {
-  ASSERT_DIE(c->refeeding && c->refeed_trie);
-  trie_add_prefix(c->refeed_trie, n, n->pxlen, n->pxlen);
+  ASSERT_DIE(c->refeeding);
+
+  struct netindex *ni = NET_TO_INDEX(n);
+  bmap_set(&c->refeed_map, ni->index);
 }
 
 void channel_request_reload(struct channel *c);