diff options
Diffstat (limited to 'proto')
-rw-r--r-- | proto/babel/babel.c | 11 | ||||
-rw-r--r-- | proto/babel/babel.h | 1 | ||||
-rw-r--r-- | proto/babel/config.Y | 3 |
3 files changed, 14 insertions, 1 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)); diff --git a/proto/babel/babel.h b/proto/babel/babel.h index b194ce30..e5c9cd5b 100644 --- a/proto/babel/babel.h +++ b/proto/babel/babel.h @@ -112,6 +112,7 @@ struct babel_config { struct proto_config c; list iface_list; /* List of iface configs (struct babel_iface_config) */ uint hold_time; /* Time to hold stale entries and unreachable routes */ + u8 randomize_router_id; struct channel_config *ip4_channel; struct channel_config *ip6_channel; diff --git a/proto/babel/config.Y b/proto/babel/config.Y index 7adfb4bb..205b4e4f 100644 --- a/proto/babel/config.Y +++ b/proto/babel/config.Y @@ -25,7 +25,7 @@ CF_DECLS CF_KEYWORDS(BABEL, INTERFACE, METRIC, RXCOST, HELLO, UPDATE, INTERVAL, PORT, TYPE, WIRED, WIRELESS, RX, TX, BUFFER, PRIORITY, LENGTH, CHECK, LINK, NEXT, HOP, IPV4, IPV6, BABEL_METRIC, SHOW, INTERFACES, NEIGHBORS, - ENTRIES) + ENTRIES, RANDOMIZE, ROUTER, ID) CF_GRAMMAR @@ -42,6 +42,7 @@ babel_proto_item: proto_item | proto_channel | INTERFACE babel_iface + | RANDOMIZE ROUTER ID bool { BABEL_CFG->randomize_router_id = $4; } ; babel_proto_opts: |