Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions clients/wicketd-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ progenitor::generate_api!(
AllowedSourceIps = omicron_common::api::internal::shared::AllowedSourceIps,
ArtifactId = omicron_common::update::ArtifactId,
Baseboard = sled_hardware_types::Baseboard,
BgpAuthKey = wicket_common::rack_setup::BgpAuthKey,
BgpAuthKey = wicketd_commission_types_versions::latest::rack_setup::BgpAuthKey,
BgpAuthKeyId = wicketd_commission_types_versions::latest::rack_setup::BgpAuthKeyId,
BgpAuthKeyInfo = wicket_common::rack_setup::BgpAuthKeyInfo,
BgpAuthKeyStatus = wicket_common::rack_setup::BgpAuthKeyStatus,
Expand All @@ -50,7 +50,7 @@ progenitor::generate_api!(
BootstrapSledDescription = wicket_common::rack_setup::BootstrapSledDescription,
CertificateUploadResponse = wicketd_commission_types_versions::latest::rack_setup::CertificateUploadResponse,
ClearUpdateStateOptions = wicket_common::rack_update::ClearUpdateStateOptions,
ClearUpdateStateResponse = wicket_common::rack_update::ClearUpdateStateResponse,
ClearUpdateStateResponse = wicketd_commission_types_versions::latest::update::ClearUpdateStateResponse,
CurrentRssUserConfigInsensitive = wicket_common::rack_setup::CurrentRssUserConfigInsensitive,
Duration = std::time::Duration,
EventReportForUplinkPreflightCheckSpec = wicket_common::preflight_check::EventReport,
Expand Down
1 change: 1 addition & 0 deletions openapi/wicketd.json
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,7 @@
]
},
"ClearUpdateStateResponse": {
"description": "Response to an instruction to clear update data.",
"type": "object",
"properties": {
"cleared": {
Expand Down
4 changes: 4 additions & 0 deletions sp-sim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ pub use update::HostFlashHashPolicy;

pub const SIM_ROT_BOARD: &str = "SimRot";

/// The staging/devel key signature reported in simulated RoT/stage0 cabooses.
pub const ROT_STAGING_DEVEL_SIGN: &str =
"11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf";

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Responsiveness {
Responsive,
Expand Down
4 changes: 1 addition & 3 deletions sp-sim/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::mem;
use std::time::Duration;
use std::time::Instant;

use crate::ROT_STAGING_DEVEL_SIGN;
use crate::SIM_GIMLET_BOARD;
use crate::SIM_ROT_BOARD;
use crate::SIM_SIDECAR_BOARD;
Expand Down Expand Up @@ -90,9 +91,6 @@ impl SimSpUpdate {
const ROT_GITC1: &str = "edededed";
const ROT_VERS0: &str = "0.0.4";
const ROT_VERS1: &str = "0.0.3";
// staging/devel key signature
const ROT_STAGING_DEVEL_SIGN: &str =
"11594bb5548a757e918e6fe056e2ad9e084297c9555417a025d8788eacf55daf";

const STAGE0_GITC0: &str = "ddddddddd";
const STAGE0_GITC1: &str = "dadadadad";
Expand Down
49 changes: 12 additions & 37 deletions wicket-common/src/rack_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::net::IpAddr;
use std::net::Ipv6Addr;
use tufaceous_artifact::ArtifactHash;
use wicketd_commission_types::rack_setup::AllowedSourceIps;
use wicketd_commission_types::rack_setup::BgpAuthKey;
use wicketd_commission_types::rack_setup::BgpAuthKeyId;
use wicketd_commission_types::rack_setup::IpRange;
use wicketd_commission_types::rack_setup::UserSpecifiedRackNetworkConfig;
Expand Down Expand Up @@ -79,43 +80,6 @@ impl<T: fmt::Display> fmt::Display for DisplaySlice<'_, T> {
}
}

/// Describes the actual authentication key to use with a BGP peer.
///
/// Currently, only TCP-MD5 authentication is supported.
#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum BgpAuthKey {
/// TCP-MD5 authentication.
TcpMd5 {
/// The pre-shared key.
key: String,
},
}

impl BgpAuthKey {
/// Returns information about the key that is safe to display in the UI.
pub fn info(&self) -> BgpAuthKeyInfo {
match self {
BgpAuthKey::TcpMd5 { key } => {
let sha256 =
ArtifactHash(Sha256::digest(key.as_bytes()).into());
BgpAuthKeyInfo::TcpMd5 { sha256 }
}
}
}
}

// Ensure that the key is not displayed in debug output.
impl fmt::Debug for BgpAuthKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
BgpAuthKey::TcpMd5 { key: _ } => {
f.debug_struct("TcpMd5").field("key", &"********").finish()
}
}
}
}

/// Describes insensitive information about a BGP authentication key.
///
/// This information is considered okay to display in the UI.
Expand All @@ -142,6 +106,17 @@ pub enum BgpAuthKeyInfo {
}

