}
}
+void
+if_feed_baby(struct proto *p)
+{
+ struct iface *i;
+
+ if (!p->if_notify)
+ return;
+ debug("Announcing interfaces to new protocol %s\n", p->name);
+ WALK_LIST(i, iface_list)
+ p->if_notify(p, IF_CHANGE_CREATE | ((i->flags & IF_UP) ? IF_CHANGE_UP : 0), NULL, i);
+}
+
void
if_init(void)
{
extern list iface_list;
+struct proto;
+
struct iface {
node n;
char name[16];
void if_dump_all(void);
void if_update(struct iface *);
void if_end_update(void);
+void if_feed_baby(struct proto *);
/*
* Neighbor Cache. We hold (direct neighbor, protocol) pairs we've seen
#include "lib/resource.h"
#include "lib/lists.h"
#include "nest/confile.h"
+#include "nest/route.h"
+#include "nest/iface.h"
list protocol_list;
list proto_list;
+list inactive_proto_list;
void *
proto_new(struct protocol *pr, unsigned size)
p->name = pr->name;
p->debug = pr->debug;
p->pool = rp_new(&root_pool, pr->name);
- add_tail(&proto_list, &p->n);
+ add_tail(&inactive_proto_list, &p->n);
return p;
}
struct protocol *p;
init_list(&proto_list);
+ init_list(&inactive_proto_list);
debug("Protocol preconfig\n");
WALK_LIST(p, protocol_list)
{
}
}
+static void
+proto_start(struct proto *p)
+{
+ rem_node(&p->n);
+ if (p->start)
+ p->start(p);
+ if_feed_baby(p);
+ rt_feed_baby(p);
+ add_tail(&proto_list, &p->n);
+}
void
protos_start(void)
{
- struct proto *p;
+ struct proto *p, *n;
debug("Protocol start\n");
- WALK_LIST(p, proto_list)
+ WALK_LIST_DELSAFE(p, n, inactive_proto_list)
{
debug("...%s\n", p->name);
- if (p->start)
- p->start(p);
+ proto_start(p);
}
}
if (p->dump)
p->dump(p);
}
+ WALK_LIST(p, inactive_proto_list)
+ debug(" inactive %s\n", p->name);
}
void
unsigned debug; /* Debugging flags */
pool *pool; /* Local objects */
unsigned preference; /* Default route preference */
+ int ready; /* Already initialized */
void (*if_notify)(struct proto *, unsigned flags, struct iface *new, struct iface *old);
void (*rt_notify)(struct proto *, struct network *net, struct rte *new, struct rte *old);
void *proto_new(struct protocol *, unsigned size);
-extern list proto_list;
+extern list proto_list, inactive_proto_list;
#endif
void rte_dump(net *, rte *);
void rt_dump(rtable *);
void rt_dump_all(void);
+void rt_feed_baby(struct proto *p);
/*
* Route Attributes
p->rt_notify(p, net, new, old);
}
+void
+rt_feed_baby(struct proto *p)
+{
+ rtable *t = &master_table;
+
+ if (!p->rt_notify)
+ return;
+ debug("Announcing routes to new protocol %s\n", p->name);
+ while (t)
+ {
+ FIB_WALK(&t->fib, fn)
+ {
+ net *n = (net *) fn;
+ rte *e;
+ for(e=n->routes; e; e=e->next)
+ p->rt_notify(p, n, e, NULL);
+ }
+ FIB_WALK_END;
+ t = t->sibling;
+ }
+}
+
static inline void
rte_free(rte *e)
{
signal_init();
- protos_start();
-
scan_if_init();
+ protos_start();
+
handle_sigusr(0);
debug("Entering I/O loop.\n");