Commit 11cae119 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Call local_update_neighbour from update_neighbour_metric.

This fixes a bug where we forgot to call local_update_neighbour
when receiving an IHU.  Reported by Gabriel Kerneis.
parent 4efe9cab
...@@ -231,10 +231,12 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -231,10 +231,12 @@ parse_packet(const unsigned char *from, struct network *net,
format_address(from), net->ifname, format_address(from), net->ifname,
format_address(address)); format_address(address));
if(message[2] == 0 || network_ll_address(net, address)) { if(message[2] == 0 || network_ll_address(net, address)) {
int changed = txcost != neigh->txcost;
neigh->txcost = txcost; neigh->txcost = txcost;
neigh->ihu_time = now; neigh->ihu_time = now;
neigh->ihu_interval = interval; neigh->ihu_interval = interval;
update_neighbour_metric(neigh); if(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);
} }
......
...@@ -105,7 +105,8 @@ find_neighbour(const unsigned char *address, struct network *net) ...@@ -105,7 +105,8 @@ find_neighbour(const unsigned char *address, struct network *net)
return neigh; return neigh;
} }
/* Recompute a neighbour's rxcost. Return true if anything changed. */ /* Recompute a neighbour's rxcost. Return true if anything changed.
This does not call local_notify_neighbour, see update_neighbour_metric. */
int int
update_neighbour(struct neighbour *neigh, int hello, int hello_interval) update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
{ {
...@@ -190,8 +191,6 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval) ...@@ -190,8 +191,6 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
send_unicast_request(neigh, NULL, 0); send_unicast_request(neigh, NULL, 0);
send_ihu(neigh, NULL); send_ihu(neigh, NULL);
} }
if(rc)
local_notify_neighbour(neigh, LOCAL_CHANGE);
return rc; return rc;
} }
...@@ -248,10 +247,8 @@ check_neighbours() ...@@ -248,10 +247,8 @@ check_neighbours()
rc = reset_txcost(neigh); rc = reset_txcost(neigh);
changed = changed || rc; changed = changed || rc;
if(changed) { if(changed)
update_neighbour_metric(neigh); update_neighbour_metric(neigh);
local_notify_neighbour(neigh, LOCAL_CHANGE);
}
if(neigh->hello_interval > 0) if(neigh->hello_interval > 0)
msecs = MIN(msecs, neigh->hello_interval * 10); msecs = MIN(msecs, neigh->hello_interval * 10);
......
...@@ -361,6 +361,8 @@ update_route_metric(struct route *route) ...@@ -361,6 +361,8 @@ update_route_metric(struct route *route)
} }
} }
/* Called whenever a neighbour's cost changes, to update the metric of
all routes through that neighbour. Calls local_notify_neighbour. */
void void
update_neighbour_metric(struct neighbour *neigh) update_neighbour_metric(struct neighbour *neigh)
{ {
...@@ -372,6 +374,7 @@ update_neighbour_metric(struct neighbour *neigh) ...@@ -372,6 +374,7 @@ update_neighbour_metric(struct neighbour *neigh)
update_route_metric(&routes[i]); update_route_metric(&routes[i]);
i++; i++;
} }
local_notify_neighbour(neigh, LOCAL_CHANGE);
} }
void void
......
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