Commit 7b413d28 authored by Matthieu Boutier's avatar Matthieu Boutier

Use the disambiguation algorithm.

parent 9fbafb73
...@@ -39,6 +39,7 @@ THE SOFTWARE. ...@@ -39,6 +39,7 @@ THE SOFTWARE.
#include "resend.h" #include "resend.h"
#include "configuration.h" #include "configuration.h"
#include "local.h" #include "local.h"
#include "disambiguation.h"
struct babel_route **routes = NULL; struct babel_route **routes = NULL;
static int route_slots = 0, max_route_slots = 0; static int route_slots = 0, max_route_slots = 0;
...@@ -501,17 +502,10 @@ install_route(struct babel_route *route) ...@@ -501,17 +502,10 @@ install_route(struct babel_route *route)
return; return;
} }
rc = kernel_route(ROUTE_ADD, route->src->prefix, route->src->plen, rc = kinstall_route(route);
route->src->src_prefix, route->src->src_plen, if(rc < 0 && errno != EEXIST)
route->nexthop, return;
route->neigh->ifp->ifindex,
metric_to_kernel(route_metric(route)), NULL, 0, 0);
if(rc < 0) {
int save = errno;
perror("kernel_route(ADD)");
if(save != EEXIST)
return;
}
route->installed = 1; route->installed = 1;
move_installed_route(route, i); move_installed_route(route, i);
...@@ -521,20 +515,13 @@ install_route(struct babel_route *route) ...@@ -521,20 +515,13 @@ install_route(struct babel_route *route)
void void
uninstall_route(struct babel_route *route) uninstall_route(struct babel_route *route)
{ {
int rc;
if(!route->installed) if(!route->installed)
return; return;
rc = kernel_route(ROUTE_FLUSH, route->src->prefix, route->src->plen,
route->src->src_prefix, route->src->src_plen,
route->nexthop,
route->neigh->ifp->ifindex,
metric_to_kernel(route_metric(route)), NULL, 0, 0);
if(rc < 0)
perror("kernel_route(FLUSH)");
route->installed = 0; route->installed = 0;
kuninstall_route(route);
local_notify_route(route, LOCAL_CHANGE); local_notify_route(route, LOCAL_CHANGE);
} }
...@@ -559,19 +546,12 @@ switch_routes(struct babel_route *old, struct babel_route *new) ...@@ -559,19 +546,12 @@ switch_routes(struct babel_route *old, struct babel_route *new)
fprintf(stderr, "WARNING: switching to unfeasible route " fprintf(stderr, "WARNING: switching to unfeasible route "
"(this shouldn't happen)."); "(this shouldn't happen).");
rc = kernel_route(ROUTE_MODIFY, old->src->prefix, old->src->plen,
old->src->src_prefix, old->src->src_plen,
old->nexthop, old->neigh->ifp->ifindex,
metric_to_kernel(route_metric(old)),
new->nexthop, new->neigh->ifp->ifindex,
metric_to_kernel(route_metric(new)));
/* XXX : should the source-ip be subject to changes ? */ /* XXX : should the source-ip be subject to changes ? */
assert(memcmp(old->src->src_prefix, new->src->src_prefix, 16) == 0 assert(memcmp(old->src->src_prefix, new->src->src_prefix, 16) == 0
&& old->src->src_plen == new->src->src_plen); && old->src->src_plen == new->src->src_plen);
if(rc < 0) { rc = kswitch_routes(old, new);
perror("kernel_route(MODIFY)"); if(rc < 0)
return; return;
}
old->installed = 0; old->installed = 0;
new->installed = 1; new->installed = 1;
...@@ -595,16 +575,9 @@ change_route_metric(struct babel_route *route, ...@@ -595,16 +575,9 @@ change_route_metric(struct babel_route *route,
if(route->installed && old != new) { if(route->installed && old != new) {
int rc; int rc;
rc = kernel_route(ROUTE_MODIFY, route->src->prefix, route->src->plen, rc = kchange_route_metric(route, refmetric, cost, add);
route->src->src_prefix, route->src->src_plen, if(rc < 0)
route->nexthop, route->neigh->ifp->ifindex,
old,
route->nexthop, route->neigh->ifp->ifindex,
new);
if(rc < 0) {
perror("kernel_route(MODIFY metric)");
return; return;
}
} }
/* Update route->smoothed_metric using the old metric. */ /* Update route->smoothed_metric using the old metric. */
......
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