Channel refeed with import table splitting between routes for one prefix

This commit is contained in:
Maria Matejka 2019-08-26 21:53:56 +02:00
parent 5ab3447de1
commit 32a254050d
2 changed files with 27 additions and 10 deletions

View file

@ -537,7 +537,8 @@ struct channel {
struct rtable *in_table; /* Internal table for received routes */ struct rtable *in_table; /* Internal table for received routes */
struct event *reload_event; /* Event responsible for reloading from in_table */ struct event *reload_event; /* Event responsible for reloading from in_table */
struct fib_iterator reload_fit; /* Iterator in in_table used during reloading */ struct fib_iterator reload_fit; /* FIB iterator in in_table used during reloading */
struct rte *reload_next_rte; /* Route iterator in in_table used during reloading */
u8 reload_active; /* Iterator reload_fit is linked */ u8 reload_active; /* Iterator reload_fit is linked */
struct rtable *out_table; /* Internal table for exported routes */ struct rtable *out_table; /* Internal table for exported routes */

View file

@ -2553,6 +2553,10 @@ rte_update_in(struct channel *c, const net_addr *n, rte *new, struct rte_src *sr
goto drop_update; goto drop_update;
} }
/* Move iterator if needed */
if (old == c->reload_next_rte)
c->reload_next_rte = old->next;
/* Remove the old rte */ /* Remove the old rte */
*pos = old->next; *pos = old->next;
rte_free_quick(old); rte_free_quick(old);
@ -2620,21 +2624,32 @@ rt_reload_channel(struct channel *c)
c->reload_active = 1; c->reload_active = 1;
} }
FIB_ITERATE_START(&tab->fib, fit, net, n) do {
for (rte *e = c->reload_next_rte; e; e = e->next)
{ {
if (max_feed <= 0) if (max_feed-- <= 0)
{ {
FIB_ITERATE_PUT(fit); c->reload_next_rte = e;
debug("%s channel reload burst split (max_feed=%d)", c->proto->name, max_feed);
return 0; return 0;
} }
for (rte *e = n->routes; e; e = e->next) rte_update2(c, e->net->n.addr, rte_do_cow(e), e->attrs->src);
}
c->reload_next_rte = NULL;
FIB_ITERATE_START(&tab->fib, fit, net, n)
{ {
rte_update2(c, n->n.addr, rte_do_cow(e), e->attrs->src); if (c->reload_next_rte = n->routes)
max_feed--; {
FIB_ITERATE_PUT_NEXT(fit, &tab->fib);
break;
} }
} }
FIB_ITERATE_END; FIB_ITERATE_END;
}
while (c->reload_next_rte);
c->reload_active = 0; c->reload_active = 0;
return 1; return 1;
@ -2647,6 +2662,7 @@ rt_reload_channel_abort(struct channel *c)
{ {
/* Unlink the iterator */ /* Unlink the iterator */
fit_get(&c->in_table->fib, &c->reload_fit); fit_get(&c->in_table->fib, &c->reload_fit);
c->reload_next_rte = NULL;
c->reload_active = 0; c->reload_active = 0;
} }
} }