Commit 46dd09f4 authored by Matthieu Boutier's avatar Matthieu Boutier Committed by Juliusz Chroboczek

Add options to control the table and priority numbers.

parent 0673b965
......@@ -253,6 +253,14 @@ This specifies the name of the file to which
.B babeld
writes out its process id, and is equivalent to the command-line option
.BR \-I .
.TP
.BI first-table-number " table"
This specifies the index of the first routing table to use for
source-specific routes. The default is 10.
.TP
.BI first-rule-priority " priority"
This specifies smallest (highest) rule priority used with source-specific
routes. The default is 100.
.SS Interface configuration
An interface is configured by a line with the following format:
.IP
......
......@@ -713,6 +713,18 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
if(c < -1 || h < 0)
goto error;
change_smoothing_half_life(h);
} else if(strcmp(token, "first-table-number") == 0) {
int n;
c = getint(c, &n, gnc, closure);
if(c < -1 || n <= 0 || n + SRC_TABLE_NUM >= 254)
goto error;
src_table_idx = n;
} else if(strcmp(token, "first-rule-priority") == 0) {
int n;
c = getint(c, &n, gnc, closure);
if(c < -1 || n <= 0 || n + SRC_TABLE_NUM >= 32765)
goto error;
src_table_prio = n;
} else {
goto error;
}
......
......@@ -32,6 +32,9 @@ THE SOFTWARE.
#include "kernel_socket.c"
#endif
int src_table_idx = 10;
int src_table_prio = 100;
/* Like gettimeofday, but returns monotonic time. If POSIX clocks are not
available, falls back to gettimeofday but enforces monotonicity. */
int
......
......@@ -51,6 +51,9 @@ struct kernel_route {
extern int export_table, import_tables[MAX_IMPORT_TABLES], import_table_count;
int add_import_table(int table);
#define SRC_TABLE_NUM 10
extern int src_table_idx; /* number of the first table */
extern int src_table_prio; /* first prio range */
int kernel_setup(int setup);
int kernel_setup_socket(int setup);
......
......@@ -1651,10 +1651,6 @@ flush_rule(int prio, int family)
/* Source specific functions and data structures */
#define SRC_TABLE_IDX 10 /* number of the first table */
#define SRC_TABLE_NUM 10
#define SRC_TABLE_PRIO 110 /* first prio range */
/* The table used for non-specific routes is "export_table", therefore, we can
take the convention of plen == 0 <=> empty table. */
struct kernel_table {
......@@ -1708,7 +1704,7 @@ insert_table(const unsigned char *src, unsigned short src_plen, int idx)
for(table = 0; table < SRC_TABLE_NUM; table++)
if(!used_tables[table])
break;
table += SRC_TABLE_IDX;
table += src_table_idx;
/* Create the table's rule at the right place. Shift rules if necessary. */
if(kernel_tables[idx].plen != 0) {
......@@ -1719,8 +1715,8 @@ insert_table(const unsigned char *src, unsigned short src_plen, int idx)
rc = change_table_priority(kernel_tables[i].src,
kernel_tables[i].plen,
kernel_tables[i].table,
i + SRC_TABLE_PRIO,
i + 1 + SRC_TABLE_PRIO);
i + src_table_prio,
i + 1 + src_table_prio);
if(rc < 0) {
perror("change_table_priority");
return NULL;
......@@ -1730,12 +1726,12 @@ insert_table(const unsigned char *src, unsigned short src_plen, int idx)
}
}
rc = add_rule(idx + SRC_TABLE_PRIO, src, src_plen, table);
rc = add_rule(idx + src_table_prio, src, src_plen, table);
if(rc < 0) {
perror("add rule");
return NULL;
}
used_tables[table - SRC_TABLE_IDX] = 1;
used_tables[table - src_table_idx] = 1;
memcpy(kernel_tables[idx].src, src, 16);
kernel_tables[idx].plen = src_plen;
kernel_tables[idx].table = table;
......@@ -1802,7 +1798,7 @@ release_tables(void)
int i;
for(i = 0; i < SRC_TABLE_NUM; i++) {
if(kernel_tables[i].plen != 0) {
flush_rule(i + SRC_TABLE_PRIO,
flush_rule(i + src_table_prio,
v4mapped(kernel_tables[i].src) ? AF_INET : AF_INET6);
kernel_tables[i].plen = 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