From d5b641e7dce246b8e512ff2f7a188467f7c4ead6 Mon Sep 17 00:00:00 2001 From: Lee Smet Date: Mon, 6 Nov 2023 14:16:11 +0100 Subject: [PATCH] Set proper seqno when distributing routes Signed-off-by: Lee Smet --- src/router.rs | 10 +++++----- src/routing_table.rs | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/router.rs b/src/router.rs index d2090f1..699cb0d 100644 --- a/src/router.rs +++ b/src/router.rs @@ -747,12 +747,12 @@ impl RouterInner { fn propagate_selected_routes(&self, router_id: RouterId) -> Vec { let mut updates = vec![]; - for sr in self.selected_routing_table.iter() { + for (sre, srk) in self.selected_routing_table.iter() { for peer in self.peer_interfaces.iter() { let peer_link_cost = peer.link_cost(); // convert sr.0.prefix to ipv6 addr - let addr = if let IpAddr::V6(addr) = sr.0.subnet().address() { + let addr = if let IpAddr::V6(addr) = sre.subnet().address() { addr } else { continue; @@ -768,10 +768,10 @@ impl RouterInner { let update = babel::Update::new( UPDATE_INTERVAL, - self.router_seqno, // updates receive the seqno of the router - sr.1.metric() + Metric::from(peer_link_cost), + srk.seqno(), // updates receive the seqno of the router + srk.metric() + Metric::from(peer_link_cost), // the cost of the route is the cost of the route + the cost of the link to the peer - sr.0.subnet(), + sre.subnet(), // we looked for the router_id, which is a public key, in the dest_pubkey_map // if the router_id is not in the map, then the route came from the node itself og_sender_pubkey, diff --git a/src/routing_table.rs b/src/routing_table.rs index 088c859..5c57b0f 100644 --- a/src/routing_table.rs +++ b/src/routing_table.rs @@ -144,6 +144,11 @@ impl RouteEntry { self.source } + /// Returns the [`SeqNo`] associated with this `RouteEntry`. + pub const fn seqno(&self) -> SeqNo { + self.seqno + } + /// Returns the metric associated with this `RouteEntry`. pub const fn metric(&self) -> Metric { self.metric