summaryrefslogtreecommitdiff
path: root/proto/bgp/attrs.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2016-11-25 11:51:38 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2016-11-25 11:51:38 +0100
commited1a908e535e4333b358d83b472453a2ad6d3f51 (patch)
tree3ee46e6d922c3e363dad23976fcc2de0a7e19429 /proto/bgp/attrs.c
parent261816b0d4f3d4549a4402b95541b82fc7f10a4b (diff)
BGP: Fix memory leak in graceful restart code
Prefix and bucket tables are initialized when entering established state but not explicitly freed when leaving it (that is handled by protocol restart). With graceful restart, BGP may enter and leave established state multiple times without hard protocol restart causing memory leak.
Diffstat (limited to 'proto/bgp/attrs.c')
-rw-r--r--proto/bgp/attrs.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index aa2a3b46..9d23374a 100644
--- a/proto/bgp/attrs.c
+++ b/proto/bgp/attrs.c
@@ -934,6 +934,15 @@ bgp_init_prefix_table(struct bgp_proto *p, u32 order)
p->prefix_slab = sl_new(p->p.pool, sizeof(struct bgp_prefix));
}
+void
+bgp_free_prefix_table(struct bgp_proto *p)
+{
+ HASH_FREE(p->prefix_hash);
+
+ rfree(p->prefix_slab);
+ p->prefix_slab = NULL;
+}
+
static struct bgp_prefix *
bgp_get_prefix(struct bgp_proto *p, ip_addr prefix, int pxlen, u32 path_id)
{
@@ -1941,6 +1950,23 @@ bgp_init_bucket_table(struct bgp_proto *p)
}
void
+bgp_free_bucket_table(struct bgp_proto *p)
+{
+ mb_free(p->bucket_hash);
+ p->bucket_hash = NULL;
+
+ struct bgp_bucket *b;
+ WALK_LIST_FIRST(b, p->bucket_queue)
+ {
+ rem_node(&b->send_node);
+ mb_free(b);
+ }
+
+ mb_free(p->withdraw_bucket);
+ p->withdraw_bucket = NULL;
+}
+
+void
bgp_get_route_info(rte *e, byte *buf, ea_list *attrs)
{
eattr *p = ea_find(attrs, EA_CODE(EAP_BGP, BA_AS_PATH));