Skip to content

Commit c6a222a

Browse files
authored
TQ: Implement network config replication (#9317)
This builds on #9310 This code essentially re-implements the bootstore implementation of early network config replication over sprockets channels. The persistence code of this state still lives in the bootstore, but will eventually move to the `trust-quorum` crate once all customer systems are running only trust quorum. This code does not deal with how the switchover from bootstore to to trust-quorum is made. That will come later with trust-quorum / sled-agent integration.
1 parent fa58725 commit c6a222a

File tree

2 files changed

+445
-62
lines changed

2 files changed

+445
-62
lines changed

trust-quorum/src/connection_manager.rs

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,11 @@ pub struct ConnToMainMsg {
9494

9595
#[derive(Debug)]
9696
pub enum ConnToMainMsgInner {
97-
Accepted {
98-
addr: SocketAddrV6,
99-
peer_id: BaseboardId,
100-
},
101-
Connected {
102-
addr: SocketAddrV6,
103-
peer_id: BaseboardId,
104-
},
105-
Received {
106-
from: BaseboardId,
107-
msg: PeerMsg,
108-
},
109-
#[expect(unused)]
110-
ReceivedNetworkConfig {
111-
from: BaseboardId,
112-
config: NetworkConfig,
113-
},
114-
Disconnected {
115-
peer_id: BaseboardId,
116-
},
97+
Accepted { addr: SocketAddrV6, peer_id: BaseboardId },
98+
Connected { addr: SocketAddrV6, peer_id: BaseboardId },
99+
Received { from: BaseboardId, msg: PeerMsg },
100+
ReceivedNetworkConfig { from: BaseboardId, config: NetworkConfig },
101+
Disconnected { peer_id: BaseboardId },
117102
}
118103

119104
pub struct TaskHandle {
@@ -138,6 +123,13 @@ impl TaskHandle {
138123
pub async fn send(&self, msg: PeerMsg) {
139124
let _ = self.tx.send(MainToConnMsg::Msg(WireMsg::Tq(msg))).await;
140125
}
126+
127+
pub async fn send_network_config(&self, config: NetworkConfig) {
128+
let _ = self
129+
.tx
130+
.send(MainToConnMsg::Msg(WireMsg::NetworkConfig(config)))
131+
.await;
132+
}
141133
}
142134

143135
impl BiHashItem for TaskHandle {
@@ -388,6 +380,45 @@ impl ConnMgr {
388380
}
389381
}
390382

383+
// After we have updated our network config, we should send it out to all
384+
// peers with established connections, with the exception of the peer we
385+
// received it from if this was not a local update.
386+
pub async fn broadcast_network_config(
387+
&mut self,
388+
network_config: &NetworkConfig,
389+
excluded_peer: Option<&BaseboardId>,
390+
) {
391+
for h in self
392+
.established
393+
.iter()
394+
.filter(|&h| Some(&h.baseboard_id) != excluded_peer)
395+
{
396+
info!(
397+
self.log,
398+
"Sending network config";
399+
"peer_id" => %h.baseboard_id,
400+
"generation" => network_config.generation
401+
);
402+
h.task_handle.send_network_config(network_config.clone()).await;
403+
}
404+
}
405+
406+
pub async fn send_network_config(
407+
&mut self,
408+
peer_id: &BaseboardId,
409+
network_config: &NetworkConfig,
410+
) {
411+
if let Some(h) = self.established.get1(peer_id) {
412+
info!(
413+
self.log,
414+
"Sending network config";
415+
"peer_id" => %h.baseboard_id,
416+
"generation" => network_config.generation
417+
);
418+
h.task_handle.send_network_config(network_config.clone()).await;
419+
}
420+
}
421+
391422
/// Perform any polling related operations that the connection
392423
/// manager must perform concurrently.
393424
pub async fn step(

0 commit comments

Comments
 (0)