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