p->preference = c->preference;
p->disabled = c->disabled;
p->proto = pr;
- p->table = (c->table ? : c->global->master_rtc)->table;
+ p->table = c->table->table;
p->in_filter = c->in_filter;
p->out_filter = c->out_filter;
return p;
c->debug = pr->debug;
c->name = pr->name;
c->out_filter = FILTER_REJECT;
+ c->table = c->global->master_rtc;
return c;
}
q->proto_state = PS_DOWN;
q->core_state = FS_HUNGRY;
proto_enqueue(&initial_proto_list, q);
+ /*
+ * HACK ALERT! In case of multiple kernel routing tables,
+ * the kernel syncer acts as multiple protocols which cooperate
+ * with each other. In order to speed up their initialization,
+ * we need to know when we're initializing the last one, hence
+ * the startup counter.
+ */
+ if (!q->disabled)
+ p->startup_counter++;
}
debug("\n");
}
if (p->core_state == FS_HUNGRY && p->proto_state == PS_DOWN)
{
DBG("Kicking %s up\n", p->name);
+ ASSERT(q->startup_counter > 0);
+ q->startup_counter--;
proto_init_instance(p);
proto_notify_state(p, (q->start ? q->start(p) : PS_UP));
}
struct proto *p, *n;
debug("Protocol shutdown\n");
- WALK_LIST_DELSAFE(p, n, inactive_proto_list)
+ WALK_LIST_BACKWARDS_DELSAFE(p, n, inactive_proto_list)
if (p->core_state != FS_HUNGRY || p->proto_state != PS_DOWN)
{
proto_shutdown_counter++;
proto_set_goal(p, FS_HUNGRY);
}
- WALK_LIST_DELSAFE(p, n, proto_list)
+ WALK_LIST_BACKWARDS_DELSAFE(p, n, proto_list)
{
proto_shutdown_counter++;
proto_set_goal(p, FS_HUNGRY);
{
schedule_flush:
DBG("%s: Scheduling flush\n", p->name);
+ proto_flush_hooks(p);
cs = FS_FLUSHING;
ev_schedule(proto_flush_event);
}
while ((p = HEAD(flush_proto_list))->n.next)
{
DBG("Flushing protocol %s\n", p->name);
- proto_flush_hooks(p);
rfree(p->pool);
p->pool = NULL;
p->core_state = FS_HUNGRY;