66
77use crate :: established_conn:: EstablishedConn ;
88use trust_quorum_protocol:: { BaseboardId , Envelope , PeerMsg } ;
9- // TODO: Move or copy this to this crate?
9+
10+ // TODO: Move to this crate
11+ // https://github.com/oxidecomputer/omicron/issues/9311
1012use bootstore:: schemes:: v0:: NetworkConfig ;
13+
1114use camino:: Utf8PathBuf ;
1215use iddqd:: {
1316 BiHashItem , BiHashMap , TriHashItem , TriHashMap , bi_upcast, tri_upcast,
@@ -91,26 +94,11 @@ pub struct ConnToMainMsg {
9194
9295#[ derive( Debug ) ]
9396pub enum ConnToMainMsgInner {
94- Accepted {
95- addr : SocketAddrV6 ,
96- peer_id : BaseboardId ,
97- } ,
98- Connected {
99- addr : SocketAddrV6 ,
100- peer_id : BaseboardId ,
101- } ,
102- Received {
103- from : BaseboardId ,
104- msg : PeerMsg ,
105- } ,
106- #[ expect( unused) ]
107- ReceivedNetworkConfig {
108- from : BaseboardId ,
109- config : NetworkConfig ,
110- } ,
111- Disconnected {
112- peer_id : BaseboardId ,
113- } ,
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 } ,
114102}
115103
116104pub struct TaskHandle {
@@ -135,6 +123,13 @@ impl TaskHandle {
135123 pub async fn send ( & self , msg : PeerMsg ) {
136124 let _ = self . tx . send ( MainToConnMsg :: Msg ( WireMsg :: Tq ( msg) ) ) . await ;
137125 }
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+ }
138133}
139134
140135impl BiHashItem for TaskHandle {
@@ -385,6 +380,45 @@ impl ConnMgr {
385380 }
386381 }
387382
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+
388422 /// Perform any polling related operations that the connection
389423 /// manager must perform concurrently.
390424 pub async fn step (
0 commit comments