Skip to content

Commit

Permalink
Networking rpw bugfixes (#5286)
Browse files Browse the repository at this point in the history
  • Loading branch information
internet-diglett authored Mar 20, 2024
1 parent 58adb45 commit a655ff2
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 39 deletions.
40 changes: 40 additions & 0 deletions clients/dpd-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

use slog::info;
use slog::Logger;
use types::LinkCreate;
use types::LinkId;
use types::LinkSettings;
use types::PortSettings;

include!(concat!(env!("OUT_DIR"), "/dpd-client.rs"));

Expand Down Expand Up @@ -787,3 +791,39 @@ impl From<u64> for MacAddr {
}
}
}

impl Eq for PortSettings {}

impl PartialEq for PortSettings {
fn eq(&self, other: &Self) -> bool {
self.links == other.links
}
}

impl Eq for LinkSettings {}

impl PartialEq for LinkSettings {
fn eq(&self, other: &Self) -> bool {
self.addrs == other.addrs && self.params == other.params
}
}

impl Eq for LinkCreate {}

impl PartialEq for LinkCreate {
fn eq(&self, other: &Self) -> bool {
self.autoneg == other.autoneg
&& self.fec == other.fec
&& self.kr == other.kr
&& self.lane == other.lane
&& self.speed == other.speed
}
}

impl Eq for LinkId {}

impl PartialEq for LinkId {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
46 changes: 46 additions & 0 deletions clients/sled-agent-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ use anyhow::Context;
use async_trait::async_trait;
use omicron_common::api::internal::shared::NetworkInterface;
use std::convert::TryFrom;
use std::hash::Hash;
use std::net::IpAddr;
use std::net::SocketAddr;
use types::{BgpConfig, BgpPeerConfig, PortConfigV1, RouteConfig};
use uuid::Uuid;

progenitor::generate_api!(
Expand Down Expand Up @@ -605,3 +607,47 @@ impl TestInterfaces for Client {
.expect("disk_finish_transition() failed unexpectedly");
}
}

impl Eq for BgpConfig {}

impl Hash for BgpConfig {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.asn.hash(state);
self.originate.hash(state);
}
}

impl Hash for BgpPeerConfig {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.addr.hash(state);
self.asn.hash(state);
self.port.hash(state);
self.hold_time.hash(state);
self.connect_retry.hash(state);
self.delay_open.hash(state);
self.idle_hold_time.hash(state);
self.keepalive.hash(state);
}
}

impl Hash for RouteConfig {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.destination.hash(state);
self.nexthop.hash(state);
}
}

impl Eq for PortConfigV1 {}

impl Hash for PortConfigV1 {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.addresses.hash(state);
self.autoneg.hash(state);
self.bgp_peers.hash(state);
self.port.hash(state);
self.routes.hash(state);
self.switch.hash(state);
self.uplink_port_fec.hash(state);
self.uplink_port_speed.hash(state);
}
}
8 changes: 6 additions & 2 deletions common/src/api/internal/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ pub enum ExternalPortDiscovery {
}

/// Switchport Speed options
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[derive(
Copy, Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema, Hash,
)]
#[serde(rename_all = "snake_case")]
pub enum PortSpeed {
#[serde(alias = "0G")]
Expand All @@ -290,7 +292,9 @@ pub enum PortSpeed {
}

/// Switchport FEC options
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[derive(
Copy, Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema, Hash,
)]
#[serde(rename_all = "snake_case")]
pub enum PortFec {
Firecode,
Expand Down
16 changes: 13 additions & 3 deletions nexus/src/app/background/nat_cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,21 @@ impl BackgroundTask for Ipv4NatGarbageCollector {

let retention_threshold = Utc::now() - Duration::weeks(2);

let result = self
let result = match self
.datastore
.ipv4_nat_cleanup(opctx, min_gen, retention_threshold)
.await
.unwrap();
.await {
Ok(v) => v,
Err(e) => {
return json!({
"error":
format!(
"failed to perform cleanup operation: {:#}",
e
)
});
},
};

let rv = serde_json::to_value(&result).unwrap_or_else(|error| {
json!({
Expand Down
Loading

0 comments on commit a655ff2

Please sign in to comment.