Skip to content

Commit

Permalink
Make the kernel dump interval configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jech authored and jkilpatr committed Jun 27, 2023
1 parent 08b8512 commit d360465
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
10 changes: 6 additions & 4 deletions babeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static int kernel_routes_changed = 0;
static int kernel_rules_changed = 0;
static int kernel_link_changed = 0;
static int kernel_addr_changed = 0;
int kernel_check_interval = 300;

struct timeval check_neighbours_timeout, check_interfaces_timeout;

Expand Down Expand Up @@ -603,7 +604,7 @@ main(int argc, char **argv)
kernel_rules_changed = 0;
kernel_link_changed = 0;
kernel_addr_changed = 0;
kernel_dump_time = now.tv_sec + roughly(30);
kernel_dump_time = now.tv_sec + roughly(kernel_check_interval);
schedule_neighbours_check(5000, 1);
schedule_interfaces_check(30000, 1);
expiry_time = now.tv_sec + roughly(30);
Expand Down Expand Up @@ -645,7 +646,8 @@ main(int argc, char **argv)
timeval_min(&tv, &check_interfaces_timeout);
timeval_min_sec(&tv, expiry_time);
timeval_min_sec(&tv, source_expiry_time);
timeval_min_sec(&tv, kernel_dump_time);
if(kernel_check_interval > 0)
timeval_min_sec(&tv, kernel_dump_time);
timeval_min(&tv, &resend_time);
FOR_ALL_INTERFACES(ifp) {
if(!if_up(ifp))
Expand Down Expand Up @@ -759,12 +761,12 @@ main(int argc, char **argv)
}

if(kernel_routes_changed || kernel_addr_changed ||
kernel_rules_changed || now.tv_sec >= kernel_dump_time) {
(kernel_check_interval > 0 && now.tv_sec >= kernel_dump_time)) {
rc = check_xroutes(1);
if(rc < 0)
fprintf(stderr, "Warning: couldn't check exported routes.\n");
kernel_routes_changed = kernel_addr_changed = 0;
kernel_dump_time = now.tv_sec + roughly(300);
kernel_dump_time = now.tv_sec + roughly(kernel_check_interval);
}

if(timeval_compare(&check_neighbours_timeout, &now) < 0) {
Expand Down
1 change: 1 addition & 0 deletions babeld.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ extern int local_server_write;
extern unsigned char protocol_group[16];
extern int protocol_socket;
extern int kernel_socket;
extern int kernel_check_interval;
extern int max_request_hopcount;

extern uint32_t fee;
Expand Down
5 changes: 5 additions & 0 deletions babeld.man
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ and can be specified multiple times with a cumulative effect. This is
equivalent to the command-line option
.BR \-T .
.TP
.BI kernel-check-interval " seconds"
This specifies the interval between two kernel routing table dumps. The
default is 300s (5 minutes). This may be set to 0 in order to never
perform periodic kernel dumps.
.TP
.BR link-detect " {" true | false }
This specifies whether to use carrier sense for determining interface
availability, and is equivalent to the command-line option
Expand Down
5 changes: 4 additions & 1 deletion configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,8 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
strcmp(token, "local-port") == 0 ||
strcmp(token, "local-port-readwrite") == 0 ||
strcmp(token, "export-table") == 0 ||
strcmp(token, "import-table") == 0) {
strcmp(token, "import-table") == 0 ||
strcmp(token, "kernel-check-interval") == 0) {
int v;
c = getint(c, &v, gnc, closure);
if(c < -1 || v <= 0 || v >= 0xFFFF)
Expand All @@ -845,6 +846,8 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
export_table = v;
else if(strcmp(token, "import-table") == 0)
add_import_table(v);
else if(strcmp(token, "kernel-check-interval") == 0)
kernel_check_interval = v;
else
abort();
} else if(strcmp(token, "link-detect") == 0 ||
Expand Down

0 comments on commit d360465

Please sign in to comment.