mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-17 16:48:43 +00:00
Added debugging of protocol state transitions.
This commit is contained in:
parent
f30b86f9d5
commit
839380d7ec
7
TODO
7
TODO
@ -1,5 +1,11 @@
|
|||||||
Core
|
Core
|
||||||
~~~~
|
~~~~
|
||||||
|
- debug: interfaces
|
||||||
|
- debug: route updates
|
||||||
|
- debug: static
|
||||||
|
- debug: pipe
|
||||||
|
- debug: krt
|
||||||
|
|
||||||
- static: check validity of route destination?
|
- static: check validity of route destination?
|
||||||
- static: allow specifying a per-route filter program for setting route attributes?
|
- static: allow specifying a per-route filter program for setting route attributes?
|
||||||
|
|
||||||
@ -12,6 +18,7 @@ Core
|
|||||||
|
|
||||||
Commands
|
Commands
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
- show status
|
||||||
- showing of routing table as seen by given protocol
|
- showing of routing table as seen by given protocol
|
||||||
- printing of dynamic attributes
|
- printing of dynamic attributes
|
||||||
|
|
||||||
|
12
nest/proto.c
12
nest/proto.c
@ -33,6 +33,8 @@ static list proto_list;
|
|||||||
struct proto *p = SKIP_BACK(struct proto, glob_node, nn);
|
struct proto *p = SKIP_BACK(struct proto, glob_node, nn);
|
||||||
#define WALK_PROTO_LIST_END } } while(0)
|
#define WALK_PROTO_LIST_END } } while(0)
|
||||||
|
|
||||||
|
#define PD(pr, msg, args...) do { if (pr->debug & D_STATES) { log(L_TRACE "%s: " msg, pr->name , ## args); } } while(0)
|
||||||
|
|
||||||
list active_proto_list;
|
list active_proto_list;
|
||||||
static list inactive_proto_list;
|
static list inactive_proto_list;
|
||||||
static list initial_proto_list;
|
static list initial_proto_list;
|
||||||
@ -45,6 +47,7 @@ static char *c_states[] = { "HUNGRY", "FEEDING", "HAPPY", "FLUSHING" };
|
|||||||
|
|
||||||
static int proto_flush_all(void *);
|
static int proto_flush_all(void *);
|
||||||
static void proto_rethink_goal(struct proto *p);
|
static void proto_rethink_goal(struct proto *p);
|
||||||
|
static char *proto_state_name(struct proto *p);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
proto_enqueue(list *l, struct proto *p)
|
proto_enqueue(list *l, struct proto *p)
|
||||||
@ -58,6 +61,7 @@ proto_relink(struct proto *p)
|
|||||||
{
|
{
|
||||||
list *l;
|
list *l;
|
||||||
|
|
||||||
|
PD(p, "State changed to %s", proto_state_name(p));
|
||||||
rem_node(&p->n);
|
rem_node(&p->n);
|
||||||
switch (p->core_state)
|
switch (p->core_state)
|
||||||
{
|
{
|
||||||
@ -112,6 +116,7 @@ proto_add_announce_hook(struct proto *p, struct rtable *t)
|
|||||||
if (!p->rt_notify)
|
if (!p->rt_notify)
|
||||||
return NULL;
|
return NULL;
|
||||||
DBG("Connecting protocol %s to table %s\n", p->name, t->name);
|
DBG("Connecting protocol %s to table %s\n", p->name, t->name);
|
||||||
|
PD(p, "Connected to table %s", t->name);
|
||||||
h = mb_alloc(p->pool, sizeof(struct announce_hook));
|
h = mb_alloc(p->pool, sizeof(struct announce_hook));
|
||||||
h->table = t;
|
h->table = t;
|
||||||
h->proto = p;
|
h->proto = p;
|
||||||
@ -142,6 +147,7 @@ proto_config_new(struct protocol *pr, unsigned size)
|
|||||||
c->name = pr->name;
|
c->name = pr->name;
|
||||||
c->out_filter = FILTER_REJECT;
|
c->out_filter = FILTER_REJECT;
|
||||||
c->table = c->global->master_rtc;
|
c->table = c->global->master_rtc;
|
||||||
|
c->debug = new_config->proto_default_debug;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +195,7 @@ proto_init(struct proto_config *c)
|
|||||||
q->core_state = FS_HUNGRY;
|
q->core_state = FS_HUNGRY;
|
||||||
proto_enqueue(&initial_proto_list, q);
|
proto_enqueue(&initial_proto_list, q);
|
||||||
add_tail(&proto_list, &q->glob_node);
|
add_tail(&proto_list, &q->glob_node);
|
||||||
|
PD(q, "Initializing");
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,6 +230,7 @@ protos_commit(struct config *new, struct config *old, int force_reconfig)
|
|||||||
if (p->proto->reconfigure && p->proto->reconfigure(p, nc))
|
if (p->proto->reconfigure && p->proto->reconfigure(p, nc))
|
||||||
{
|
{
|
||||||
DBG("\t%s: same\n", oc->name);
|
DBG("\t%s: same\n", oc->name);
|
||||||
|
PD(p, "Reconfigured");
|
||||||
p->cf = nc;
|
p->cf = nc;
|
||||||
p->name = nc->name;
|
p->name = nc->name;
|
||||||
nc->proto = p;
|
nc->proto = p;
|
||||||
@ -231,12 +239,14 @@ protos_commit(struct config *new, struct config *old, int force_reconfig)
|
|||||||
}
|
}
|
||||||
/* Unsuccessful, force reconfig */
|
/* Unsuccessful, force reconfig */
|
||||||
DBG("\t%s: power cycling\n", oc->name);
|
DBG("\t%s: power cycling\n", oc->name);
|
||||||
|
PD(p, "Reconfiguration failed, restarting");
|
||||||
p->cf_new = nc;
|
p->cf_new = nc;
|
||||||
nc->proto = p;
|
nc->proto = p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBG("\t%s: deleting\n", oc->name);
|
DBG("\t%s: deleting\n", oc->name);
|
||||||
|
PD(p, "Unconfigured");
|
||||||
p->cf_new = NULL;
|
p->cf_new = NULL;
|
||||||
}
|
}
|
||||||
p->reconfiguring = 1;
|
p->reconfiguring = 1;
|
||||||
@ -291,6 +301,7 @@ proto_rethink_goal(struct proto *p)
|
|||||||
if (p->core_state == FS_HUNGRY && p->proto_state == PS_DOWN)
|
if (p->core_state == FS_HUNGRY && p->proto_state == PS_DOWN)
|
||||||
{
|
{
|
||||||
DBG("Kicking %s up\n", p->name);
|
DBG("Kicking %s up\n", p->name);
|
||||||
|
PD(p, "Starting");
|
||||||
proto_init_instance(p);
|
proto_init_instance(p);
|
||||||
proto_notify_state(p, (q->start ? q->start(p) : PS_UP));
|
proto_notify_state(p, (q->start ? q->start(p) : PS_UP));
|
||||||
}
|
}
|
||||||
@ -300,6 +311,7 @@ proto_rethink_goal(struct proto *p)
|
|||||||
if (p->proto_state == PS_START || p->proto_state == PS_UP)
|
if (p->proto_state == PS_START || p->proto_state == PS_UP)
|
||||||
{
|
{
|
||||||
DBG("Kicking %s down\n", p->name);
|
DBG("Kicking %s down\n", p->name);
|
||||||
|
PD(p, "Shutting down");
|
||||||
proto_notify_state(p, (q->shutdown ? q->shutdown(p) : PS_DOWN));
|
proto_notify_state(p, (q->shutdown ? q->shutdown(p) : PS_DOWN));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user