Introduced protocol priority (all 'normal' protocols should use the
default zero priority). No more "kernel syncer initialized before device routes" problems.
This commit is contained in:
parent
84c7e1943f
commit
b2280748ad
3 changed files with 22 additions and 3 deletions
23
nest/proto.c
23
nest/proto.c
|
@ -37,6 +37,22 @@ static char *c_states[] = { "HUNGRY", "FEEDING", "HAPPY", "FLUSHING" };
|
||||||
|
|
||||||
static void proto_flush_all(void *);
|
static void proto_flush_all(void *);
|
||||||
|
|
||||||
|
static void
|
||||||
|
proto_enqueue(list *l, struct proto *p)
|
||||||
|
{
|
||||||
|
int pri = p->proto->priority;
|
||||||
|
|
||||||
|
if (!pri)
|
||||||
|
add_tail(l, &p->n);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct proto *q = HEAD(*l);
|
||||||
|
while (q->n.next && q->proto->priority >= pri)
|
||||||
|
q = (struct proto *) q->n.next;
|
||||||
|
insert_node(&p->n, q->n.prev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
proto_relink(struct proto *p)
|
proto_relink(struct proto *p)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +70,7 @@ proto_relink(struct proto *p)
|
||||||
default:
|
default:
|
||||||
l = &inactive_proto_list;
|
l = &inactive_proto_list;
|
||||||
}
|
}
|
||||||
add_tail(l, &p->n);
|
proto_enqueue(l, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
@ -146,7 +162,7 @@ protos_commit(struct config *c)
|
||||||
q = p->init(x);
|
q = p->init(x);
|
||||||
q->proto_state = PS_DOWN;
|
q->proto_state = PS_DOWN;
|
||||||
q->core_state = FS_HUNGRY;
|
q->core_state = FS_HUNGRY;
|
||||||
add_tail(&initial_proto_list, &q->n);
|
proto_enqueue(&initial_proto_list, q);
|
||||||
}
|
}
|
||||||
debug("\n");
|
debug("\n");
|
||||||
}
|
}
|
||||||
|
@ -224,7 +240,8 @@ protos_dump_all(void)
|
||||||
|
|
||||||
WALK_LIST(p, proto_list)
|
WALK_LIST(p, proto_list)
|
||||||
{
|
{
|
||||||
debug(" protocol %s: state %s/%s\n", p->name, p_states[p->proto_state], c_states[p->core_state]);
|
debug(" protocol %s (pri=%d): state %s/%s\n", p->name, p->proto->priority,
|
||||||
|
p_states[p->proto_state], c_states[p->core_state]);
|
||||||
if (p->disabled)
|
if (p->disabled)
|
||||||
debug("\tDISABLED\n");
|
debug("\tDISABLED\n");
|
||||||
else if (p->proto->dump)
|
else if (p->proto->dump)
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct protocol {
|
||||||
node n;
|
node n;
|
||||||
char *name;
|
char *name;
|
||||||
unsigned debug; /* Default debugging flags */
|
unsigned debug; /* Default debugging flags */
|
||||||
|
int priority; /* Protocol priority (usually 0) */
|
||||||
|
|
||||||
void (*preconfig)(struct protocol *, struct config *); /* Just before configuring */
|
void (*preconfig)(struct protocol *, struct config *); /* Just before configuring */
|
||||||
void (*postconfig)(struct proto_config *); /* After configuring each instance */
|
void (*postconfig)(struct proto_config *); /* After configuring each instance */
|
||||||
|
|
|
@ -92,6 +92,7 @@ dev_preconfig(struct protocol *x, struct config *c)
|
||||||
|
|
||||||
struct protocol proto_device = {
|
struct protocol proto_device = {
|
||||||
name: "Device",
|
name: "Device",
|
||||||
|
priority: 100,
|
||||||
preconfig: dev_preconfig,
|
preconfig: dev_preconfig,
|
||||||
init: dev_init,
|
init: dev_init,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue