Commit 6d768ba4 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Encapsulate testing for ipv6_subtrees within a function.

parent 36f056a0
...@@ -266,7 +266,7 @@ kinstall_route(const struct babel_route *route) ...@@ -266,7 +266,7 @@ 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(!has_ipv6_subtrees || v4) { 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");
...@@ -330,7 +330,7 @@ kuninstall_route(const struct babel_route *route) ...@@ -330,7 +330,7 @@ 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(!has_ipv6_subtrees || v4) { 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");
...@@ -376,7 +376,7 @@ kswitch_routes(const struct babel_route *old, const struct babel_route *new) ...@@ -376,7 +376,7 @@ kswitch_routes(const struct babel_route *old, const struct babel_route *new)
} }
/* Remove source-specific conflicting routes */ /* Remove source-specific conflicting routes */
if(!has_ipv6_subtrees || v4mapped(old->nexthop)) { if(!kernel_disambiguate(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");
...@@ -423,7 +423,7 @@ kchange_route_metric(const struct babel_route *route, ...@@ -423,7 +423,7 @@ kchange_route_metric(const struct babel_route *route,
return -1; return -1;
} }
if(!has_ipv6_subtrees || v4mapped(route->nexthop)) { if(!kernel_disambiguate(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");
......
...@@ -65,6 +65,7 @@ int kernel_interface_ipv4(const char *ifname, int ifindex, ...@@ -65,6 +65,7 @@ int kernel_interface_ipv4(const char *ifname, int ifindex,
int kernel_interface_mtu(const char *ifname, int ifindex); int kernel_interface_mtu(const char *ifname, int ifindex);
int kernel_interface_wireless(const char *ifname, int ifindex); int kernel_interface_wireless(const char *ifname, int ifindex);
int kernel_interface_channel(const char *ifname, int ifindex); int kernel_interface_channel(const char *ifname, int ifindex);
int kernel_disambiguate(int v4);
int kernel_route(int operation, const unsigned char *dest, unsigned short plen, int kernel_route(int operation, const unsigned char *dest, unsigned short plen,
const unsigned char *src, unsigned short src_plen, const unsigned char *src, unsigned short src_plen,
const unsigned char *gate, int ifindex, unsigned int metric, const unsigned char *gate, int ifindex, unsigned int metric,
......
...@@ -917,6 +917,14 @@ kernel_interface_channel(const char *ifname, int ifindex) ...@@ -917,6 +917,14 @@ kernel_interface_channel(const char *ifname, int ifindex)
return -1; return -1;
} }
/* Return true if we cannot handle disambiguation ourselves. */
int
kernel_disambiguate(int v4)
{
return !v4 && has_ipv6_subtrees;
}
int int
kernel_route(int operation, const unsigned char *dest, unsigned short plen, kernel_route(int operation, const unsigned char *dest, unsigned short plen,
const unsigned char *src, unsigned short src_plen, const unsigned char *src, unsigned short src_plen,
...@@ -994,7 +1002,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen, ...@@ -994,7 +1002,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
if(src_plen == 0) { if(src_plen == 0) {
table = export_table; table = export_table;
} else if(has_ipv6_subtrees && !ipv4) { } else if(kernel_disambiguate(ipv4)) {
table = export_table; table = export_table;
use_src = 1; use_src = 1;
} else { } else {
...@@ -1841,7 +1849,7 @@ find_table(const unsigned char *src, unsigned short src_plen) ...@@ -1841,7 +1849,7 @@ find_table(const unsigned char *src, unsigned short src_plen)
int i, new_i; int i, new_i;
if(src_plen == 0 || if(src_plen == 0 ||
(has_ipv6_subtrees && (src_plen < 96 || !v4mapped(src)))) { (kernel_disambiguate(src_plen >= 96 && v4mapped(src)))) {
fprintf(stderr, "Find_table called for route handled by kernel " fprintf(stderr, "Find_table called for route handled by kernel "
"(this shouldn't happen)."); "(this shouldn't happen).");
return -1; return -1;
......
...@@ -382,6 +382,12 @@ kernel_interface_channel(const char *ifname, int ifindex) ...@@ -382,6 +382,12 @@ kernel_interface_channel(const char *ifname, int ifindex)
return -1; return -1;
} }
int
kernel_disambiguate(int v4)
{
return 0;
}
int int
kernel_route(int operation, const unsigned char *dest, unsigned short plen, kernel_route(int operation, const unsigned char *dest, unsigned short plen,
const unsigned char *src, unsigned short src_plen, const unsigned char *src, unsigned short src_plen,
......
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