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 /nest/route.h | |
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 'nest/route.h')
-rw-r--r-- | nest/route.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/nest/route.h b/nest/route.h index 53cdcee8..2393fdc3 100644 --- a/nest/route.h +++ b/nest/route.h @@ -148,12 +148,15 @@ struct rtable_config { int gc_max_ops; /* Maximum number of operations before GC is run */ int gc_min_time; /* Minimum time between two consecutive GC runs */ byte sorted; /* Routes of network are sorted according to rte_better() */ + byte internal; /* Internal table of a protocol */ btime min_settle_time; /* Minimum settle time for notifications */ btime max_settle_time; /* Maximum settle time for notifications */ }; typedef struct rtable { + resource r; node n; /* Node in list of all tables */ + pool *rp; /* Resource pool to allocate everything from, including itself */ struct fib fib; char *name; /* Name of this table */ list channels; /* List of attached channels (struct channel) */ @@ -311,7 +314,9 @@ void rt_lock_table(rtable *); void rt_unlock_table(rtable *); void rt_subscribe(rtable *tab, struct rt_subscription *s); void rt_unsubscribe(struct rt_subscription *s); -void rt_setup(pool *, rtable *, struct rtable_config *); +rtable *rt_setup(pool *, struct rtable_config *); +static inline void rt_shutdown(rtable *r) { rfree(r->rp); } + static inline net *net_find(rtable *tab, const net_addr *addr) { return (net *) fib_find(&tab->fib, addr); } static inline net *net_find_valid(rtable *tab, const net_addr *addr) { net *n = net_find(tab, addr); return (n && rte_is_valid(n->routes)) ? n : NULL; } |