Commit ec07953a authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Call local_notify_neighbour unconditionally.

Working out exactly when to call local_notify_neighbour is too
error-prone.  Call it systematically, at the cost of some extra
local traffic.
parent 11cae119
...@@ -213,8 +213,7 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -213,8 +213,7 @@ parse_packet(const unsigned char *from, struct network *net,
net->activity_time = now.tv_sec; net->activity_time = now.tv_sec;
update_hello_interval(net); update_hello_interval(net);
changed = update_neighbour(neigh, seqno, interval); changed = update_neighbour(neigh, seqno, interval);
if(changed) update_neighbour_metric(neigh, changed);
update_neighbour_metric(neigh);
if(interval > 0) if(interval > 0)
schedule_neighbours_check(interval * 10, 0); schedule_neighbours_check(interval * 10, 0);
} else if(type == MESSAGE_IHU) { } else if(type == MESSAGE_IHU) {
...@@ -235,8 +234,7 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -235,8 +234,7 @@ parse_packet(const unsigned char *from, struct network *net,
neigh->txcost = txcost; neigh->txcost = txcost;
neigh->ihu_time = now; neigh->ihu_time = now;
neigh->ihu_interval = interval; neigh->ihu_interval = interval;
if(changed) update_neighbour_metric(neigh, changed);
update_neighbour_metric(neigh);
if(interval > 0) if(interval > 0)
schedule_neighbours_check(interval * 10 * 3, 0); schedule_neighbours_check(interval * 10 * 3, 0);
} }
......
...@@ -247,8 +247,7 @@ check_neighbours() ...@@ -247,8 +247,7 @@ check_neighbours()
rc = reset_txcost(neigh); rc = reset_txcost(neigh);
changed = changed || rc; changed = changed || rc;
if(changed) update_neighbour_metric(neigh, changed);
update_neighbour_metric(neigh);
if(neigh->hello_interval > 0) if(neigh->hello_interval > 0)
msecs = MIN(msecs, neigh->hello_interval * 10); msecs = MIN(msecs, neigh->hello_interval * 10);
......
...@@ -364,8 +364,10 @@ update_route_metric(struct route *route) ...@@ -364,8 +364,10 @@ update_route_metric(struct route *route)
/* Called whenever a neighbour's cost changes, to update the metric of /* Called whenever a neighbour's cost changes, to update the metric of
all routes through that neighbour. Calls local_notify_neighbour. */ all routes through that neighbour. Calls local_notify_neighbour. */
void void
update_neighbour_metric(struct neighbour *neigh) update_neighbour_metric(struct neighbour *neigh, int changed)
{ {
if(changed) {
int i; int i;
i = 0; i = 0;
...@@ -374,6 +376,8 @@ update_neighbour_metric(struct neighbour *neigh) ...@@ -374,6 +376,8 @@ update_neighbour_metric(struct neighbour *neigh)
update_route_metric(&routes[i]); update_route_metric(&routes[i]);
i++; i++;
} }
}
local_notify_neighbour(neigh, LOCAL_CHANGE); local_notify_neighbour(neigh, LOCAL_CHANGE);
} }
......
...@@ -61,7 +61,7 @@ struct route *find_best_route(const unsigned char *prefix, unsigned char plen, ...@@ -61,7 +61,7 @@ struct route *find_best_route(const unsigned char *prefix, unsigned char plen,
int feasible, struct neighbour *exclude); int feasible, struct neighbour *exclude);
struct route *install_best_route(const unsigned char prefix[16], struct route *install_best_route(const unsigned char prefix[16],
unsigned char plen); unsigned char plen);
void update_neighbour_metric(struct neighbour *neigh); void update_neighbour_metric(struct neighbour *neigh, int changed);
void update_network_metric(struct network *net); void update_network_metric(struct network *net);
void update_route_metric(struct route *route); void update_route_metric(struct route *route);
struct route *update_route(const unsigned char *a, struct route *update_route(const unsigned char *a,
......
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