diff options
Diffstat (limited to 'nest/rt-table.c')
-rw-r--r-- | nest/rt-table.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/nest/rt-table.c b/nest/rt-table.c index 1eb3395b..386738c9 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -136,9 +136,17 @@ rt_feed_baby(struct proto *p) } } -static inline void +void rte_free(rte *e) { + if (e->attrs->aflags & RTAF_CACHED) + rta_free(e->attrs); + sl_free(rte_slab, e); +} + +static inline void +rte_free_quick(rte *e) +{ rta_free(e->attrs); sl_free(rte_slab, e); } @@ -150,6 +158,9 @@ rte_update(net *net, struct proto *p, rte *new) rte *old = NULL; rte **k, *r, *s; + if (new && !(new->attrs->aflags & RTAF_CACHED)) /* Need to copy attributes */ + new->attrs = rta_lookup(new->attrs); + k = &net->routes; /* Find and remove original route from the same protocol */ while (old = *k) { @@ -202,7 +213,7 @@ rte_update(net *net, struct proto *p, rte *new) { if (p->rte_remove) p->rte_remove(net, old); - rte_free(old); + rte_free_quick(old); } if (new) { |