summaryrefslogtreecommitdiffstats
path: root/nest/proto.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-03-03 20:33:54 +0100
committerMartin Mares <mj@ucw.cz>1999-03-03 20:33:54 +0100
commitb2280748ad5087b5dab54dd4e423053ffe1f2387 (patch)
tree90997ee7e125ed00a7bc113e68676014f23bd43c /nest/proto.c
parent84c7e1943f0dbf896b1dd8d02a21120aa00463f4 (diff)
downloadbird-b2280748ad5087b5dab54dd4e423053ffe1f2387.tar
bird-b2280748ad5087b5dab54dd4e423053ffe1f2387.zip
Introduced protocol priority (all 'normal' protocols should use the
default zero priority). No more "kernel syncer initialized before device routes" problems.
Diffstat (limited to 'nest/proto.c')
-rw-r--r--nest/proto.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/nest/proto.c b/nest/proto.c
index 21f3630..76120fa 100644
--- a/nest/proto.c
+++ b/nest/proto.c
@@ -38,6 +38,22 @@ static char *c_states[] = { "HUNGRY", "FEEDING", "HAPPY", "FLUSHING" };
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
proto_relink(struct proto *p)
{
list *l;
@@ -54,7 +70,7 @@ proto_relink(struct proto *p)
default:
l = &inactive_proto_list;
}
- add_tail(l, &p->n);
+ proto_enqueue(l, p);
}
void *
@@ -146,7 +162,7 @@ protos_commit(struct config *c)
q = p->init(x);
q->proto_state = PS_DOWN;
q->core_state = FS_HUNGRY;
- add_tail(&initial_proto_list, &q->n);
+ proto_enqueue(&initial_proto_list, q);
}
debug("\n");
}
@@ -224,7 +240,8 @@ protos_dump_all(void)
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)
debug("\tDISABLED\n");
else if (p->proto->dump)