From bfd7922e3e8a1d1f89ab9794809d4f80a91fbbec Mon Sep 17 00:00:00 2001 From: Ryan Goodfellow Date: Mon, 29 Jan 2024 12:52:12 -0800 Subject: [PATCH] a bit of cleanup --- nexus/src/app/background/bfd.rs | 8 ++++++-- nexus/src/app/bfd.rs | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nexus/src/app/background/bfd.rs b/nexus/src/app/background/bfd.rs index 681066d5b8a..a586db54e4c 100644 --- a/nexus/src/app/background/bfd.rs +++ b/nexus/src/app/background/bfd.rs @@ -36,6 +36,7 @@ impl BfdManager { struct BfdSessionKey { switch: SwitchLocation, + local: Option, remote: IpAddr, detection_threshold: u8, required_rx: u64, @@ -70,6 +71,7 @@ impl From for BfdSessionKey { Self { switch: value.switch.parse().unwrap(), //TODO unwrap remote: value.remote.ip(), + local: value.local.map(|x| x.ip()), detection_threshold: value .detection_threshold .0 @@ -125,6 +127,7 @@ impl BackgroundTask for BfdManager { }; for info in &client_current { current.insert(BfdSessionKey { + local: Some(info.config.listen), remote: info.config.peer, detection_threshold: info.config.detection_threshold, required_rx: info.config.required_rx, @@ -170,7 +173,7 @@ impl BackgroundTask for BfdManager { .add_bfd_peer(&BfdPeerConfig { peer: x.remote, detection_threshold: x.detection_threshold, - listen: Ipv4Addr::UNSPECIFIED.into(), + listen: x.local.unwrap_or(Ipv4Addr::UNSPECIFIED.into()), mode: match x.mode { BfdMode::SingleHop => SessionMode::SingleHop, BfdMode::MultiHop => SessionMode::MultiHop, @@ -204,7 +207,8 @@ impl BackgroundTask for BfdManager { } } - //TODO parameter updates + // TODO parameter updates + // https://github.com/oxidecomputer/omicron/issues/4921 json!({}) } diff --git a/nexus/src/app/bfd.rs b/nexus/src/app/bfd.rs index eed06dffeef..2d95ad9a586 100644 --- a/nexus/src/app/bfd.rs +++ b/nexus/src/app/bfd.rs @@ -33,6 +33,8 @@ impl super::Nexus { opctx: &OpContext, session: params::BfdSessionEnable, ) -> Result<(), Error> { + // add the bfd session to the db and trigger the bfd manager to handle + // the reset self.datastore().bfd_session_create(opctx, &session).await?; self.background_tasks .driver @@ -45,6 +47,8 @@ impl super::Nexus { opctx: &OpContext, session: params::BfdSessionDisable, ) -> Result<(), Error> { + // remove the bfd session from the db and trigger the bfd manager to + // handle the reset self.datastore().bfd_session_delete(opctx, &session).await?; self.background_tasks .driver @@ -56,6 +60,8 @@ impl super::Nexus { &self, _opctx: &OpContext, ) -> Result, Error> { + // ask each rack switch about all its BFD sessions. This will need to + // be updated for multirack. let mut result = Vec::new(); for s in &[SwitchLocation::Switch0, SwitchLocation::Switch1] { let mg_client = self.mg_client_for_switch_location(*s)?;