summaryrefslogtreecommitdiffstats
path: root/nest/rt-table.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1998-12-07 22:59:15 +0100
committerMartin Mares <mj@ucw.cz>1998-12-07 22:59:15 +0100
commit04925e9040330afc92f8001e6a19ae2146e36782 (patch)
tree66f976a8ebb63fc1e29206a345a142df59286ed5 /nest/rt-table.c
parentcdc6bfa70f730c3741537cc21cdd0a5d13ed2af9 (diff)
downloadbird-04925e9040330afc92f8001e6a19ae2146e36782.tar
bird-04925e9040330afc92f8001e6a19ae2146e36782.zip
Minor rte/rta interface changes:
o rte can now contain a pointer to both cached and uncached rta. Protocols which don't need their own attribute caching can now just fill-in a rta, link it to rte without any calls to attribute cache and call rte_update() which will replace rte->attrs by a cached copy. o In order to support this, one of previously pad bytes in struct rta now holds new attribute flags (RTAF_CACHED). If you call rte_update() with uncached rta, you _must_ clear these flags. In other cases rta_lookup() sets it appropriately. o Added rte_free() which is useful when you construct a rte and then the circumstances change and you decide not to use it for an update. (Needed for temporary rte's in kernel syncer...)
Diffstat (limited to 'nest/rt-table.c')
-rw-r--r--nest/rt-table.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/nest/rt-table.c b/nest/rt-table.c
index 1eb3395..386738c 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)
{