From ff397df7edcbe7a8abca5b419729b9c64c063847 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 30 Mar 2021 18:51:31 +0200 Subject: 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. --- sysdep/unix/krt.c | 11 ++++++----- sysdep/unix/krt.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'sysdep') diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index c00c660d..ceb88563 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -317,7 +317,7 @@ static void krt_learn_scan(struct krt_proto *p, rte *e) { net *n0 = e->net; - net *n = net_get(&p->krt_table, n0->n.addr); + net *n = net_get(p->krt_table, n0->n.addr); rte *m, **mm; e->attrs = rta_lookup(e->attrs); @@ -354,7 +354,7 @@ krt_learn_scan(struct krt_proto *p, rte *e) static void krt_learn_prune(struct krt_proto *p) { - struct fib *fib = &p->krt_table.fib; + struct fib *fib = &p->krt_table->fib; struct fib_iterator fit; KRT_TRACE(p, D_EVENTS, "Pruning inherited routes"); @@ -430,7 +430,7 @@ static void krt_learn_async(struct krt_proto *p, rte *e, int new) { net *n0 = e->net; - net *n = net_get(&p->krt_table, n0->n.addr); + net *n = net_get(p->krt_table, n0->n.addr); rte *g, **gg, *best, **bestp, *old_best; e->attrs = rta_lookup(e->attrs); @@ -511,8 +511,9 @@ krt_learn_init(struct krt_proto *p) struct rtable_config *cf = mb_allocz(p->p.pool, sizeof(struct rtable_config)); cf->name = "Inherited"; cf->addr_type = p->p.net_type; + cf->internal = 1; - rt_setup(p->p.pool, &p->krt_table, cf); + p->krt_table = rt_setup(p->p.pool, cf); } } @@ -524,7 +525,7 @@ krt_dump(struct proto *P) if (!KRT_CF->learn) return; debug("KRT: Table of inheritable routes\n"); - rt_dump(&p->krt_table); + rt_dump(p->krt_table); } static void diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h index 4a5d10d2..62228f08 100644 --- a/sysdep/unix/krt.h +++ b/sysdep/unix/krt.h @@ -49,7 +49,7 @@ struct krt_proto { struct krt_state sys; /* Sysdep state */ #ifdef KRT_ALLOW_LEARN - struct rtable krt_table; /* Internal table of inherited routes */ + struct rtable *krt_table; /* Internal table of inherited routes */ #endif #ifndef CONFIG_ALL_TABLES_AT_ONCE -- cgit v1.2.3