Commit c111f9f7 authored by Toke Høiland-Jørgensen's avatar Toke Høiland-Jørgensen Committed by Juliusz Chroboczek

Add configuration flag to skip initial kernel setup.

This adds a configuration flag to skip kernel (sysctl) setup on daemon
startup. This can be useful if running in, e.g., a container environment
where setting sysctls are not allowed.
Signed-off-by: default avatarToke Høiland-Jørgensen <toke@toke.dk>
parent 67984ffa
...@@ -67,6 +67,7 @@ int default_wired_hello_interval = -1; ...@@ -67,6 +67,7 @@ int default_wired_hello_interval = -1;
int resend_delay = -1; int resend_delay = -1;
int random_id = 0; int random_id = 0;
int do_daemonise = 0; int do_daemonise = 0;
int skip_kernel_setup = 0;
const char *logfile = NULL, const char *logfile = NULL,
*pidfile = "/var/run/babeld.pid", *pidfile = "/var/run/babeld.pid",
*state_file = "/var/lib/babel-state"; *state_file = "/var/lib/babel-state";
......
...@@ -86,6 +86,7 @@ extern time_t reboot_time; ...@@ -86,6 +86,7 @@ extern time_t reboot_time;
extern int default_wireless_hello_interval, default_wired_hello_interval; extern int default_wireless_hello_interval, default_wired_hello_interval;
extern int resend_delay; extern int resend_delay;
extern int random_id; extern int random_id;
extern int skip_kernel_setup;
extern int do_daemonise; extern int do_daemonise;
extern const char *logfile, *pidfile, *state_file; extern const char *logfile, *pidfile, *state_file;
extern int link_detect; extern int link_detect;
......
...@@ -253,6 +253,11 @@ This specifies whether to daemonize at startup, and is equivalent to ...@@ -253,6 +253,11 @@ This specifies whether to daemonize at startup, and is equivalent to
the command-line option the command-line option
.BR \-D . .BR \-D .
.TP .TP
.BR skip-kernel-setup " {" true | false }
If this flag is set, no kernel (sysctl) setup is performed on startup. This can
be useful when running in environments where system permissions prevent setting
kernel parameters, for instance inside a Linux container.
.TP
.BI state-file " filename" .BI state-file " filename"
This specifies the name of the file used for preserving long-term This specifies the name of the file used for preserving long-term
information between invocations of the information between invocations of the
......
...@@ -691,6 +691,7 @@ parse_option(int c, gnc_t gnc, void *closure, char *token) ...@@ -691,6 +691,7 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
strcmp(token, "link-detect") == 0 || strcmp(token, "link-detect") == 0 ||
strcmp(token, "random-id") == 0 || strcmp(token, "random-id") == 0 ||
strcmp(token, "daemonise") == 0 || strcmp(token, "daemonise") == 0 ||
strcmp(token, "skip-kernel-setup") == 0 ||
strcmp(token, "ipv6-subtrees") == 0 || strcmp(token, "ipv6-subtrees") == 0 ||
strcmp(token, "reflect-kernel-metric") == 0) { strcmp(token, "reflect-kernel-metric") == 0) {
int b; int b;
...@@ -706,6 +707,8 @@ parse_option(int c, gnc_t gnc, void *closure, char *token) ...@@ -706,6 +707,8 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
random_id = b; random_id = b;
else if(strcmp(token, "daemonise") == 0) else if(strcmp(token, "daemonise") == 0)
do_daemonise = b; do_daemonise = b;
else if(strcmp(token, "skip-kernel-setup") == 0)
skip_kernel_setup = b;
else if(strcmp(token, "ipv6-subtrees") == 0) else if(strcmp(token, "ipv6-subtrees") == 0)
has_ipv6_subtrees = b; has_ipv6_subtrees = b;
else if(strcmp(token, "reflect-kernel-metric") == 0) else if(strcmp(token, "reflect-kernel-metric") == 0)
......
...@@ -514,6 +514,7 @@ kernel_setup(int setup) ...@@ -514,6 +514,7 @@ kernel_setup(int setup)
} }
nl_setup = 1; nl_setup = 1;
if(skip_kernel_setup) return 1;
for(i=0; i<NUM_SYSCTLS; i++) { for(i=0; i<NUM_SYSCTLS; i++) {
s = &sysctl_settings[i]; s = &sysctl_settings[i];
...@@ -541,6 +542,8 @@ kernel_setup(int setup) ...@@ -541,6 +542,8 @@ kernel_setup(int setup)
nl_command.sock = -1; nl_command.sock = -1;
nl_setup = 0; nl_setup = 0;
if(skip_kernel_setup) return 1;
for(i=0; i<NUM_SYSCTLS; i++) { for(i=0; i<NUM_SYSCTLS; i++) {
s = &sysctl_settings[i]; s = &sysctl_settings[i];
if(s->was && s->was != s->want) { if(s->was && s->was != s->want) {
......
...@@ -214,6 +214,8 @@ kernel_setup(int setup) ...@@ -214,6 +214,8 @@ kernel_setup(int setup)
int mib[4]; int mib[4];
size_t datasize; size_t datasize;
if(skip_kernel_setup) return 1;
mib[0] = CTL_NET; mib[0] = CTL_NET;
mib[1] = AF_INET6; mib[1] = AF_INET6;
seq = time(NULL); seq = time(NULL);
......
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