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 ...@@ -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 whether link quality estimation is being done. The default is 96 for wired
interfaces, and 256 for wireless ones. interfaces, and 256 for wireless ones.
.TP .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" .BI channel " channel"
Sets the channel for this interface. The value Sets the channel for this interface. The value
.I channel .I channel
......
...@@ -406,6 +406,12 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure, ...@@ -406,6 +406,12 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
if(c < -1 || cost <= 0 || cost > 0xFFFF) if(c < -1 || cost <= 0 || cost > 0xFFFF)
goto error; goto error;
if_conf->cost = cost; 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) { } else if(strcmp(token, "hello-interval") == 0) {
int interval; int interval;
c = getthousands(c, &interval, gnc, closure); c = getthousands(c, &interval, gnc, closure);
...@@ -569,6 +575,7 @@ merge_ifconf(struct interface_conf *dest, ...@@ -569,6 +575,7 @@ merge_ifconf(struct interface_conf *dest,
MERGE(hello_interval); MERGE(hello_interval);
MERGE(update_interval); MERGE(update_interval);
MERGE(cost); MERGE(cost);
MERGE(legacy_cost);
MERGE(wired); MERGE(wired);
MERGE(split_horizon); MERGE(split_horizon);
MERGE(lq); MERGE(lq);
......
...@@ -289,6 +289,7 @@ interface_up(struct interface *ifp, int up) ...@@ -289,6 +289,7 @@ interface_up(struct interface *ifp, int up)
else else
ifp->flags |= IF_LQ; ifp->flags |= IF_LQ;
} }
ifp->legacy_cost = IF_CONF(ifp, legacy_cost);
if(IF_CONF(ifp, faraway) == CONFIG_YES) if(IF_CONF(ifp, faraway) == CONFIG_YES)
ifp->flags |= IF_FARAWAY; ifp->flags |= IF_FARAWAY;
......
...@@ -32,6 +32,7 @@ struct interface_conf { ...@@ -32,6 +32,7 @@ struct interface_conf {
unsigned hello_interval; unsigned hello_interval;
unsigned update_interval; unsigned update_interval;
unsigned short cost; unsigned short cost;
unsigned short legacy_cost;
char wired; char wired;
char split_horizon; char split_horizon;
char lq; char lq;
...@@ -94,6 +95,7 @@ struct interface { ...@@ -94,6 +95,7 @@ struct interface {
time_t bucket_time; time_t bucket_time;
unsigned int bucket; unsigned int bucket;
time_t last_update_time; time_t last_update_time;
unsigned short legacy_cost;
unsigned short hello_seqno; unsigned short hello_seqno;
unsigned hello_interval; unsigned hello_interval;
unsigned update_interval; unsigned update_interval;
......
...@@ -267,20 +267,25 @@ check_neighbours() ...@@ -267,20 +267,25 @@ check_neighbours()
unsigned unsigned
neighbour_rxcost(struct neighbour *neigh) neighbour_rxcost(struct neighbour *neigh)
{ {
unsigned delay; unsigned delay, cost;
unsigned short reach = neigh->reach; unsigned short reach = neigh->reach;
struct interface *ifp;
delay = timeval_minus_msec(&now, &neigh->hello_time); delay = timeval_minus_msec(&now, &neigh->hello_time);
if((reach & 0xFFF0) == 0 || delay >= 180000) { if((reach & 0xFFF0) == 0 || delay >= 180000)
return INFINITY; 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 = int sreach =
((reach & 0x8000) >> 2) + ((reach & 0x8000) >> 2) +
((reach & 0x4000) >> 1) + ((reach & 0x4000) >> 1) +
(reach & 0x3FFF); (reach & 0x3FFF);
/* 0 <= sreach <= 0x7FFF */ /* 0 <= sreach <= 0x7FFF */
int cost = (0x8000 * neigh->ifp->cost) / (sreach + 1); cost = (0x8000 * cost) / (sreach + 1);
/* cost >= interface->cost */ /* cost >= interface->cost */
if(delay >= 40000) if(delay >= 40000)
cost = (cost * (delay - 20000) + 10000) / 20000; cost = (cost * (delay - 20000) + 10000) / 20000;
...@@ -288,11 +293,11 @@ neighbour_rxcost(struct neighbour *neigh) ...@@ -288,11 +293,11 @@ neighbour_rxcost(struct neighbour *neigh)
} else { } else {
/* To lose one hello is a misfortune, to lose two is carelessness. */ /* To lose one hello is a misfortune, to lose two is carelessness. */
if((reach & 0xC000) == 0xC000) if((reach & 0xC000) == 0xC000)
return neigh->ifp->cost; return cost;
else if((reach & 0xC000) == 0) else if((reach & 0xC000) == 0)
return INFINITY; return INFINITY;
else if((reach & 0x2000)) else if((reach & 0x2000))
return neigh->ifp->cost; return cost;
else else
return INFINITY; 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