summaryrefslogtreecommitdiff
path: root/net/bird3/files/patch-12-BGP-tx-bucket-storage
blob: 513824f867692ab143868a52bf0d9bec48207885 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From fdb5c4920b45139fb3c37e1144643c0f756364b6 Mon Sep 17 00:00:00 2001
From: Maria Matejka <mq@ucw.cz>
Date: Tue, 24 Dec 2024 13:22:56 +0100
Subject: [PATCH] BGP: TX bucket storage moved to Stonehenge

---
 proto/bgp/attrs.c | 11 +++++++----
 proto/bgp/bgp.h   |  4 ++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index a2feaef53..725c469ff 100644
--- proto/bgp/attrs.c
+++ proto/bgp/attrs.c
@@ -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);
 
diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h
index 202e78ba3..dac6e84ea 100644
--- proto/bgp/bgp.h
+++ proto/bgp/bgp.h
@@ -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 */
 };
-- 
GitLab