summaryrefslogtreecommitdiffstats
path: root/nest/iface.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1998-10-19 20:13:36 +0200
committerMartin Mares <mj@ucw.cz>1998-10-19 20:13:36 +0200
commit7d8329078066b5682a0330b20dbdf74c7a01cbac (patch)
tree10893b4eef8fd178460a7ae2d2bc3106179bb3c3 /nest/iface.c
parent08045252553478457f923a9f941675df9992f507 (diff)
downloadbird-7d8329078066b5682a0330b20dbdf74c7a01cbac.tar
bird-7d8329078066b5682a0330b20dbdf74c7a01cbac.zip
Generate router_id automatically if possible (standard "smallest of local
regular interface addresses" rule). Protocols should NOT rely on router_id existence -- when router ID is not available, the router_id variable is set to zero and protocols requiring valid router ID should just refuse to start, reporting such error to the log.
Diffstat (limited to 'nest/iface.c')
-rw-r--r--nest/iface.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/nest/iface.c b/nest/iface.c
index f6f33a9..5f356fd 100644
--- a/nest/iface.c
+++ b/nest/iface.c
@@ -15,6 +15,8 @@
static pool *if_pool;
+u32 router_id;
+
/*
* Neighbor Cache
*
@@ -196,7 +198,7 @@ if_dump_all(void)
debug("Known network interfaces:\n");
WALK_LIST(i, iface_list)
if_dump(i);
- debug("\n");
+ debug("\nRouter ID: %08x\n\n", router_id);
}
static inline int
@@ -325,6 +327,25 @@ if_feed_baby(struct proto *p)
}
void
+auto_router_id(void) /* FIXME: What if we run IPv6??? */
+{
+ struct iface *i, *j;
+
+ if (router_id)
+ return;
+ j = NULL;
+ WALK_LIST(i, iface_list)
+ if ((i->flags & IF_UP) &&
+ !(i->flags & (IF_UNNUMBERED | IF_LOOPBACK | IF_IGNORE)) &&
+ (!j || ipa_to_u32(i->ip) < ipa_to_u32(j->ip)))
+ j = i;
+ if (!j) /* FIXME: allow configuration or running without RID */
+ die("Cannot determine router ID, please configure manually");
+ router_id = ipa_to_u32(j->ip);
+ debug("Router ID set to %08x (%s)\n", router_id, j->name);
+}
+
+void
if_init(void)
{
if_pool = rp_new(&root_pool, "Interfaces");