Commit 865bb88f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Add ability to specify router-id explicitly on the command-line.

There is no equivalent config-file option, since I'm worried about config
files being copied between nodes.
parent 19b6b01e
babeld-1.6.2 (unreleased) babeld-1.6.2 (unreleased)
* Added the ability to specify a router-id explicitly (-R).
* Changed router-id computation to use all interfaces, which increases * Changed router-id computation to use all interfaces, which increases
the chances of a stable id. the chances of a stable id.
* Changed the format of babel-state to only contain the seqno -- the * Changed the format of babel-state to only contain the seqno -- the
......
...@@ -56,6 +56,7 @@ THE SOFTWARE. ...@@ -56,6 +56,7 @@ THE SOFTWARE.
struct timeval now; struct timeval now;
unsigned char myid[8]; unsigned char myid[8];
int have_id = 0;
int debug = 0; int debug = 0;
int link_detect = 0; int link_detect = 0;
...@@ -126,7 +127,8 @@ main(int argc, char **argv) ...@@ -126,7 +127,8 @@ main(int argc, char **argv)
has_ipv6_subtrees = kernel_has_ipv6_subtrees(); has_ipv6_subtrees = kernel_has_ipv6_subtrees();
while(1) { while(1) {
opt = getopt(argc, argv, "m:p:h:H:i:k:A:sruS:d:g:lwz:M:t:T:c:C:DL:I:"); opt = getopt(argc, argv,
"m:p:h:H:i:k:A:srR:uS:d:g:lwz:M:t:T:c:C:DL:I:");
if(opt < 0) if(opt < 0)
break; break;
...@@ -179,6 +181,12 @@ main(int argc, char **argv) ...@@ -179,6 +181,12 @@ main(int argc, char **argv)
case 'r': case 'r':
random_id = 1; random_id = 1;
break; break;
case 'R':
rc = parse_eui64(optarg, myid);
if(rc < 0)
goto usage;
have_id = 1;
break;
case 'u': case 'u':
keep_unfeasible = 1; keep_unfeasible = 1;
break; break;
...@@ -395,39 +403,40 @@ main(int argc, char **argv) ...@@ -395,39 +403,40 @@ main(int argc, char **argv)
goto fail; goto fail;
} }
if(random_id) if(!have_id && !random_id) {
goto random_id; /* We use all available interfaces here, since this increases the
chances of getting a stable router-id in case the set of Babel
interfaces changes. */
/* We use all available interfaces here, since this increases the for(i = 1; i < 256; i++) {
chances of getting a stable router-id in case the set of Babel char buf[IF_NAMESIZE], *ifname;
interfaces changes. */ unsigned char eui[8];
ifname = if_indextoname(i, buf);
for(i = 1; i < 256; i++) { if(ifname == NULL)
char buf[IF_NAMESIZE], *ifname; continue;
unsigned char eui[8]; rc = if_eui64(ifname, i, eui);
ifname = if_indextoname(i, buf); if(rc < 0)
if(ifname == NULL) continue;
continue; memcpy(myid, eui, 8);
rc = if_eui64(ifname, i, eui); have_id = 1;
if(rc < 0) break;
continue; }
memcpy(myid, eui, 8);
goto have_id;
} }
fprintf(stderr, if(!have_id) {
"Warning: couldn't find router id -- using random value.\n"); if(!random_id)
fprintf(stderr,
random_id: "Warning: couldn't find router id -- "
rc = read_random_bytes(myid, 8); "using random value.\n");
if(rc < 0) { rc = read_random_bytes(myid, 8);
perror("read(random)"); if(rc < 0) {
goto fail; perror("read(random)");
goto fail;
}
/* Clear group and global bits */
myid[0] &= ~3;
} }
/* Clear group and global bits */
myid[0] &= ~3;
have_id:
myseqno = (random() & 0xFFFF); myseqno = (random() & 0xFFFF);
fd = open(state_file, O_RDONLY); fd = open(state_file, O_RDONLY);
......
...@@ -94,6 +94,11 @@ derived from the MAC address of the first interface, which is easier ...@@ -94,6 +94,11 @@ derived from the MAC address of the first interface, which is easier
to debug and more reliably prevents routing loops but may sometimes to debug and more reliably prevents routing loops but may sometimes
cause a node to be unreachable for 120 seconds just after boot. cause a node to be unreachable for 120 seconds just after boot.
.TP .TP
.BI \-R " router-id"
Specify the router-id explicitly, as a modified EUI-64 or a MAC-48
address. If two nodes have the same router-id, bad things will happen.
Don't use this option unless you know what you are doing.
.TP
.B \-u .B \-u
Do not flush unfeasible (useless) routes. This is useful in order to Do not flush unfeasible (useless) routes. This is useful in order to
announce more information to a front-end (see announce more information to a front-end (see
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment