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

Make routes maintain all three components of a metric.

parent 209707c6
...@@ -259,7 +259,8 @@ change_route_metric(struct route *route, unsigned cost, unsigned add) ...@@ -259,7 +259,8 @@ change_route_metric(struct route *route, unsigned cost, unsigned add)
} }
} }
route->metric = newmetric; route->cost = cost;
route->add_metric = add;
local_notify_route(route, LOCAL_CHANGE); local_notify_route(route, LOCAL_CHANGE);
} }
...@@ -478,8 +479,9 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen, ...@@ -478,8 +479,9 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen,
route = &routes[numroutes]; route = &routes[numroutes];
route->src = src; route->src = src;
route->refmetric = refmetric; route->refmetric = refmetric;
route->cost = neighbour_cost(neigh);
route->add_metric = add_metric;
route->seqno = seqno; route->seqno = seqno;
route->metric = metric;
route->neigh = neigh; route->neigh = neigh;
memcpy(route->nexthop, nexthop, 16); memcpy(route->nexthop, nexthop, 16);
route->time = now.tv_sec; route->time = now.tv_sec;
......
...@@ -22,8 +22,9 @@ THE SOFTWARE. ...@@ -22,8 +22,9 @@ THE SOFTWARE.
struct route { struct route {
struct source *src; struct source *src;
unsigned short metric;
unsigned short refmetric; unsigned short refmetric;
unsigned short cost;
unsigned short add_metric;
unsigned short seqno; unsigned short seqno;
struct neighbour *neigh; struct neighbour *neigh;
unsigned char nexthop[16]; unsigned char nexthop[16];
...@@ -35,7 +36,8 @@ struct route { ...@@ -35,7 +36,8 @@ struct route {
static inline int static inline int
route_metric(const struct route *route) route_metric(const struct route *route)
{ {
return route->metric; int m = route->refmetric + route->cost + route->add_metric;
return MIN(m, INFINITY);
} }
extern struct route *routes; extern struct route *routes;
......
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