net *net_get(rtable *tab, const net_addr *addr);
net *net_route(rtable *tab, const net_addr *n);
int net_roa_check(rtable *tab, const net_addr *n, u32 asn);
-rte *rte_find(net *net, struct rte_src *src);
-rte *rte_get_temp(struct rta *, struct rte_src *src);
-void rte_update2(struct channel *c, const net_addr *n, rte *new, struct rte_src *src);
-/* rte_update() moved to protocol.h to avoid dependency conflicts */
-int rt_examine(rtable *t, net_addr *a, struct proto *p, const struct filter *filter);
-rte *rt_export_merged(struct channel *c, net *net, rte **rt_free, linpool *pool, int silent);
-void rt_refresh_begin(rtable *t, struct channel *c);
-void rt_refresh_end(rtable *t, struct channel *c);
-void rt_modify_stale(rtable *t, struct channel *c);
+int rt_examine(rtable *t, net_addr *a, struct channel *c, const struct filter *filter);
+rte *rt_export_merged(struct channel *c, rte ** feed, uint count, linpool *pool, int silent);
+void rt_refresh_begin(rtable *t, struct rt_import_request *);
+void rt_refresh_end(rtable *t, struct rt_import_request *);
+void rt_modify_stale(rtable *t, struct rt_import_request *);
void rt_schedule_prune(rtable *t);
-void rte_dump(rte *);
-void rte_free(rte *);
-rte *rte_do_cow(rte *);
-static inline rte * rte_cow(rte *r) { return (r->flags & REF_COW) ? rte_do_cow(r) : r; }
-rte *rte_cow_rta(rte *r, linpool *lp);
+void rte_dump(struct rte_storage *);
- void rte_free(struct rte_storage *, rtable *);
++void rte_free(struct rte_storage *);
+struct rte_storage *rte_store(const rte *, net *net, rtable *);
void rt_dump(rtable *);
void rt_dump_all(void);
-int rt_feed_channel(struct channel *c);
-void rt_feed_channel_abort(struct channel *c);
-int rte_update_in(struct channel *c, const net_addr *n, rte *new, struct rte_src *src);
+void rt_dump_hooks(rtable *);
+void rt_dump_hooks_all(void);
int rt_reload_channel(struct channel *c);
void rt_reload_channel_abort(struct channel *c);
+void rt_refeed_channel(struct channel *c);
void rt_prune_sync(rtable *t, int all);
-int rte_update_out(struct channel *c, const net_addr *n, rte *new, rte *old, rte **old_exported, int refeed);
+int rte_update_in(struct channel *c, const net_addr *n, rte *new, struct rte_src *src);
+int rte_update_out(struct channel *c, const net_addr *n, rte *new, const rte *old, struct rte_storage **old_exported);
struct rtable_config *rt_new_table(struct symbol *s, uint addr_type);
static inline int rt_is_ip(rtable *tab)
*
* rte_free() deletes the given &rte from the routing table it's linked to.
*/
-void
-rte_free(rte *e)
-{
- rt_unlock_source(e->src);
- if (rta_is_cached(e->attrs))
- rta_free(e->attrs);
- sl_free(e);
-}
-static inline void
-rte_free_quick(rte *e)
+void
- rte_free(struct rte_storage *e, rtable *tab)
++rte_free(struct rte_storage *e)
{
- rt_unlock_source(e->src);
- rta_free(e->attrs);
+ rt_unlock_source(e->rte.src);
+ rta_free(e->rte.attrs);
- sl_free(tab->rte_slab, e);
+ sl_free(e);
}
static int /* Actually better or at least as good as */
if (p->debug & D_ROUTES)
{
if (new && old)
- rte_trace_out(D_ROUTES, c, new, "replaced");
+ channel_rte_trace_out(D_ROUTES, c, new, "replaced");
else if (new)
- rte_trace_out(D_ROUTES, c, new, "added");
+ channel_rte_trace_out(D_ROUTES, c, new, "added");
else if (old)
- rte_trace_out(D_ROUTES, c, old, "removed");
+ channel_rte_trace_out(D_ROUTES, c, old, "removed");
}
- p->rt_notify(p, c, net, new, old);
+ p->rt_notify(p, c, net, new, old_exported ? &old_exported->rte : old);
if (c->out_table && old_exported)
- rte_free(old_exported, c->out_table);
- rte_free_quick(old_exported);
++ rte_free(old_exported);
}
static void
if (old)
{
- if (!new)
+ if (!new_stored)
hmap_clear(&table->id_map, old->id);
- rte_free(old_stored, table);
- rte_free_quick(old);
++ rte_free(old_stored);
}
}
n->routes = new;
}
- /* Announce the new best route */
- if (new != old_best)
- rte_trace_in(D_ROUTES, new->sender, new, "updated [best]");
-
- /* Propagate changes */
- rte_announce_i(tab, RA_UNDEF, n, NULL, NULL, n->routes, old_best);
+ /* Announce the changes */
+ for (int i=0; i<count; i++)
+ {
+ _Bool nb = (new == updates[i].new), ob = (old_best == updates[i].old);
+ const char *best_indicator[2][2] = { { "updated", "updated [-best]" }, { "updated [+best]", "updated [best]" } };
+ rt_rte_trace_in(D_ROUTES, updates[i].new->rte.sender->req, &updates[i].new->rte, best_indicator[nb][ob]);
+ rte_announce_i(tab, n, updates[i].new, updates[i].old, new, old_best);
+ }
- if (free_old_best)
- rte_free_quick(old_best);
+ for (int i=0; i<count; i++)
- rte_free(updates[i].old, tab);
++ rte_free(updates[i].old);
return count;
}
goto drop_update;
}
+ if (!new)
+ CHANNEL_LIMIT_POP(c, RX);
+
/* Move iterator if needed */
- if (old == c->reload_next_rte)
- c->reload_next_rte = old->next;
+ if (*pos == c->reload_next_rte)
+ c->reload_next_rte = (*pos)->next;
/* Remove the old rte */
- *pos = old->next;
- rte_free_quick(old);
+ struct rte_storage *del = *pos;
+ *pos = (*pos)->next;
- rte_free(del, tab);
++ rte_free(del);
tab->rt_count--;
+ }
+ else if (new)
+ {
+ if (CHANNEL_LIMIT_PUSH(c, RX))
+ {
+ /* Required by rte_trace_in() */
+ new->net = n;
- break;
+ channel_rte_trace_in(D_FILTERS, c, new, "ignored [limit]");
+ goto drop_update;
+ }
}
+ else
+ goto drop_withdraw;
if (!new)
{
while (e = *ee)
{
- if (all || (e->flags & (REF_STALE | REF_DISCARD)))
+ if (all || (e->rte.flags & (REF_STALE | REF_DISCARD)))
{
*ee = e->next;
- rte_free(e, t);
- rte_free_quick(e);
++ rte_free(e);
t->rt_count--;
}
else
break;
if (m)
{
- if (krt_uptodate(m, e))
+ if (krt_uptodate(&m->rte, e))
{
krt_trace_in_rl(&rl_alien, p, e, "[alien] seen");
- rte_free(ee, p->krt_table);
- rte_free(e);
- m->pflags |= KRT_REF_SEEN;
++ rte_free(ee);
+ m->rte.pflags |= KRT_REF_SEEN;
}
else
{
ee = &n->routes;
while (e = *ee)
{
- if (e->pflags & KRT_REF_BEST)
+ if (e->rte.pflags & KRT_REF_BEST)
old_best = e;
- if (!(e->pflags & KRT_REF_SEEN))
+ if (!(e->rte.pflags & KRT_REF_SEEN))
{
*ee = e->next;
- rte_free(e, p->krt_table);
+ rte_free(e);
continue;
}
{
if (g)
{
- if (krt_uptodate(g, e))
+ if (krt_uptodate(&g->rte, e))
{
krt_trace_in(p, e, "[alien async] same");
- rte_free(ee, p->krt_table);
- rte_free(e);
++ rte_free(ee);
return;
}
krt_trace_in(p, e, "[alien async] updated");
else if (!g)
{
krt_trace_in(p, e, "[alien async] delete failed");
- rte_free(ee, p->krt_table);
- rte_free(e);
++ rte_free(ee);
return;
}
else
{
krt_trace_in(p, e, "[alien async] removed");
*gg = g->next;
- rte_free(ee, p->krt_table);
- rte_free(g, p->krt_table);
- rte_free(e);
++ rte_free(ee);
+ rte_free(g);
}
best = n->routes;
bestp = &n->routes;