summaryrefslogtreecommitdiff
path: root/nest/proto.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2021-03-30 18:51:31 +0200
committerMaria Matejka <mq@ucw.cz>2021-03-30 21:56:08 +0200
commitff397df7edcbe7a8abca5b419729b9c64c063847 (patch)
tree796c7c2a4eadb6badd788f6c463ec9e24df81f6c /nest/proto.c
parenta9938b179203a4d5c54eae6c814bfa8766f4fde0 (diff)
Routing table is now a resource allocated from its own pool
This also fixes memory leaks from import/export tables being never cleaned up and freed.
Diffstat (limited to 'nest/proto.c')
-rw-r--r--nest/proto.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/nest/proto.c b/nest/proto.c
index 1c27e638..31ee1fa1 100644
--- a/nest/proto.c
+++ b/nest/proto.c
@@ -518,11 +518,12 @@ void
channel_setup_in_table(struct channel *c)
{
struct rtable_config *cf = mb_allocz(c->proto->pool, sizeof(struct rtable_config));
+
cf->name = "import";
cf->addr_type = c->net_type;
+ cf->internal = 1;
- c->in_table = mb_allocz(c->proto->pool, sizeof(struct rtable));
- rt_setup(c->proto->pool, c->in_table, cf);
+ c->in_table = rt_setup(c->proto->pool, cf);
c->reload_event = ev_new_init(c->proto->pool, channel_reload_loop, c);
}
@@ -534,9 +535,9 @@ channel_setup_out_table(struct channel *c)
struct rtable_config *cf = mb_allocz(c->proto->pool, sizeof(struct rtable_config));
cf->name = "export";
cf->addr_type = c->net_type;
+ cf->internal = 1;
- c->out_table = mb_allocz(c->proto->pool, sizeof(struct rtable));
- rt_setup(c->proto->pool, c->out_table, cf);
+ c->out_table = rt_setup(c->proto->pool, cf);
}
@@ -609,6 +610,8 @@ channel_do_down(struct channel *c)
c->reload_event = NULL;
c->out_table = NULL;
+ /* The in_table and out_table are going to be freed by freeing their resource pools. */
+
CALL(c->channel->cleanup, c);
/* Schedule protocol shutddown */