Commit 1dd3b6eb authored by Julien Muchembled's avatar Julien Muchembled

New -F option not to enable forwarding at startup

To be pushed upstream.
parent 8950d3b2
......@@ -100,7 +100,7 @@ int
main(int argc, char **argv)
{
struct sockaddr_in6 sin6;
int rc, fd, i, opt;
int rc, fd, i, opt, setup = 2;
time_t expiry_time, source_expiry_time, kernel_dump_time;
const char **config_files = NULL;
int num_config_files = 0;
......@@ -124,7 +124,7 @@ main(int argc, char **argv)
change_smoothing_half_life(4);
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:sruS:d:g:lwz:M:t:T:c:C:DL:I:F");
if(opt < 0)
break;
......@@ -259,6 +259,9 @@ main(int argc, char **argv)
case 'I':
pidfile = optarg;
break;
case 'F':
setup = 1;
break;
default:
goto usage;
}
......@@ -363,7 +366,7 @@ main(int argc, char **argv)
close(pfd);
}
rc = kernel_setup(1);
rc = kernel_setup(setup);
if(rc < 0) {
fprintf(stderr, "kernel_setup failed.\n");
goto fail_pid;
......@@ -817,7 +820,7 @@ main(int argc, char **argv)
" "
"[-k metric] [-A metric] [-s] [-l] [-w] [-r] [-u] [-g port]\n"
" "
"[-t table] [-T table] [-c file] [-C statement]\n"
"[-F] [-t table] [-T table] [-c file] [-C statement]\n"
" "
"[-d level] [-D] [-L logfile] [-I pidfile]\n"
" "
......
......@@ -99,6 +99,11 @@ Do not flush unfeasible (useless) routes. This is useful in order to
announce more information to a front-end (see
.BR \-g ).
.TP
.B \-F
Assume forwarding is already set, or not wanted. By not touching
net.*.conf.all.forwarding at startup, it is also useful to prevent the
kernel from removing a default IPv6 route provided by autoconfiguration.
.TP
.BI \-d " level"
Debug level. A value of 1 requests a routing table dump at every
iteration through the daemon's main loop. A value of 2 additionally
......
......@@ -502,32 +502,33 @@ kernel_setup(int setup)
}
nl_setup = 1;
old_forwarding = read_proc("/proc/sys/net/ipv6/conf/all/forwarding");
if(old_forwarding < 0) {
perror("Couldn't read forwarding knob.");
return -1;
}
if(setup > 1) {
old_forwarding = read_proc("/proc/sys/net/ipv6/conf/all/forwarding");
if(old_forwarding < 0) {
perror("Couldn't read forwarding knob.");
return -1;
}
rc = write_proc("/proc/sys/net/ipv6/conf/all/forwarding", 1);
if(rc < 0) {
perror("Couldn't write forwarding knob.");
return -1;
}
rc = write_proc("/proc/sys/net/ipv6/conf/all/forwarding", 1);
if(rc < 0) {
perror("Couldn't write forwarding knob.");
return -1;
}
old_ipv4_forwarding =
read_proc("/proc/sys/net/ipv4/conf/all/forwarding");
if(old_ipv4_forwarding < 0) {
perror("Couldn't read IPv4 forwarding knob.");
return -1;
}
old_ipv4_forwarding =
read_proc("/proc/sys/net/ipv4/conf/all/forwarding");
if(old_ipv4_forwarding < 0) {
perror("Couldn't read IPv4 forwarding knob.");
return -1;
}
rc = write_proc("/proc/sys/net/ipv4/conf/all/forwarding", 1);
if(rc < 0) {
perror("Couldn't write IPv4 forwarding knob.");
return -1;
rc = write_proc("/proc/sys/net/ipv4/conf/all/forwarding", 1);
if(rc < 0) {
perror("Couldn't write IPv4 forwarding knob.");
return -1;
}
}
old_accept_redirects =
read_proc("/proc/sys/net/ipv6/conf/all/accept_redirects");
if(old_accept_redirects < 0) {
......
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