Commit 82578ef4 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Avoid scanning the source table in update_route.

Yeah, it's a hack.
parent 4a0308bf
...@@ -680,13 +680,20 @@ update_route(const unsigned char *id, ...@@ -680,13 +680,20 @@ update_route(const unsigned char *id,
if(add_metric >= INFINITY) if(add_metric >= INFINITY)
return NULL; return NULL;
route = find_route(prefix, plen, neigh, nexthop);
if(route && memcmp(route->src->id, id, 8) == 0)
/* Avoid scanning the source table. */
src = route->src;
else
src = find_source(id, prefix, plen, 1, seqno); src = find_source(id, prefix, plen, 1, seqno);
if(src == NULL) if(src == NULL)
return NULL; return NULL;
feasible = update_feasible(src, seqno, refmetric); feasible = update_feasible(src, seqno, refmetric);
route = find_route(prefix, plen, neigh, nexthop);
metric = MIN((int)refmetric + neighbour_cost(neigh) + add_metric, INFINITY); metric = MIN((int)refmetric + neighbour_cost(neigh) + add_metric, INFINITY);
if(route) { if(route) {
struct source *oldsrc; struct source *oldsrc;
unsigned short oldmetric; unsigned short oldmetric;
......
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