Skip to content

Commit

Permalink
a bit of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rcgoodfellow committed Jan 29, 2024
1 parent 05550f8 commit bfd7922
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nexus/src/app/background/bfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl BfdManager {

struct BfdSessionKey {
switch: SwitchLocation,
local: Option<IpAddr>,
remote: IpAddr,
detection_threshold: u8,
required_rx: u64,
Expand Down Expand Up @@ -70,6 +71,7 @@ impl From<BfdSession> 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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -204,7 +207,8 @@ impl BackgroundTask for BfdManager {
}
}

//TODO parameter updates
// TODO parameter updates
// https://github.com/oxidecomputer/omicron/issues/4921

json!({})
}
Expand Down
6 changes: 6 additions & 0 deletions nexus/src/app/bfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -56,6 +60,8 @@ impl super::Nexus {
&self,
_opctx: &OpContext,
) -> Result<Vec<BfdStatus>, 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)?;
Expand Down

0 comments on commit bfd7922

Please sign in to comment.