impl BgpAuthKeyInfo {
/// Returns information about a key that is safe to display in the UI.
pub fn for_key(key: &BgpAuthKey) -> Self {
match key {
BgpAuthKey::TcpMd5 { key } => {
let sha256 =
ArtifactHash(Sha256::digest(key.as_bytes()).into());
BgpAuthKeyInfo::TcpMd5 { sha256 }
}
}
}

pub fn to_string_styled(&self, label_style: Style) -> String {
match self {
BgpAuthKeyInfo::TcpMd5 { sha256 } => {
Expand Down
13 changes: 1 addition & 12 deletions wicket-common/src/rack_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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 std::{collections::BTreeSet, time::Duration};
use std::time::Duration;

use semver::Version;

Expand Down Expand Up @@ -80,17 +80,6 @@ pub struct AbortUpdateOptions {
pub test_error: Option<UpdateTestError>,
}

#[derive(
Clone, Debug, Default, PartialEq, Eq, JsonSchema, Serialize, Deserialize,
)]
pub struct ClearUpdateStateResponse {
/// The SPs for which update data was cleared.
pub cleared: BTreeSet<SpIdentifier>,

/// The SPs that had no update state to clear.
pub no_update_data: BTreeSet<SpIdentifier>,
}

#[derive(
Copy, Clone, Debug, JsonSchema, Deserialize, Serialize, PartialEq, Eq,
)]
Expand Down
6 changes: 4 additions & 2 deletions wicket/src/cli/rack_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ use std::io::Read;
use std::mem;
use std::net::SocketAddrV6;
use std::time::Duration;
use wicket_common::rack_setup::BgpAuthKey;
use wicket_common::rack_setup::BgpAuthKeyInfo;
use wicket_common::rack_setup::BgpAuthKeyStatus;
use wicket_common::rack_setup::DisplaySlice;
use wicketd_client::types::GetBgpAuthKeyParams;
use wicketd_client::types::NewPasswordHash;
use wicketd_client::types::PutBgpAuthKeyBody;
use wicketd_client::types::PutRssRecoveryUserPasswordHash;
use wicketd_client::types::SetBgpAuthKeyStatus;
use wicketd_commission_types::rack_setup::BgpAuthKey;
use wicketd_commission_types::rack_setup::BgpAuthKeyId;
use wicketd_commission_types::rack_setup::CertificateUploadResponse;
use wicketd_commission_types::rack_setup::PutRssUserConfigInsensitive;
Expand Down Expand Up @@ -393,7 +394,8 @@ impl SetBgpAuthKeyArgs {
);

let key = read_bgp_md5_key(&prompt)?;
let info = key.info().to_string_styled(styles.bold);
let info = BgpAuthKeyInfo::for_key(&key)
.to_string_styled(styles.bold);
let response = client
.put_bgp_auth_key(&key_id, &PutBgpAuthKeyBody { key })
.await
Expand Down
8 changes: 5 additions & 3 deletions wicket/src/cli/rack_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ use tokio::{sync::watch, task::JoinHandle};
use wicket_common::{
WICKETD_TIMEOUT,
rack_update::{
ClearUpdateStateResponse, ComponentUpdateStatus, ExitMessage,
RackUpdateStatus, UpdateState, UpdateStateCounts, rollup_update_state,
ComponentUpdateStatus, ExitMessage, RackUpdateStatus, UpdateState,
UpdateStateCounts, rollup_update_state,
},
update_events::{EventReport, WicketdEngineSpec},
};
use wicketd_client::types::{
ClearUpdateStateParams, GetArtifactsAndEventReportsResponse,
StartUpdateParams,
};
use wicketd_commission_types::update::UpdateTargets;
use wicketd_commission_types::update::{
ClearUpdateStateResponse, UpdateTargets,
};

use super::command::CommandOutput;

Expand Down
18 changes: 3 additions & 15 deletions wicketd-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ use wicket_common::inventory::SpType;
use wicket_common::multirack_setup::CurrentMultirackJoinUserConfig;
use wicket_common::multirack_setup::MultirackJoinConfigBaseUserInput;
use wicket_common::preflight_check;
use wicket_common::rack_setup::BgpAuthKey;
use wicket_common::rack_setup::CurrentRssUserConfigInsensitive;
use wicket_common::rack_setup::GetBgpAuthKeyInfoResponse;
use wicket_common::rack_update::AbortUpdateOptions;
use wicket_common::rack_update::ClearUpdateStateOptions;
use wicket_common::rack_update::ClearUpdateStateResponse;
use wicket_common::rack_update::StartUpdateOptions;
use wicket_common::update_events::EventReport;
use wicketd_commission_types::rack_setup::BgpAuthKey;
use wicketd_commission_types::rack_setup::BgpAuthKeyId;
use wicketd_commission_types::rack_setup::CertificateUploadResponse;
use wicketd_commission_types::rack_setup::PutRssUserConfigInsensitive;
use wicketd_commission_types::rack_setup::SetBgpAuthKeyStatus;
use wicketd_commission_types::update::ClearUpdateStateResponse;
use wicketd_commission_types::update::UpdateTargets;

