Commit 78c84feb authored by Matthieu Boutier's avatar Matthieu Boutier Committed by Juliusz Chroboczek

Fix bug which may consider inexistent disambiguation entries.

This patch fix the non-disambiguation behaviour: we were looking to
disambiguation entries to remove or replace, which is a complete non-sense,
since there should not being disambiguation entries.
parent fccc49a8
...@@ -266,30 +266,34 @@ kinstall_route(const struct babel_route *route) ...@@ -266,30 +266,34 @@ kinstall_route(const struct babel_route *route)
format_prefix(route->src->prefix, route->src->plen), format_prefix(route->src->prefix, route->src->plen),
format_prefix(route->src->src_prefix, route->src->src_plen)); format_prefix(route->src->src_prefix, route->src->src_plen));
/* Install source-specific conflicting routes */ /* Install source-specific conflicting routes */
if(!kernel_disambiguate(v4)) { if(kernel_disambiguate(v4)) {
stream = route_stream(1); to_zone(route, &zone);
if(!stream) { rc = add_route(&zone, route);
fprintf(stderr, "Couldn't allocate route stream.\n"); goto end;
return -1; }
}
/* Install source-specific conflicting routes */
while(1) {
rt1 = route_stream_next(stream);
if(rt1 == NULL) break;
inter(route, rt1, &zone); stream = route_stream(1);
if(!(conflicts(route, rt1) && if(!stream) {
!is_installed(&zone) && fprintf(stderr, "Couldn't allocate route stream.\n");
rt_cmp(rt1, min_conflict(&zone, route)) == 0)) return -1;
continue; }
rt2 = min_conflict(&zone, rt1); /* Install source-specific conflicting routes */
if(rt2 == NULL) while(1) {
add_route(&zone, min_route(route, rt1)); rt1 = route_stream_next(stream);
else if(rt_cmp(route, rt2) < 0 && rt_cmp(route, rt1) < 0) if(rt1 == NULL) break;
chg_route(&zone, rt2, route);
} inter(route, rt1, &zone);
route_stream_done(stream); if(!(conflicts(route, rt1) &&
!is_installed(&zone) &&
rt_cmp(rt1, min_conflict(&zone, route)) == 0))
continue;
rt2 = min_conflict(&zone, rt1);
if(rt2 == NULL)
add_route(&zone, min_route(route, rt1));
else if(rt_cmp(route, rt2) < 0 && rt_cmp(route, rt1) < 0)
chg_route(&zone, rt2, route);
} }
route_stream_done(stream);
/* Non conflicting case */ /* Non conflicting case */
to_zone(route, &zone); to_zone(route, &zone);
...@@ -298,6 +302,7 @@ kinstall_route(const struct babel_route *route) ...@@ -298,6 +302,7 @@ kinstall_route(const struct babel_route *route)
rc = add_route(&zone, route); rc = add_route(&zone, route);
else else
rc = chg_route(&zone, rt1, route); rc = chg_route(&zone, rt1, route);
end:
if(rc < 0) { if(rc < 0) {
int save = errno; int save = errno;
perror("kernel_route(ADD)"); perror("kernel_route(ADD)");
...@@ -319,8 +324,14 @@ kuninstall_route(const struct babel_route *route) ...@@ -319,8 +324,14 @@ kuninstall_route(const struct babel_route *route)
debugf("uninstall_route(%s from %s)\n", debugf("uninstall_route(%s from %s)\n",
format_prefix(route->src->prefix, route->src->plen), format_prefix(route->src->prefix, route->src->plen),
format_prefix(route->src->src_prefix, route->src->src_plen)); format_prefix(route->src->src_prefix, route->src->src_plen));
/* Remove the route, or change if the route was solving a conflict. */
to_zone(route, &zone); to_zone(route, &zone);
if(kernel_disambiguate(v4)) {
rc = del_route(&zone, route);
if(rc < 0)
perror("kernel_route(FLUSH)");
return rc;
}
/* Remove the route, or change if the route was solving a conflict. */
rt1 = conflict_solution(route); rt1 = conflict_solution(route);
if(rt1 == NULL) if(rt1 == NULL)
rc = del_route(&zone, route); rc = del_route(&zone, route);
...@@ -330,29 +341,27 @@ kuninstall_route(const struct babel_route *route) ...@@ -330,29 +341,27 @@ kuninstall_route(const struct babel_route *route)
perror("kernel_route(FLUSH)"); perror("kernel_route(FLUSH)");
/* Remove source-specific conflicting routes */ /* Remove source-specific conflicting routes */
if(!kernel_disambiguate(v4)) { stream = route_stream(1);
stream = route_stream(1); if(!stream) {
if(!stream) { fprintf(stderr, "Couldn't allocate route stream.\n");
fprintf(stderr, "Couldn't allocate route stream.\n"); return -1;
return -1; }
} while(1) {
while(1) { rt1 = route_stream_next(stream);
rt1 = route_stream_next(stream); if(rt1 == NULL) break;
if(rt1 == NULL) break;
inter(route, rt1, &zone); inter(route, rt1, &zone);
if(!(conflicts(route, rt1) && if(!(conflicts(route, rt1) &&
!is_installed(&zone) && !is_installed(&zone) &&
rt_cmp(rt1, min_conflict(&zone, route)) == 0)) rt_cmp(rt1, min_conflict(&zone, route)) == 0))
continue; continue;
rt2 = min_conflict(&zone, rt1); rt2 = min_conflict(&zone, rt1);
if(rt2 == NULL) if(rt2 == NULL)
del_route(&zone, min_route(route, rt1)); del_route(&zone, min_route(route, rt1));
else if(rt_cmp(route, rt2) < 0 && rt_cmp(route, rt1) < 0) else if(rt_cmp(route, rt2) < 0 && rt_cmp(route, rt1) < 0)
chg_route(&zone, route, rt2); chg_route(&zone, route, rt2);
}
route_stream_done(stream);
} }
route_stream_done(stream);
return rc; return rc;
} }
......
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