]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Replace trie linpool with slab
authorIgor Putovny <igor.putovny@nic.cz>
Tue, 4 Mar 2025 15:38:30 +0000 (16:38 +0100)
committerIgor Putovny <igor.putovny@nic.cz>
Tue, 4 Mar 2025 15:38:30 +0000 (16:38 +0100)
proto/aggregator/aggregator.c
proto/aggregator/aggregator.h
proto/aggregator/trie.c

index da2fc76308e63d8c03f4e510738976420c19622a..7aeb0701432fa2bbea64401d708ebe8871291ebe 100644 (file)
@@ -851,7 +851,7 @@ aggregator_init_trie(struct aggregator_proto *p)
   HASH_INSERT2(p->buckets, AGGR_BUCK, p->p.pool, new_bucket);
 
   /* Create root node */
-  p->root = aggregator_create_new_node(p->trie_pool);
+  p->root = aggregator_create_new_node(p->trie_slab);
 
   /*
    * Root node is initialized with NON_FIB status.
@@ -872,7 +872,7 @@ aggregator_start(struct proto *P)
 
   ASSERT_DIE(p->bucket_pool == NULL);
   ASSERT_DIE(p->route_pool == NULL);
-  ASSERT_DIE(p->trie_pool == NULL);
+  ASSERT_DIE(p->trie_slab == NULL);
   ASSERT_DIE(p->root == NULL);
 
   p->addr_type = p->src->table->addr_type;
@@ -890,8 +890,8 @@ aggregator_start(struct proto *P)
 
   if (p->aggr_mode == PREFIX_AGGR)
   {
-    ASSERT_DIE(p->trie_pool == NULL);
-    p->trie_pool = lp_new(P->pool);
+    ASSERT_DIE(p->trie_slab == NULL);
+    p->trie_slab = sl_new(P->pool, sizeof(struct trie_node));
 
     ASSERT_DIE(p->bucket_list == NULL);
     ASSERT_DIE(p->bucket_list_size == 0);
@@ -926,7 +926,7 @@ aggregator_cleanup(struct proto *P)
    */
   p->bucket_pool = NULL;
   p->route_pool = NULL;
-  p->trie_pool = NULL;
+  p->trie_slab = NULL;
   p->rte_withdrawal_pool = NULL;
 
   p->root = NULL;
index 1f2d3533a46d8c9ac39b72590ec47d95ceb8ae96..31b9a0a598417f28da5fa96ad71b480082816cf2 100644 (file)
@@ -86,7 +86,7 @@ struct aggregator_proto {
 
   /* Aggregation trie */
   uint addr_type;
-  linpool *trie_pool;
+  struct slab *trie_slab;
   struct trie_node *root;
   int logging;
 
@@ -152,6 +152,6 @@ void aggregator_aggregate(struct aggregator_proto *p);
 void aggregator_recalculate(struct aggregator_proto *p, struct aggregator_route *old, struct aggregator_route *new);
 void aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *bucket, struct network *net);
 
-struct trie_node *aggregator_create_new_node(linpool *trie_pool);
+struct trie_node *aggregator_create_new_node(struct slab *trie_slab);
 
 #endif
index 07c69049c406046300e142e71a29f293d084c21b..a4f1a9a11082bd9923a2fc84d2b788ec43d95838 100644 (file)
@@ -92,13 +92,12 @@ static const u32 ipa_shift[] = {
 };
 
 /*
- * Allocate new node in protocol linpool
+ * Allocate new node in trie slab
  */
 struct trie_node *
-aggregator_create_new_node(linpool *trie_pool)
+aggregator_create_new_node(struct slab *trie_slab)
 {
-  struct trie_node *node = lp_allocz(trie_pool, sizeof(*node));
-  return node;
+  return sl_allocz(trie_slab);
 }
 
 static inline int
@@ -130,6 +129,7 @@ aggregator_remove_node(struct trie_node *node)
   }
 
   memset(node, 0, sizeof(*node));
+  sl_free(node);
 }
 
 /*
@@ -439,7 +439,7 @@ aggregator_trie_insert_prefix(struct aggregator_proto *p, ip_addr prefix, u32 px
 
     if (!node->child[bit])
     {
-      struct trie_node *new = aggregator_create_new_node(p->trie_pool);
+      struct trie_node *new = aggregator_create_new_node(p->trie_slab);
 
       *new = (struct trie_node) {
         .parent = node,
@@ -720,7 +720,7 @@ aggregator_third_pass_helper(struct aggregator_proto *p, struct trie_node *node,
      */
     if (!aggregator_is_bucket_potential(&imaginary_node, imaginary_node_inherited_bucket))
     {
-      struct trie_node *new = aggregator_create_new_node(p->trie_pool);
+      struct trie_node *new = aggregator_create_new_node(p->trie_slab);
       *new = imaginary_node;
 
       /* Connect new node to the trie */