Commit 449c8d59 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Remove support for forced xroutes.

Significantly simplifies the xroute logic.
parent f915c7a8
...@@ -968,10 +968,9 @@ dump_tables(FILE *out) ...@@ -968,10 +968,9 @@ dump_tables(FILE *out)
neigh->network->up ? "" : " (down)"); neigh->network->up ? "" : " (down)");
} }
for(i = 0; i < numxroutes; i++) { for(i = 0; i < numxroutes; i++) {
fprintf(out, "%s metric %d (%s)\n", fprintf(out, "%s metric %d (exported)\n",
format_prefix(xroutes[i].prefix, xroutes[i].plen), format_prefix(xroutes[i].prefix, xroutes[i].plen),
xroutes[i].metric, xroutes[i].metric);
xroutes[i].kind == XROUTE_FORCED ? "forced" : "exported");
} }
for(i = 0; i < numroutes; i++) { for(i = 0; i < numroutes; i++) {
int id = int id =
......
...@@ -85,18 +85,11 @@ flush_xroute(struct xroute *xroute) ...@@ -85,18 +85,11 @@ flush_xroute(struct xroute *xroute)
} }
int int
add_xroute(int kind, unsigned char prefix[16], unsigned char plen, add_xroute(unsigned char prefix[16], unsigned char plen,
unsigned short metric, unsigned int ifindex, int proto) unsigned short metric, unsigned int ifindex, int proto)
{ {
struct xroute *xroute = find_xroute(prefix, plen); struct xroute *xroute = find_xroute(prefix, plen);
if(xroute) { if(xroute) {
if(xroute->kind < kind)
return 0;
else if(xroute->kind > kind) {
flush_xroute(xroute);
return add_xroute(kind, prefix, plen, metric, ifindex, proto);
}
if(xroute->metric <= metric) if(xroute->metric <= metric)
return 0; return 0;
xroute->metric = metric; xroute->metric = metric;
...@@ -116,7 +109,6 @@ add_xroute(int kind, unsigned char prefix[16], unsigned char plen, ...@@ -116,7 +109,6 @@ add_xroute(int kind, unsigned char prefix[16], unsigned char plen,
xroutes = new_xroutes; xroutes = new_xroutes;
} }
xroutes[numxroutes].kind = kind;
memcpy(xroutes[numxroutes].prefix, prefix, 16); memcpy(xroutes[numxroutes].prefix, prefix, 16);
xroutes[numxroutes].plen = plen; xroutes[numxroutes].plen = plen;
xroutes[numxroutes].metric = metric; xroutes[numxroutes].metric = metric;
...@@ -168,9 +160,6 @@ check_xroutes(int send_updates) ...@@ -168,9 +160,6 @@ check_xroutes(int send_updates)
i = 0; i = 0;
while(i < numxroutes) { while(i < numxroutes) {
export = 0; export = 0;
if(xroutes[i].kind == XROUTE_FORCED) {
export = 1;
} else if(xroutes[i].kind == XROUTE_REDISTRIBUTED) {
metric = redistribute_filter(xroutes[i].prefix, xroutes[i].plen, metric = redistribute_filter(xroutes[i].prefix, xroutes[i].plen,
xroutes[i].ifindex, xroutes[i].proto); xroutes[i].ifindex, xroutes[i].proto);
if((metric < INFINITY && metric == xroutes[i].metric) || if((metric < INFINITY && metric == xroutes[i].metric) ||
...@@ -191,7 +180,6 @@ check_xroutes(int send_updates) ...@@ -191,7 +180,6 @@ check_xroutes(int send_updates)
} }
} }
} }
}
if(!export) { if(!export) {
unsigned char prefix[16], plen; unsigned char prefix[16], plen;
...@@ -222,8 +210,7 @@ check_xroutes(int send_updates) ...@@ -222,8 +210,7 @@ check_xroutes(int send_updates)
if(metric == METRIC_INHERIT) if(metric == METRIC_INHERIT)
metric = routes[i].metric * 256; metric = routes[i].metric * 256;
if(metric < INFINITY) { if(metric < INFINITY) {
rc = add_xroute(XROUTE_REDISTRIBUTED, rc = add_xroute(routes[i].prefix, routes[i].plen,
routes[i].prefix, routes[i].plen,
metric, routes[i].ifindex, routes[i].proto); metric, routes[i].ifindex, routes[i].proto);
if(rc) { if(rc) {
struct route *route; struct route *route;
......
...@@ -22,13 +22,9 @@ THE SOFTWARE. ...@@ -22,13 +22,9 @@ THE SOFTWARE.
/* These should come in decreasing order of priority. */ /* These should come in decreasing order of priority. */
#define XROUTE_FORCED 1
#define XROUTE_REDISTRIBUTED 2
struct xroute { struct xroute {
unsigned char prefix[16]; unsigned char prefix[16];
unsigned char plen; unsigned char plen;
char kind;
unsigned short metric; unsigned short metric;
unsigned int ifindex; unsigned int ifindex;
int proto; int proto;
...@@ -39,6 +35,6 @@ extern int numxroutes; ...@@ -39,6 +35,6 @@ extern int numxroutes;
struct xroute *find_xroute(const unsigned char *prefix, unsigned char plen); struct xroute *find_xroute(const unsigned char *prefix, unsigned char plen);
void flush_xroute(struct xroute *xroute); void flush_xroute(struct xroute *xroute);
int add_xroute(int kind, unsigned char prefix[16], unsigned char plen, int add_xroute(unsigned char prefix[16], unsigned char plen,
unsigned short metric, unsigned int ifindex, int proto); unsigned short metric, unsigned int ifindex, int proto);
int check_xroutes(int send_updates); int check_xroutes(int send_updates);
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