net: route: Verify if neighbor entry is in use when iterating

Verify the `ref` value of the neighbor entry in `net_route_foreach()`,
so that it only executes the callback on routes in use. Otherwise, the
function could call the callback for the route that has already been
deleted.

This could be encountered when executing `net route` shell command,
which printed the already deleted routes along the existing ones.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2021-12-02 12:13:32 +01:00 committed by Carles Cufí
parent c097b8f80e
commit 6fe1c9041b

View file

@ -624,6 +624,10 @@ int net_route_foreach(net_route_cb_t cb, void *user_data)
continue;
}
if (!nbr->ref) {
continue;
}
route = net_route_data(nbr);
if (!route) {
continue;