Commit d839fc55 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

More smarts when forwarding requests.

parent 655c4f3d
......@@ -268,7 +268,7 @@ handle_request(struct neighbour *neigh, const unsigned char *prefix,
route = find_installed_route(prefix, plen);
if(!route || route->metric >= INFINITY || route->neigh == neigh)
route = find_best_route(prefix, plen, 0);
route = find_best_route(prefix, plen, 0, neigh);
if(!route || route->metric >= INFINITY || route->neigh == neigh)
return;
if(router_hash == hash_id(route->src->address) &&
......
......@@ -242,7 +242,8 @@ update_feasible(const unsigned char *a,
/* This returns the feasible route with the smallest metric. */
struct route *
find_best_route(const unsigned char *prefix, unsigned char plen, int feasible)
find_best_route(const unsigned char *prefix, unsigned char plen, int feasible,
struct neighbour *exclude)
{
struct route *route = NULL;
int i;
......@@ -254,6 +255,8 @@ find_best_route(const unsigned char *prefix, unsigned char plen, int feasible)
continue;
if(feasible && !route_feasible(&routes[i]))
continue;
if(exclude && routes[i].neigh == exclude)
continue;
if(route && route->metric <= routes[i].metric)
continue;
route = &routes[i];
......@@ -575,7 +578,7 @@ trigger_route_change(struct route *route,
if(route->metric > oldmetric) {
struct route *better_route;
better_route =
find_best_route(route->src->prefix, route->src->plen, 1);
find_best_route(route->src->prefix, route->src->plen, 1, NULL);
if(better_route && better_route->metric <= route->metric - 96)
consider_route(better_route);
}
......@@ -593,7 +596,7 @@ void
route_lost(struct source *src, int oldmetric)
{
struct route *new_route;
new_route = find_best_route(src->prefix, src->plen, 1);
new_route = find_best_route(src->prefix, src->plen, 1, NULL);
if(new_route) {
consider_route(new_route);
} else {
......
......@@ -54,7 +54,7 @@ int update_feasible(const unsigned char *a,
const unsigned char *p, unsigned char plen,
unsigned short seqno, unsigned short refmetric);
struct route *find_best_route(const unsigned char *prefix, unsigned char plen,
int feasible);
int feasible, struct neighbour *exclude);
struct route *install_best_route(const unsigned char prefix[16],
unsigned char plen);
void update_neighbour_metric(struct neighbour *neigh);
......
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