Skip to content

Commit 7378e00

Browse files
author
Hugo Laloge
committed
Send locators updates to peers&routers
When updating the locators after a network change, send the new locators to the routers and the peers if in linkstate mode.
1 parent e74c967 commit 7378e00

File tree

7 files changed

+60
-1
lines changed

7 files changed

+60
-1
lines changed

zenoh/src/net/protocol/network.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,21 @@ impl Network {
987987
}
988988
}
989989

990+
pub(crate) fn update_locators(&mut self) {
991+
self.graph[self.idx].sn += 1;
992+
self.send_on_links(
993+
vec![(
994+
self.idx,
995+
Details {
996+
zid: false,
997+
locators: true,
998+
links: self.full_linkstate || self.router_peers_failover_brokering,
999+
},
1000+
)],
1001+
|link| link.transport.get_whatami().unwrap_or(WhatAmI::Peer) == WhatAmI::Router,
1002+
);
1003+
}
1004+
9901005
fn remove_detached_nodes(&mut self) -> Vec<(NodeIndex, Node)> {
9911006
let mut dfs_stack = vec![self.idx];
9921007
let mut visit_map = self.graph.visit_map();

zenoh/src/net/routing/hat/linkstate_peer/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ impl HatBaseTrait for HatCode {
277277
Ok(())
278278
}
279279

280+
fn update_self_locators(&self, tables: &mut Tables) {
281+
if let Some(net) = hat_mut!(tables).linkstatepeers_net.as_mut() {
282+
net.update_locators();
283+
}
284+
}
285+
280286
fn close_face(
281287
&self,
282288
tables: &TablesLock,

zenoh/src/net/routing/hat/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ pub(crate) trait HatBaseTrait {
105105
send_declare: &mut SendDeclare,
106106
) -> ZResult<()>;
107107

108+
fn update_self_locators(&self, _tables: &mut Tables) {}
109+
108110
fn handle_oam(
109111
&self,
110112
tables: &mut Tables,

zenoh/src/net/routing/hat/p2p_peer/gossip.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,4 +605,19 @@ impl Network {
605605
}
606606
vec![]
607607
}
608+
609+
pub(super) fn update_locators(&mut self) {
610+
self.graph[self.idx].sn += 1;
611+
self.send_on_links(
612+
vec![(
613+
self.idx,
614+
Details {
615+
zid: false,
616+
locators: true,
617+
links: self.router_peers_failover_brokering,
618+
},
619+
)],
620+
|link| link.transport.get_whatami().unwrap_or(WhatAmI::Peer) == WhatAmI::Router,
621+
);
622+
}
608623
}

zenoh/src/net/routing/hat/p2p_peer/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ impl HatBaseTrait for HatCode {
219219
Ok(())
220220
}
221221

222+
fn update_self_locators(&self, tables: &mut Tables) {
223+
if let Some(net) = hat_mut!(tables).gossip.as_mut() {
224+
net.update_locators();
225+
}
226+
}
227+
222228
fn close_face(
223229
&self,
224230
tables: &TablesLock,

zenoh/src/net/routing/hat/router/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,15 @@ impl HatBaseTrait for HatCode {
460460
Ok(())
461461
}
462462

463+
fn update_self_locators(&self, tables: &mut Tables) {
464+
if let Some(net) = hat_mut!(tables).routers_net.as_mut() {
465+
net.update_locators();
466+
}
467+
if let Some(net) = hat_mut!(tables).linkstatepeers_net.as_mut() {
468+
net.update_locators();
469+
}
470+
}
471+
463472
fn close_face(
464473
&self,
465474
tables: &TablesLock,

zenoh/src/net/runtime/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,13 @@ impl Runtime {
449449

450450
update_iface_cache();
451451
self.update_locators();
452-
// TODO Transmit new locators to peers?
452+
453+
{
454+
let tables_lock = &self.state.router.tables;
455+
let _ctrl_lock = zlock!(tables_lock.ctrl_lock);
456+
let mut tables = zwrite!(tables_lock.tables);
457+
tables_lock.hat_code.update_self_locators(&mut tables);
458+
}
453459

454460
let scouting = self.state.scouting.lock().await;
455461
if let Some(scouting) = scouting.as_ref() {

0 commit comments

Comments
 (0)