Commit 1486108f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Cleanup metric computation for non-interfering routes.

This moves all metric computation back to route.[ch],
where it belongs.
parent 794863e9
...@@ -961,25 +961,23 @@ flushupdates(struct network *net) ...@@ -961,25 +961,23 @@ flushupdates(struct network *net)
unsigned char channels[DIVERSITY_HOPS]; unsigned char channels[DIVERSITY_HOPS];
int chlen; int chlen;
struct network *route_net = route->neigh->network; struct network *route_net = route->neigh->network;
int metric; unsigned short metric;
unsigned short seqno; unsigned short seqno;
seqno = route->seqno; seqno = route->seqno;
metric = route_metric(route); metric =
route_interferes(route, net) ?
route_metric(route) :
route_metric_noninterfering(route);
if(metric < INFINITY) if(metric < INFINITY)
satisfy_request(route->src->prefix, route->src->plen, satisfy_request(route->src->prefix, route->src->plen,
seqno, route->src->id, net); seqno, route->src->id, net);
if((net->flags & NET_SPLIT_HORIZON) && if((net->flags & NET_SPLIT_HORIZON) &&
route->neigh->network == net) route->neigh->network == net)
continue; continue;
if(!route_interferes(route, net)) {
metric =
(int)route->refmetric +
(diversity_factor * route->cost + 128) / 256 +
route->add_metric;
metric = MIN(metric, INFINITY);
metric = MAX(metric, route->refmetric + 1);
}
if(route_net->channel == NET_CHANNEL_NONINTERFERING) { if(route_net->channel == NET_CHANNEL_NONINTERFERING) {
memcpy(channels, route->channels, DIVERSITY_HOPS); memcpy(channels, route->channels, DIVERSITY_HOPS);
} else { } else {
......
...@@ -41,6 +41,12 @@ struct route { ...@@ -41,6 +41,12 @@ struct route {
unsigned char channels[DIVERSITY_HOPS]; unsigned char channels[DIVERSITY_HOPS];
}; };
extern struct route *routes;
extern int numroutes, maxroutes;
extern int kernel_metric, allow_duplicates;
extern int diversity_kind, diversity_factor;
extern int keep_unfeasible;
static inline int static inline int
route_metric(const struct route *route) route_metric(const struct route *route)
{ {
...@@ -48,11 +54,16 @@ route_metric(const struct route *route) ...@@ -48,11 +54,16 @@ route_metric(const struct route *route)
return MIN(m, INFINITY); return MIN(m, INFINITY);
} }
extern struct route *routes; static inline int
extern int numroutes, maxroutes; route_metric_noninterfering(const struct route *route)
extern int kernel_metric, allow_duplicates; {
extern int diversity_kind, diversity_factor; int m =
extern int keep_unfeasible; (int)route->refmetric +
(diversity_factor * route->cost + 128) / 256 +
route->add_metric;
m = MAX(m, route->refmetric + 1);
return MIN(m, INFINITY);
}
struct route *find_route(const unsigned char *prefix, unsigned char plen, struct route *find_route(const unsigned char *prefix, unsigned char plen,
struct neighbour *neigh, const unsigned char *nexthop); struct neighbour *neigh, const unsigned char *nexthop);
......
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