Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clients/nexus-lockstep-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ progenitor::generate_api!(
},
replace = {
BaseboardId = sled_hardware_types::BaseboardId,
BfdMode = omicron_common::api::internal::shared::BfdMode,
// It's kind of unfortunate to pull in such a complex and unstable type
// as "blueprint" this way, but we have really useful functionality
// (e.g., diff'ing) that's implemented on our local type.
Expand Down
19 changes: 0 additions & 19 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3547,25 +3547,6 @@ pub struct BgpImported {
pub switch: SwitchLocation,
}

/// BFD connection mode.
#[derive(
Clone,
Copy,
Debug,
Deserialize,
Serialize,
JsonSchema,
PartialEq,
Eq,
Ord,
PartialOrd,
)]
#[serde(rename_all = "snake_case")]
pub enum BfdMode {
SingleHop,
MultiHop,
}

/// Configuration of inbound ICMP allowed by API services.
#[derive(
Clone,
Expand Down
1 change: 1 addition & 0 deletions common/src/api/internal/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub use external_ip::SourceNatConfigV4;
pub use external_ip::SourceNatConfigV6;

// Re-export latest version of rack_init types.
pub use rack_init::BfdMode;
pub use rack_init::BfdPeerConfig;
pub use rack_init::BgpConfig;
pub use rack_init::BgpPeerConfig;
Expand Down
1 change: 1 addition & 0 deletions common/src/api/internal/shared/rack_init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod impls;

// Re-export latest version types for convenience.
// Note: New versions of these types will be added to the top-level module.
pub use v1::BfdMode;
pub use v1::BfdPeerConfig;
pub use v1::LldpAdminStatus;
pub use v1::LldpPortConfig;
Expand Down
21 changes: 20 additions & 1 deletion common/src/api/internal/shared/rack_init/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//! Version 1 of rack init types.

use crate::api::external::{BfdMode, ImportExportPolicy};
use crate::api::external::ImportExportPolicy;
use oxnet::{IpNet, Ipv4Net, Ipv6Net};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -107,6 +107,25 @@ pub struct BfdPeerConfig {
pub switch: SwitchLocation,
}

