From 33251c4c5262cf83176110d61fe1e42a52f5e7c0 Mon Sep 17 00:00:00 2001 From: Lee Smet Date: Wed, 31 Jan 2024 12:56:35 +0100 Subject: [PATCH] Close #95: Account for link cost in route select Signed-off-by: Lee Smet --- src/router.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/router.rs b/src/router.rs index 4c0fd24..dadc5a6 100644 --- a/src/router.rs +++ b/src/router.rs @@ -798,7 +798,9 @@ impl Router { // If we swap to an actually different route, only do so if the metric is // significantly better OR if it is directly connected (metric 0). if (best.source() != current.source() || best.neighbour() != current.neighbour()) - && !(best.metric() < current.metric() - SIGNIFICANT_METRIC_IMPROVEMENT + && !(best.metric() + Metric::from(best.neighbour().link_cost()) + < current.metric() + Metric::from(current.neighbour().link_cost()) + - SIGNIFICANT_METRIC_IMPROVEMENT || best.metric().is_direct()) { debug!("maintaining currently selected route since new route is not significantly better");