/// Full release repositories are currently (Dec 2024) 1.8 GiB and are likely to
Expand Down Expand Up @@ -436,19 +437,6 @@ pub struct PutBgpAuthKeyResponse {
pub status: SetBgpAuthKeyStatus,
}

#[derive(Clone, Debug, Serialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetBgpAuthKeyStatus {
/// The key was accepted and replaced an old key.
Replaced,

/// The key was accepted, and is the same as the existing key.
Unchanged,

/// The key was accepted and is new.
Added,
}

#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
pub struct PutRssRecoveryUserPasswordHash {
pub hash: omicron_passwords::NewPasswordHash,
Expand Down
37 changes: 37 additions & 0 deletions wicketd-commission-types/versions/src/initial/rack_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,43 @@ impl<'de> Deserialize<'de> for UserSpecifiedRouterPeerAddr {
)]
pub struct BgpAuthKeyId(pub(crate) Name);

/// Describes the actual authentication key to use with a BGP peer.
///
/// Currently, only TCP-MD5 authentication is supported.
#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum BgpAuthKey {
/// TCP-MD5 authentication.
TcpMd5 {
/// The pre-shared key.
key: String,
},
}

// Ensure that the key is not displayed in debug output.
impl fmt::Debug for BgpAuthKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
BgpAuthKey::TcpMd5 { key: _ } => {
f.debug_struct("TcpMd5").field("key", &"********").finish()
}
}
}
}

#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetBgpAuthKeyStatus {
/// The key was accepted and replaced an old key.
Replaced,

/// The key was accepted, and is the same as the existing key.
Unchanged,

/// The key was accepted and is new.
Added,
}

/// The result of uploading half of a certificate/key pair.
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
#[serde(tag = "status", rename_all = "snake_case")]
Expand Down
12 changes: 12 additions & 0 deletions wicketd-commission-types/versions/src/initial/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ impl JsonSchema for UpdateTargets {
}
}

/// Response to an instruction to clear update data.
#[derive(
Clone, Debug, Default, PartialEq, Eq, JsonSchema, Serialize, Deserialize,
)]
pub struct ClearUpdateStateResponse {
/// The SPs for which update data was cleared.
pub cleared: BTreeSet<SpIdentifier>,

/// The SPs that had no update state to clear.
pub no_update_data: BTreeSet<SpIdentifier>,
}

/// Error returned when UpdateTargets is constructed from an empty set.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct EmptyUpdateTargets;
Expand Down
3 changes: 3 additions & 0 deletions wicketd-commission-types/versions/src/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

pub mod rack_setup {
pub use crate::v1::rack_setup::AllowedSourceIps;
pub use crate::v1::rack_setup::BgpAuthKey;
pub use crate::v1::rack_setup::BgpAuthKeyId;
pub use crate::v1::rack_setup::BgpConfig;
pub use crate::v1::rack_setup::CertificateUploadResponse;
Expand All @@ -23,6 +24,7 @@ pub mod rack_setup {
pub use crate::v1::rack_setup::RouteConfig;
pub use crate::v1::rack_setup::RouterLifetimeConfig;
pub use crate::v1::rack_setup::RouterPeerIpAddr;
pub use crate::v1::rack_setup::SetBgpAuthKeyStatus;
pub use crate::v1::rack_setup::TxEqConfig;
pub use crate::v1::rack_setup::UplinkAddress;
pub use crate::v1::rack_setup::UplinkIpNet;
Expand All @@ -35,6 +37,7 @@ pub mod rack_setup {
}

pub mod update {
pub use crate::v1::update::ClearUpdateStateResponse;
pub use crate::v1::update::EmptyUpdateTargets;
pub use crate::v1::update::UpdateTargets;
}
9 changes: 6 additions & 3 deletions wicketd/src/bgp_auth_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
use std::collections::BTreeMap;
use std::collections::btree_map;
use thiserror::Error;
use wicket_common::rack_setup::BgpAuthKey;
use wicket_common::rack_setup::BgpAuthKeyInfo;
use wicket_common::rack_setup::BgpAuthKeyStatus;
use wicket_common::rack_setup::DisplaySlice;
use wicketd_api::SetBgpAuthKeyStatus;
use wicketd_commission_types::rack_setup::BgpAuthKey;
use wicketd_commission_types::rack_setup::BgpAuthKeyId;
use wicketd_commission_types::rack_setup::SetBgpAuthKeyStatus;

#[derive(Clone, Debug, PartialEq, Eq, Error)]
pub(crate) enum BgpAuthKeyError {
Expand Down Expand Up @@ -71,7 +72,9 @@ impl BgpAuthKeys {
.map(|(key_id, key)| {
let status = key
.as_ref()
.map(|key| BgpAuthKeyStatus::Set { info: key.info() })
.map(|key| BgpAuthKeyStatus::Set {
info: BgpAuthKeyInfo::for_key(key),
})
.unwrap_or(BgpAuthKeyStatus::Unset);
(key_id.clone(), status)
})
Expand Down
Loading
Loading