Commit d40e0807 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement reflect-kernel-metric.

Thanks to Pierre Pfister.
parent 0490036f
babeld-1.5.2 (unreleased):
* Added support for reflecting metrics as kernel priorities. Thanks to
Pierre Pfister.
4 July 2014: babeld-1.5.1: 4 July 2014: babeld-1.5.1:
* Added support for reading multiple configuration files by specifying * Added support for reading multiple configuration files by specifying
......
...@@ -164,6 +164,13 @@ This specifies the priority value used when installing routes into the ...@@ -164,6 +164,13 @@ This specifies the priority value used when installing routes into the
kernel, and is equivalent to the command-line option kernel, and is equivalent to the command-line option
.BR \-k . .BR \-k .
.TP .TP
.BR reflect-kernel-metric " {" true | false }
Reflect route metrics as kernel priorities. The priority effectively used
is
.B kernel-priority
+
.BR metric .
.TP
.BI allow-duplicates " priority" .BI allow-duplicates " priority"
This allows duplicating external routes when their kernel priority is This allows duplicating external routes when their kernel priority is
at least at least
......
...@@ -656,6 +656,8 @@ parse_option(int c, gnc_t gnc, void *closure, char *token) ...@@ -656,6 +656,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, "reflect-kernel-metric") == 0)
reflect_kernel_metric = b;
else else
abort(); abort();
} else if(strcmp(token, "protocol-group") == 0) { } else if(strcmp(token, "protocol-group") == 0) {
......
...@@ -42,7 +42,7 @@ THE SOFTWARE. ...@@ -42,7 +42,7 @@ THE SOFTWARE.
struct babel_route **routes = NULL; struct babel_route **routes = NULL;
static int route_slots = 0, max_route_slots = 0; static int route_slots = 0, max_route_slots = 0;
int kernel_metric = 0; int kernel_metric = 0, reflect_kernel_metric = 0;
int allow_duplicates = -1; int allow_duplicates = -1;
int diversity_kind = DIVERSITY_NONE; int diversity_kind = DIVERSITY_NONE;
int diversity_factor = 256; /* in units of 1/256 */ int diversity_factor = 256; /* in units of 1/256 */
...@@ -373,7 +373,14 @@ route_stream_done(struct route_stream *stream) ...@@ -373,7 +373,14 @@ route_stream_done(struct route_stream *stream)
static int static int
metric_to_kernel(int metric) metric_to_kernel(int metric)
{ {
return metric < INFINITY ? kernel_metric : KERNEL_INFINITY; if(metric >= INFINITY) {
return KERNEL_INFINITY;
} else if(reflect_kernel_metric) {
int r = kernel_metric + metric;
return r >= KERNEL_INFINITY ? KERNEL_INFINITY : r;
} else {
return kernel_metric;
}
} }
/* This is used to maintain the invariant that the installed route is at /* This is used to maintain the invariant that the installed route is at
......
...@@ -47,7 +47,7 @@ struct babel_route { ...@@ -47,7 +47,7 @@ struct babel_route {
struct route_stream; struct route_stream;
extern struct babel_route **routes; extern struct babel_route **routes;
extern int kernel_metric, allow_duplicates; extern int kernel_metric, allow_duplicates, reflect_kernel_metric;
extern int diversity_kind, diversity_factor; extern int diversity_kind, diversity_factor;
extern int keep_unfeasible; extern int keep_unfeasible;
......
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