[B.A.T.M.A.N.] [RFC 09/10] batman-adv: adapt the neighbor purging routine to use the new API functions

Antonio Quartulli
2013-05-28T22:20:49Z

From: Antonio Quartulli <antonio@open-mesh.com>

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
originator.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/originator.c b/originator.c
index 3f05e08..f7fc006 100644
--- a/originator.c
+++ b/originator.c
@@ -377,6 +377,8 @@ batadv_purge_orig_neighbors(struct batadv_priv *bat_priv,
bool neigh_purged = false;
unsigned long last_seen;
struct batadv_hard_iface *if_incoming;
+ struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
+ uint32_t neigh_metric, best_metric;

*best_neigh_node = NULL;

@@ -411,10 +413,13 @@ batadv_purge_orig_neighbors(struct batadv_priv *bat_priv,
batadv_bonding_candidate_del(orig_node, neigh_node);
batadv_neigh_node_free_ref(neigh_node);
} else {
- if ((!*best_neigh_node) ||
- (neigh_node->bat_iv.tq_avg >
- (*best_neigh_node)->bat_iv.tq_avg))
+ neigh_metric = bao->bat_metric_get(neigh_node);
+ if (!*best_neigh_node ||
+ bao->bat_metric_compare(neigh_metric,
+ best_metric) > 0) {
*best_neigh_node = neigh_node;
+ best_metric = bao->bat_metric_get(neigh_node);
+ }
}
}

--
1.8.1.5