Commit f4c88749 authored by Julien Muchembled's avatar Julien Muchembled

New legacy-cost interface option for compatibility purpose

parent f5360dfe
Pipeline #299 skipped
......@@ -304,6 +304,13 @@ for computing metrics of routes going through this interface depends on
whether link quality estimation is being done. The default is 96 for wired
interfaces, and 256 for wireless ones.
.TP
.BI legacy\-rxcost " cost"
This overrides the interface rxcost when when RTT can not be computed, usually
because the neighbour runs an old version of Babel. This parameter exists
mainly for compatibility purpose and without it, the first nodes that are
upgraded to use RTT-based cost would be overrated. By default, rxcost is not
overridden.
.TP
.BI channel " channel"
Sets the channel for this interface. The value
.I channel
......
......@@ -406,6 +406,12 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
if(c < -1 || cost <= 0 || cost > 0xFFFF)
goto error;
if_conf->cost = cost;
} else if(strcmp(token, "legacy-rxcost") == 0) {
int cost;
c = getint(c, &cost, gnc, closure);
if(c < -1 || cost <= 0 || cost > 0xFFFF)
goto error;
if_conf->legacy_cost = cost;
} else if(strcmp(token, "hello-interval") == 0) {
int interval;
c = getthousands(c, &interval, gnc, closure);
......@@ -569,6 +575,7 @@ merge_ifconf(struct interface_conf *dest,
MERGE(hello_interval);
MERGE(update_interval);
MERGE(cost);
MERGE(legacy_cost);
MERGE(wired);
MERGE(split_horizon);
MERGE(lq);
......
......@@ -289,6 +289,7 @@ interface_up(struct interface *ifp, int up)
else
ifp->flags |= IF_LQ;
}
ifp->legacy_cost = IF_CONF(ifp, legacy_cost);
if(IF_CONF(ifp, faraway) == CONFIG_YES)
ifp->flags |= IF_FARAWAY;
......
......@@ -32,6 +32,7 @@ struct interface_conf {
unsigned hello_interval;
unsigned update_interval;
unsigned short cost;
unsigned short legacy_cost;
char wired;
char split_horizon;
char lq;
......@@ -94,6 +95,7 @@ struct interface {
time_t bucket_time;
unsigned int bucket;
time_t last_update_time;
unsigned short legacy_cost;
unsigned short hello_seqno;
unsigned hello_interval;
unsigned update_interval;
......
......@@ -267,20 +267,25 @@ check_neighbours()
unsigned
neighbour_rxcost(struct neighbour *neigh)
{
unsigned delay;
unsigned delay, cost;
unsigned short reach = neigh->reach;
struct interface *ifp;
delay = timeval_minus_msec(&now, &neigh->hello_time);
if((reach & 0xFFF0) == 0 || delay >= 180000) {
if((reach & 0xFFF0) == 0 || delay >= 180000)
return INFINITY;
} else if((neigh->ifp->flags & IF_LQ)) {
ifp = neigh->ifp;
cost = ifp->max_rtt_penalty && !valid_rtt(neigh) && ifp->legacy_cost
? ifp->legacy_cost : ifp->cost;
if((neigh->ifp->flags & IF_LQ)) {
int sreach =
((reach & 0x8000) >> 2) +
((reach & 0x4000) >> 1) +
(reach & 0x3FFF);
/* 0 <= sreach <= 0x7FFF */
int cost = (0x8000 * neigh->ifp->cost) / (sreach + 1);
cost = (0x8000 * cost) / (sreach + 1);
/* cost >= interface->cost */
if(delay >= 40000)
cost = (cost * (delay - 20000) + 10000) / 20000;
......@@ -288,11 +293,11 @@ neighbour_rxcost(struct neighbour *neigh)
} else {
/* To lose one hello is a misfortune, to lose two is carelessness. */
if((reach & 0xC000) == 0xC000)
return neigh->ifp->cost;
return cost;
else if((reach & 0xC000) == 0)
return INFINITY;
else if((reach & 0x2000))
return neigh->ifp->cost;
return cost;
else
return INFINITY;
}
......
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