/// BFD connection mode.
#[derive(
Clone,
Copy,
Debug,
Deserialize,
Serialize,
JsonSchema,
PartialEq,
Eq,
Ord,
PartialOrd,
)]
#[serde(rename_all = "snake_case")]
pub enum BfdMode {
SingleHop,
MultiHop,
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
pub struct RouteConfig {
/// The destination of the route.
Expand Down
17 changes: 9 additions & 8 deletions nexus/db-model/src/bfd.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use crate::{SqlU32, impl_enum_type};
use chrono::DateTime;
use chrono::Utc;
use ipnetwork::IpNetwork;
use nexus_db_schema::schema::bfd_session;
use nexus_types::external_api::bfd::ExternalBfdMode;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

Expand Down Expand Up @@ -42,15 +47,11 @@ pub struct BfdSession {
pub time_deleted: Option<DateTime<Utc>>,
}

impl From<omicron_common::api::external::BfdMode> for BfdMode {
fn from(value: omicron_common::api::external::BfdMode) -> Self {
impl From<ExternalBfdMode> for BfdMode {
fn from(value: ExternalBfdMode) -> Self {
match value {
omicron_common::api::external::BfdMode::SingleHop => {
BfdMode::SingleHop
}
omicron_common::api::external::BfdMode::MultiHop => {
BfdMode::MultiHop
}
ExternalBfdMode::SingleHop => BfdMode::SingleHop,
ExternalBfdMode::MultiHop => BfdMode::MultiHop,
}
}
}
5 changes: 3 additions & 2 deletions nexus/src/app/bfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use mg_admin_client::types::BfdPeerState;
use nexus_db_queries::context::OpContext;
use nexus_types::external_api::bfd;
use nexus_types::external_api::bfd::ExternalBfdMode;
use nexus_types::external_api::networking;
use omicron_common::api::{external::Error, internal::shared::SwitchLocation};

Expand Down Expand Up @@ -95,10 +96,10 @@ impl super::Nexus {
required_rx: info.config.required_rx,
mode: match info.config.mode {
mg_admin_client::types::SessionMode::SingleHop => {
omicron_common::api::external::BfdMode::SingleHop
ExternalBfdMode::SingleHop
}
mg_admin_client::types::SessionMode::MultiHop => {
omicron_common::api::external::BfdMode::MultiHop
ExternalBfdMode::MultiHop
}
},
})
Expand Down
3 changes: 2 additions & 1 deletion nexus/tests/integration_tests/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use nexus_test_utils::SWITCH_UUID;
use nexus_test_utils::resource_helpers::test_params;
use nexus_types::external_api::affinity;
use nexus_types::external_api::alert;
use nexus_types::external_api::bfd;
use nexus_types::external_api::certificate;
use nexus_types::external_api::disk;
use nexus_types::external_api::external_subnet;
Expand Down Expand Up @@ -1030,7 +1031,7 @@ pub static DEMO_BFD_ENABLE: LazyLock<networking::BfdSessionEnable> =
detection_threshold: 3,
required_rx: 1000000,
switch: "switch0".parse().unwrap(),
mode: omicron_common::api::external::BfdMode::MultiHop,
mode: bfd::ExternalBfdMode::MultiHop,
});

pub static DEMO_BFD_DISABLE: LazyLock<networking::BfdSessionDisable> =
Expand Down
1 change: 0 additions & 1 deletion nexus/types/src/external_api/bfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
//! BFD (Bidirectional Forwarding Detection) types.

pub use nexus_types_versions::latest::bfd::*;
pub use omicron_common::api::external::BfdMode;
23 changes: 21 additions & 2 deletions nexus/types/versions/src/initial/bfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use std::net::IpAddr;

use omicron_common::api::external::BfdMode;
use omicron_common::api::external::Name;
use schemars::JsonSchema;
use serde::Deserialize;
Expand Down Expand Up @@ -57,5 +56,25 @@ pub struct BfdStatus {
pub local: Option<IpAddr>,
pub detection_threshold: u8,
pub required_rx: u64,
pub mode: BfdMode,
pub mode: ExternalBfdMode,
}

/// BFD connection mode.
#[derive(
Clone,
Copy,
Debug,
Deserialize,
Serialize,
JsonSchema,
PartialEq,
Eq,
Ord,
PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[schemars(rename = "BfdMode")] // don't include "External..." in OpenAPI spec
pub enum ExternalBfdMode {
SingleHop,
MultiHop,
}
5 changes: 3 additions & 2 deletions nexus/types/versions/src/initial/networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
//! This includes address lot, switch port, BGP, BFD, and routing configuration
//! types.

use super::bfd::ExternalBfdMode;
use api_identity::ObjectIdentity;
use omicron_common::api::external;
use omicron_common::api::external::{
AddressLotKind, BfdMode, IdentityMetadata, IdentityMetadataCreateParams,
AddressLotKind, IdentityMetadata, IdentityMetadataCreateParams,
ImportExportPolicy, LinkFec, LinkSpeed, Name, NameOrId, ObjectIdentity,
SwitchLocation,
};
Expand Down Expand Up @@ -619,7 +620,7 @@ pub struct BfdSessionEnable {
pub switch: Name,

/// Select either single-hop (RFC 5881) or multi-hop (RFC 5883)
pub mode: BfdMode,
pub mode: ExternalBfdMode,
}

/// Information needed to disable a BFD session
Expand Down
1 change: 1 addition & 0 deletions nexus/types/versions/src/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub mod audit {
pub mod bfd {
pub use crate::v2025_11_20_00::bfd::BfdState;
pub use crate::v2025_11_20_00::bfd::BfdStatus;
pub use crate::v2025_11_20_00::bfd::ExternalBfdMode;
}

pub mod device {
Expand Down
4 changes: 2 additions & 2 deletions sled-agent/src/bootstrap/early_networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ use mg_admin_client::types::{
use omicron_common::OMICRON_DPD_TAG;
use omicron_common::address::DENDRITE_PORT;
use omicron_common::address::{MGD_PORT, MGS_PORT};
use omicron_common::api::external::{BfdMode, ImportExportPolicy};
use omicron_common::api::external::ImportExportPolicy;
use omicron_common::api::internal::shared::{
BgpConfig, BgpPeerConfig, PortConfig, PortFec, PortSpeed,
BfdMode, BgpConfig, BgpPeerConfig, PortConfig, PortFec, PortSpeed,
RackNetworkConfig, SwitchLocation,
};
use omicron_common::backoff::{
Expand Down
23 changes: 7 additions & 16 deletions sled-agent/src/rack_setup/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,22 +985,13 @@ impl ServiceInner {
bfd: config
.bfd
.iter()
.map(|spec| {
NexusTypes::BfdPeerConfig {
detection_threshold: spec.detection_threshold,
local: spec.local,
mode: match spec.mode {
omicron_common::api::external::BfdMode::SingleHop => {
NexusTypes::BfdMode::SingleHop
}
omicron_common::api::external::BfdMode::MultiHop => {
NexusTypes::BfdMode::MultiHop
}
},
remote: spec.remote,
required_rx: spec.required_rx,
switch: spec.switch.into(),
}
.map(|spec| NexusTypes::BfdPeerConfig {
detection_threshold: spec.detection_threshold,
local: spec.local,
mode: spec.mode,
remote: spec.remote,
required_rx: spec.required_rx,
switch: spec.switch.into(),
})
.collect(),
}
Expand Down
Loading