Commit 85f0b2dd authored by Matthieu Boutier's avatar Matthieu Boutier

Don't insert ipv6 disambiguation routes if IPV6_SUBTREES is defined.

Since the kernel behavior is the one desired for ipv6 (match by destination
first, then source), we don't install disambiguation route entries for ipv6.
The behavior for v4 doesn't change.
parent 7fa1be74
...@@ -103,10 +103,10 @@ search_conflict_solution(const struct zone *conflict_zone) ...@@ -103,10 +103,10 @@ search_conflict_solution(const struct zone *conflict_zone)
static int static int
add_non_conflicting_route(const struct babel_route *route, add_non_conflicting_route(const struct babel_route *route,
const struct zone *zone) const struct zone *zone, int v4)
{ {
int rc; int rc;
if(!has_conflict(zone)) { if((has_ipv6_subtrees && !v4) || !has_conflict(zone)) {
rc = kernel_route(ROUTE_ADD, zone->dst_prefix, zone->dst_plen, rc = kernel_route(ROUTE_ADD, zone->dst_prefix, zone->dst_plen,
zone->src_prefix, zone->src_plen, zone->src_prefix, zone->src_plen,
route->nexthop, route->nexthop,
...@@ -192,7 +192,7 @@ install_conflicting_routes(const struct babel_route *route_to_add, ...@@ -192,7 +192,7 @@ install_conflicting_routes(const struct babel_route *route_to_add,
solution = route_to_add; solution = route_to_add;
debugf(" solution is our route\n"); debugf(" solution is our route\n");
} }
return add_non_conflicting_route(solution, &cz); return add_non_conflicting_route(solution, &cz, v4mapped(rt->prefix));
} }
int int
...@@ -202,16 +202,19 @@ kinstall_route(const struct babel_route *route) ...@@ -202,16 +202,19 @@ kinstall_route(const struct babel_route *route)
struct zone zone; struct zone zone;
struct babel_route *rt1 = NULL; struct babel_route *rt1 = NULL;
struct route_stream *stream = NULL; struct route_stream *stream = NULL;
int v4 = v4mapped(route->nexthop);
debugf("install_route(%s from %s)\n", debugf("install_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));
/* Install source-specific conflicting routes */ /* Install source-specific conflicting routes */
if(!has_ipv6_subtrees || 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;
} }
/* Install source-specific conflicting routes */
while(1) { while(1) {
rt1 = route_stream_next(stream); rt1 = route_stream_next(stream);
if(rt1 == NULL) break; if(rt1 == NULL) break;
...@@ -226,13 +229,14 @@ kinstall_route(const struct babel_route *route) ...@@ -226,13 +229,14 @@ kinstall_route(const struct babel_route *route)
} }
} }
route_stream_done(stream); route_stream_done(stream);
}
/* Non conflicting case */ /* Non conflicting case */
zone.dst_prefix = route->src->prefix; zone.dst_prefix = route->src->prefix;
zone.dst_plen = route->src->plen; zone.dst_plen = route->src->plen;
zone.src_prefix = route->src->src_prefix; zone.src_prefix = route->src->src_prefix;
zone.src_plen = route->src->src_plen; zone.src_plen = route->src->src_plen;
rc = add_non_conflicting_route(route, &zone); rc = add_non_conflicting_route(route, &zone, v4);
if(rc < 0) { if(rc < 0) {
int save = errno; int save = errno;
perror("kernel_route(ADD)"); perror("kernel_route(ADD)");
...@@ -244,10 +248,10 @@ kinstall_route(const struct babel_route *route) ...@@ -244,10 +248,10 @@ kinstall_route(const struct babel_route *route)
static int static int
del_non_conflicting_route(const struct babel_route *route, del_non_conflicting_route(const struct babel_route *route,
const struct zone *zone) const struct zone *zone, int v4)
{ {
int rc; int rc;
if(!has_conflict(zone)) { if((has_ipv6_subtrees && !v4) || !has_conflict(zone)) {
rc = kernel_route(ROUTE_FLUSH, zone->dst_prefix, zone->dst_plen, rc = kernel_route(ROUTE_FLUSH, zone->dst_prefix, zone->dst_plen,
zone->src_prefix, zone->src_plen, zone->src_prefix, zone->src_plen,
route->nexthop, route->nexthop,
...@@ -380,6 +384,7 @@ kuninstall_route(const struct babel_route *route) ...@@ -380,6 +384,7 @@ kuninstall_route(const struct babel_route *route)
struct zone zone; struct zone zone;
struct babel_route *rt1; struct babel_route *rt1;
struct route_stream *stream = NULL; struct route_stream *stream = NULL;
int v4 = v4mapped(route->nexthop);
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),
...@@ -389,11 +394,12 @@ kuninstall_route(const struct babel_route *route) ...@@ -389,11 +394,12 @@ kuninstall_route(const struct babel_route *route)
zone.dst_plen = route->src->plen; zone.dst_plen = route->src->plen;
zone.src_prefix = route->src->src_prefix; zone.src_prefix = route->src->src_prefix;
zone.src_plen = route->src->src_plen; zone.src_plen = route->src->src_plen;
rc = del_non_conflicting_route(route, &zone); rc = del_non_conflicting_route(route, &zone, v4);
if(rc < 0) if(rc < 0)
perror("kernel_route(FLUSH)"); perror("kernel_route(FLUSH)");
/* Remove source-specific conflicting routes */ /* Remove source-specific conflicting routes */
if(!has_ipv6_subtrees || 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");
...@@ -407,6 +413,7 @@ kuninstall_route(const struct babel_route *route) ...@@ -407,6 +413,7 @@ kuninstall_route(const struct babel_route *route)
perror("kernel_route(FLUSH sub)"); perror("kernel_route(FLUSH sub)");
} }
route_stream_done(stream); route_stream_done(stream);
}
return rc; return rc;
} }
...@@ -488,12 +495,12 @@ kswitch_routes(const struct babel_route *old, const struct babel_route *new) ...@@ -488,12 +495,12 @@ kswitch_routes(const struct babel_route *old, const struct babel_route *new)
new_metric = metric_to_kernel(route_metric(new)); new_metric = metric_to_kernel(route_metric(new));
/* Remove source-specific conflicting routes */ /* Remove source-specific conflicting routes */
if(!has_ipv6_subtrees || v4mapped(old->nexthop)) {
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;
...@@ -502,6 +509,7 @@ kswitch_routes(const struct babel_route *old, const struct babel_route *new) ...@@ -502,6 +509,7 @@ kswitch_routes(const struct babel_route *old, const struct babel_route *new)
perror("kernel_route(MODIFY sub)"); perror("kernel_route(MODIFY sub)");
} }
route_stream_done(stream); route_stream_done(stream);
}
return rc; return rc;
} }
...@@ -531,6 +539,7 @@ kchange_route_metric(const struct babel_route *route, ...@@ -531,6 +539,7 @@ kchange_route_metric(const struct babel_route *route,
return -1; return -1;
} }
if(!has_ipv6_subtrees || v4mapped(route->nexthop)) {
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");
...@@ -545,6 +554,7 @@ kchange_route_metric(const struct babel_route *route, ...@@ -545,6 +554,7 @@ kchange_route_metric(const struct babel_route *route,
perror("kernel_route(MODIFY metric sub)"); perror("kernel_route(MODIFY metric sub)");
} }
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