]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: TX bucket storage moved to Stonehenge
authorMaria Matejka <mq@ucw.cz>
Tue, 24 Dec 2024 12:22:56 +0000 (13:22 +0100)
committerMaria Matejka <mq@ucw.cz>
Thu, 9 Jan 2025 09:08:27 +0000 (10:08 +0100)
proto/bgp/attrs.c
proto/bgp/bgp.h

index a2feaef534001457bfd01511c09c073c7ae15039..725c469ffd87507e4583b463adaf86f273ffc8d7 100644 (file)
@@ -1734,13 +1734,16 @@ bgp_get_bucket(struct bgp_ptx_private *c, ea_list *new)
   uint size = sizeof(struct bgp_bucket) + ea_size;
 
   /* Allocate the bucket */
-  b = mb_alloc(c->pool, size);
+  sth_block blk = sth_alloc(c->sth, size);
+  b = blk.block;
   *b = (struct bgp_bucket) { };
   init_list(&b->prefixes);
   b->hash = hash;
 
   /* Copy the ea_list */
   ea_list_copy(b->eattrs, new, ea_size);
+  if (blk.large)
+    b->eattrs->flags |= EALF_HUGE;
 
   /* Insert the bucket to bucket hash */
   HASH_INSERT2(c->bucket_hash, RBH, c->pool, b);
@@ -1764,7 +1767,7 @@ static void
 bgp_free_bucket(struct bgp_ptx_private *c, struct bgp_bucket *b)
 {
   HASH_REMOVE2(c->bucket_hash, RBH, c->pool, b);
-  mb_free(b);
+  sth_free((sth_block) { b, !!(b->eattrs->flags & EALF_HUGE) });
 }
 
 int
@@ -2086,6 +2089,7 @@ bgp_init_pending_tx(struct bgp_channel *c)
 
   bpp->lock = dom;
   bpp->pool = p;
+  bpp->sth = sth_new(p);
   bpp->c = c;
 
   bgp_init_bucket_table(bpp);
@@ -2160,8 +2164,7 @@ bgp_free_pending_tx(struct bgp_channel *bc)
   HASH_WALK_END;
 
   HASH_FREE(c->bucket_hash);
-  sl_delete(c->bucket_slab);
-  c->bucket_slab = NULL;
+  sth_delete(c->sth);
 
   rp_free(c->pool);
 
index 202e78ba39a0f4dc03b844e8dd06c07afac811e1..dac6e84eaa415792c0347bb07cc909dc999c84ef 100644 (file)
@@ -452,7 +452,8 @@ struct bgp_ptx_private {
   struct { BGP_PTX_PUBLIC; };
   struct bgp_ptx_private **locked_at;
 
-  pool *pool;                          /* Resource pool for TX related allocations */
+  pool *pool;                          /* Pool for infrequent long-term blocks */
+  stonehenge *sth;                     /* Bucket allocator */
 
   HASH(struct bgp_bucket) bucket_hash; /* Hash table of route buckets */
   struct bgp_bucket *withdraw_bucket;  /* Withdrawn routes */
@@ -461,7 +462,6 @@ struct bgp_ptx_private {
   HASH(struct bgp_prefix) prefix_hash; /* Hash table of pending prefices */
 
   slab *prefix_slab;                   /* Slab holding prefix nodes */
-  slab *bucket_slab;                   /* Slab holding buckets to send */
 
   char bmp;                            /* This is a fake ptx for BMP encoding */
 };