summaryrefslogtreecommitdiff
path: root/proto/babel/babel.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2018-05-03 16:55:11 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2018-05-03 16:55:11 +0200
commit70fab17837dbb4c5848681e4c6b9b90891891130 (patch)
treedbb9bbd89407c03e552bec34933441582c0eec85 /proto/babel/babel.c
parent23b079043bea5899b49a750c4616aff5b332c50d (diff)
Babel: Add option to randomize router ID
When a Babel node restarts, it loses its sequence number, which can cause its routes to be rejected by peers until the state is cleared out by other nodes in the network (which can take on the order of minutes). There are two ways to fix this: Having stable storage to keep the sequence number across restarts, or picking a different router ID each time. This implements the latter, by introducing a new option that will cause BIRD to randomize a high 32 bits of router ID every time it starts up. This avoids the problem at the cost of not having stable router IDs in the network. Thanks to Toke Hoiland-Jorgensen for the patch.
Diffstat (limited to 'proto/babel/babel.c')
-rw-r--r--proto/babel/babel.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index 797a83d4..ce05191c 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -2226,6 +2226,14 @@ babel_init(struct proto_config *CF)
return P;
}
+static inline void
+babel_randomize_router_id(struct babel_proto *p)
+{
+ p->router_id &= (u64) 0xffffffff;
+ p->router_id |= ((u64) random()) << 32;
+ TRACE(D_EVENTS, "Randomized router ID to %lR", p->router_id);
+}
+
static int
babel_start(struct proto *P)
{
@@ -2244,6 +2252,9 @@ babel_start(struct proto *P)
p->update_seqno = 1;
p->router_id = proto_get_router_id(&cf->c);
+ if (cf->randomize_router_id)
+ babel_randomize_router_id(p);
+
p->route_slab = sl_new(P->pool, sizeof(struct babel_route));
p->source_slab = sl_new(P->pool, sizeof(struct babel_source));
p->msg_slab = sl_new(P->pool, sizeof(struct babel_msg_node));