diff options
author | Maria Matejka <mq@ucw.cz> | 2021-03-30 18:51:31 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2021-03-30 21:56:08 +0200 |
commit | ff397df7edcbe7a8abca5b419729b9c64c063847 (patch) | |
tree | 796c7c2a4eadb6badd788f6c463ec9e24df81f6c /sysdep | |
parent | a9938b179203a4d5c54eae6c814bfa8766f4fde0 (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 'sysdep')
-rw-r--r-- | sysdep/unix/krt.c | 11 | ||||
-rw-r--r-- | sysdep/unix/krt.h | 2 |
2 files changed, 7 insertions, 6 deletions
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 |