Commit bd67a650 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Remove support for iterating over source-specific routes.

This means we no longer need to keep source-specific routes at
the beginning, so remove the debugging check (which should never
have made it into production anyway).
parent 580257c7
...@@ -1115,7 +1115,7 @@ dump_tables(FILE *out) ...@@ -1115,7 +1115,7 @@ dump_tables(FILE *out)
xroute_stream_done(xroutes); xroute_stream_done(xroutes);
} }
routes = route_stream(ROUTE_ALL); routes = route_stream(0);
if(routes) { if(routes) {
while(1) { while(1) {
struct babel_route *route = route_stream_next(routes); struct babel_route *route = route_stream_next(routes);
......
...@@ -302,7 +302,7 @@ local_notify_all_1(struct local_socket *s) ...@@ -302,7 +302,7 @@ local_notify_all_1(struct local_socket *s)
xroute_stream_done(xroutes); xroute_stream_done(xroutes);
} }
routes = route_stream(ROUTE_ALL); routes = route_stream(0);
if(routes) { if(routes) {
while(1) { while(1) {
struct babel_route *route = route_stream_next(routes); struct babel_route *route = route_stream_next(routes);
......
...@@ -1568,7 +1568,7 @@ send_update(struct interface *ifp, int urgent, ...@@ -1568,7 +1568,7 @@ send_update(struct interface *ifp, int urgent,
struct route_stream *routes; struct route_stream *routes;
send_self_update(ifp); send_self_update(ifp);
debugf("Sending update to %s for any.\n", ifp->name); debugf("Sending update to %s for any.\n", ifp->name);
routes = route_stream(ROUTE_INSTALLED); routes = route_stream(1);
if(routes) { if(routes) {
while(1) { while(1) {
int is_ss; int is_ss;
......
...@@ -50,22 +50,6 @@ int diversity_factor = 256; /* in units of 1/256 */ ...@@ -50,22 +50,6 @@ int diversity_factor = 256; /* in units of 1/256 */
static int smoothing_half_life = 0; static int smoothing_half_life = 0;
static int two_to_the_one_over_hl = 0; /* 2^(1/hl) * 0x10000 */ static int two_to_the_one_over_hl = 0; /* 2^(1/hl) * 0x10000 */
static int
check_specific_first(void)
{
/* All source-specific routes are in front of the list */
int specific = 1;
int i;
for(i = 0; i < route_slots; i++) {
if(is_default(routes[i]->src->src_prefix, routes[i]->src->src_plen)) {
specific = 0;
} else if(!specific) {
return 0;
}
}
return 1;
}
/* We maintain a list of "slots", ordered by prefix. Every slot /* We maintain a list of "slots", ordered by prefix. Every slot
contains a linked list of the routes to this prefix, with the contains a linked list of the routes to this prefix, with the
installed route, if any, at the head of the list. */ installed route, if any, at the head of the list. */
...@@ -374,19 +358,16 @@ struct route_stream { ...@@ -374,19 +358,16 @@ struct route_stream {
struct route_stream * struct route_stream *
route_stream(int which) route_stream(int installed)
{ {
struct route_stream *stream; struct route_stream *stream;
if(!check_specific_first())
fprintf(stderr, "Invariant failed: specific routes first in RIB.\n");
stream = calloc(1, sizeof(struct route_stream)); stream = calloc(1, sizeof(struct route_stream));
if(stream == NULL) if(stream == NULL)
return NULL; return NULL;
stream->installed = which; stream->installed = installed;
stream->index = which == ROUTE_ALL ? -1 : 0; stream->index = installed ? 0 : -1;
stream->next = NULL; stream->next = NULL;
return stream; return stream;
...@@ -396,16 +377,12 @@ struct babel_route * ...@@ -396,16 +377,12 @@ struct babel_route *
route_stream_next(struct route_stream *stream) route_stream_next(struct route_stream *stream)
{ {
if(stream->installed) { if(stream->installed) {
while(stream->index < route_slots) while(stream->index < route_slots) {
if(stream->installed == ROUTE_SS_INSTALLED && if(routes[stream->index]->installed)
is_default(routes[stream->index]->src->src_prefix,
routes[stream->index]->src->src_plen))
return NULL;
else if(routes[stream->index]->installed)
break; break;
else else
stream->index++; stream->index++;
}
if(stream->index < route_slots) if(stream->index < route_slots)
return routes[stream->index++]; return routes[stream->index++];
else else
......
...@@ -43,9 +43,6 @@ struct babel_route { ...@@ -43,9 +43,6 @@ struct babel_route {
struct babel_route *next; struct babel_route *next;
}; };
#define ROUTE_ALL 0
#define ROUTE_INSTALLED 1
#define ROUTE_SS_INSTALLED 2
struct route_stream; struct route_stream;
extern struct babel_route **routes; extern struct babel_route **routes;
......
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