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,9 +403,7 @@ main(int argc, char **argv) ...@@ -395,9 +403,7 @@ 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 /* We use all available interfaces here, since this increases the
chances of getting a stable router-id in case the set of Babel chances of getting a stable router-id in case the set of Babel
interfaces changes. */ interfaces changes. */
...@@ -412,13 +418,16 @@ main(int argc, char **argv) ...@@ -412,13 +418,16 @@ main(int argc, char **argv)
if(rc < 0) if(rc < 0)
continue; continue;
memcpy(myid, eui, 8); memcpy(myid, eui, 8);
goto have_id; have_id = 1;
break;
}
} }
if(!have_id) {
if(!random_id)
fprintf(stderr, fprintf(stderr,
"Warning: couldn't find router id -- using random value.\n"); "Warning: couldn't find router id -- "
"using random value.\n");
random_id:
rc = read_random_bytes(myid, 8); rc = read_random_bytes(myid, 8);
if(rc < 0) { if(rc < 0) {
perror("read(random)"); perror("read(random)");
...@@ -426,8 +435,8 @@ main(int argc, char **argv) ...@@ -426,8 +435,8 @@ main(int argc, char **argv)
} }
/* Clear group and global bits */ /* Clear group and global bits */
myid[0] &= ~3; 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