Commit 4ab89604 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement random router-ids (-r).

parent 69348bb2
...@@ -100,7 +100,7 @@ int ...@@ -100,7 +100,7 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
struct sockaddr_in6 sin6; struct sockaddr_in6 sin6;
int rc, fd, i, opt; int rc, fd, i, opt, random_id = 0;
time_t expiry_time, source_expiry_time, kernel_dump_time; time_t expiry_time, source_expiry_time, kernel_dump_time;
char *config_file = NULL; char *config_file = NULL;
void *vrc; void *vrc;
...@@ -123,7 +123,7 @@ main(int argc, char **argv) ...@@ -123,7 +123,7 @@ main(int argc, char **argv)
change_smoothing_half_life(4); change_smoothing_half_life(4);
while(1) { while(1) {
opt = getopt(argc, argv, "m:p:h:H:i:k:A:suS:d:g:lwz:M:t:T:c:C:DL:I:"); opt = getopt(argc, argv, "m:p:h:H:i:k:A:sruS:d:g:lwz:M:t:T:c:C:DL:I:");
if(opt < 0) if(opt < 0)
break; break;
...@@ -173,6 +173,9 @@ main(int argc, char **argv) ...@@ -173,6 +173,9 @@ main(int argc, char **argv)
case 's': case 's':
split_horizon = 0; split_horizon = 0;
break; break;
case 'r':
random_id = 1;
break;
case 'u': case 'u':
keep_unfeasible = 1; keep_unfeasible = 1;
break; break;
...@@ -377,6 +380,9 @@ main(int argc, char **argv) ...@@ -377,6 +380,9 @@ main(int argc, char **argv)
goto fail; goto fail;
} }
if(random_id)
goto random_id;
FOR_ALL_INTERFACES(ifp) { FOR_ALL_INTERFACES(ifp) {
/* ifp->ifindex is not necessarily valid at this point */ /* ifp->ifindex is not necessarily valid at this point */
int ifindex = if_nametoindex(ifp->name); int ifindex = if_nametoindex(ifp->name);
...@@ -408,6 +414,7 @@ main(int argc, char **argv) ...@@ -408,6 +414,7 @@ main(int argc, char **argv)
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)");
...@@ -452,7 +459,7 @@ main(int argc, char **argv) ...@@ -452,7 +459,7 @@ main(int argc, char **argv)
gettimeofday(&realnow, NULL); gettimeofday(&realnow, NULL);
if(memcmp(sid, myid, 8) == 0) if(memcmp(sid, myid, 8) == 0)
myseqno = seqno_plus(s, 1); myseqno = seqno_plus(s, 1);
else else if(!random_id)
fprintf(stderr, "ID mismatch in babel-state.\n"); fprintf(stderr, "ID mismatch in babel-state.\n");
} }
} else { } else {
...@@ -787,7 +794,7 @@ main(int argc, char **argv) ...@@ -787,7 +794,7 @@ main(int argc, char **argv)
" " " "
"[-h hello] [-H wired_hello] [-z kind[,factor]]\n" "[-h hello] [-H wired_hello] [-z kind[,factor]]\n"
" " " "
"[-k metric] [-A metric] [-s] [-l] [-w] [-u] [-g port]\n" "[-k metric] [-A metric] [-s] [-l] [-w] [-r] [-u] [-g port]\n"
" " " "
"[-t table] [-T table] [-c file] [-C statement]\n" "[-t table] [-T table] [-c file] [-C statement]\n"
" " " "
......
...@@ -88,6 +88,12 @@ explicitly overridden in the configuration file. ...@@ -88,6 +88,12 @@ explicitly overridden in the configuration file.
Do not perform split-horizon processing on wired interfaces. Do not perform split-horizon processing on wired interfaces.
Split-horizon is not performed on wireless interfaces. Split-horizon is not performed on wireless interfaces.
.TP .TP
.B \-r
Use a random router-id. The default is to use persistent router-ids
derived from the MAC address of the first interface, which is easier
to debug and more reliably prevents routing loops but may sometimes
cause a node to be unreachable for 120 seconds just after boot.
.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