Skip to content
Open
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
18 changes: 18 additions & 0 deletions .github/buildomat/jobs/test-ddm-dual.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
#:
#: name = "test-ddm-dual"
#: variety = "basic"
#: target = "helios-3.0"
#: rust_toolchain = "stable"
#: output_rules = [
#: "/work/*.log",
#: ]

source .github/buildomat/test-ddm-common.sh

#
# dual sidecar tests
#

banner "dual"
pfexec cargo test --release -p mg-tests test_dual_sidecar -- --nocapture
2 changes: 1 addition & 1 deletion .github/buildomat/jobs/test-ddm-trio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ source .github/buildomat/test-ddm-common.sh
#

banner "trio"
pfexec cargo test --release -p mg-tests test_trio_v3 -- --nocapture
pfexec cargo test --release -p mg-tests test_trio -- --nocapture
8 changes: 7 additions & 1 deletion .github/buildomat/jobs/test-ddm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ set -o pipefail

source .github/buildomat/test-common.sh
banner ddm
cargo nextest run -p ddm -p ddm-api-types -p ddm-api-types-versions --nocapture
cargo nextest run \
-p ddm \
-p ddm-api-types \
-p ddm-api-types-versions \
-p ddm-protocol \
-p mg-common \
--nocapture
4 changes: 2 additions & 2 deletions .github/buildomat/test-ddm-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
source .github/buildomat/common.sh

export MAGHEMITE_VERSION=`git rev-parse HEAD`
export SOFTNPU_VERSION=a6a878533f9eae542552ef66223a37443f931149
export SIDECAR_LITE_VERSION=be3c09fe9a7e9c6bc5f5c6d184ad203b62b1eb32
export SOFTNPU_VERSION=63687602f0d26add71d4dae4ac62d46563ba23f5
export SIDECAR_LITE_VERSION=5f1d8eb2c7b3cd550c37e6a2118b91c95b49b6de
export DENDRITE_VERSION=`grep -A3 'dpd-client' Cargo.toml | sed -n 's/^rev = "\(.*\)"/\1/p'`

function cleanup {
Expand Down
13 changes: 9 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ rev = "44052786cb63ad9ff32ec47bd8d65edb6a184e21"

[workspace.dependencies.dpd-client]
git = "https://github.com/oxidecomputer/dendrite"
rev = "6a5425b2e6ae84d6c4d18bd3a984a16731bf4734"
rev = "a1b7c0652650a86a05d9c0f23d5773c79aab2613"

[workspace.dependencies.dpd-types-versions]
git = "https://github.com/oxidecomputer/dendrite"
rev = "6a5425b2e6ae84d6c4d18bd3a984a16731bf4734"
rev = "a1b7c0652650a86a05d9c0f23d5773c79aab2613"
1 change: 1 addition & 0 deletions ddm-admin-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ progenitor::generate_api!(
ExternalMulticastIp = ddm_api_types_versions::latest::net::OverlayMulticast,
UnderlayMulticastIpv6 = ddm_api_types_versions::latest::net::UnderlayMulticastIpv6,
MulticastRoute = ddm_api_types_versions::latest::db::MulticastRoute,
ImportedMulticastRoute = ddm_api_types_versions::latest::db::ImportedMulticastRoute,
MulticastPathHop = ddm_api_types_versions::latest::exchange::MulticastPathHop,
PeerInfo = ddm_api_types_versions::latest::db::PeerInfo,
PeerStatus = ddm_api_types_versions::latest::db::PeerStatus,
Expand Down
35 changes: 32 additions & 3 deletions ddm-api-types/versions/src/impls/mcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ impl From<MulticastRoute> for MulticastOrigin {

#[cfg(test)]
mod tests {
use std::collections::HashSet;
use std::hash::{DefaultHasher, Hash, Hasher};
use std::net::Ipv6Addr;

use crate::latest::db::MulticastRoute;
use crate::latest::exchange::MulticastPathHop;
use crate::latest::net::{
use crate::v4::db::MulticastRoute;
use crate::v4::exchange::MulticastPathHop;
use crate::v4::net::{
MulticastOrigin, OverlayMulticast, UnderlayMulticastIpv6, Vni,
};
use crate::v5::db::ImportedMulticastRoute;

fn origin(overlay: &str) -> MulticastOrigin {
MulticastOrigin::new(
Expand All @@ -55,6 +57,33 @@ mod tests {
.unwrap()
}

#[test]
fn v4_conversion_drops_interface_ident() {
let route = MulticastRoute {
origin: origin("233.252.0.1"),
nexthop: "fe80::1".parse().unwrap(),
path: vec![MulticastPathHop::new(
"peer".into(),
"fe80::1".parse().unwrap(),
)],
};
let imported = HashSet::from([
ImportedMulticastRoute {
route: route.clone(),
if_name: "tfportrear0_0".into(),
},
ImportedMulticastRoute {
route: route.clone(),
if_name: "tfportrear1_0".into(),
},
]);
assert_eq!(imported.len(), 2);

let prev: HashSet<crate::v4::db::MulticastRoute> =
imported.into_iter().map(Into::into).collect();
assert_eq!(prev, HashSet::from([route]));
}

/// Use the same initial hasher state for each route comparison.
fn hash_of(route: &MulticastRoute) -> u64 {
let mut hasher = DefaultHasher::new();
Expand Down
2 changes: 2 additions & 0 deletions ddm-api-types/versions/src/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub mod db {

pub use crate::v4::db::MulticastRoute;
pub use crate::v4::db::PeerInfo;

pub use crate::v5::db::ImportedMulticastRoute;
}

pub mod exchange {
Expand Down
2 changes: 2 additions & 0 deletions ddm-api-types/versions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ pub mod v2;
pub mod v3;
#[path = "multicast_support/mod.rs"]
pub mod v4;
#[path = "multicast_interfaces/mod.rs"]
pub mod v5;
25 changes: 25 additions & 0 deletions ddm-api-types/versions/src/multicast_interfaces/db.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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 schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::v4;

/// A multicast route with the interface on which its peer was discovered.
#[derive(
Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema,
)]
pub struct ImportedMulticastRoute {
/// The imported multicast route.
pub route: v4::db::MulticastRoute,
/// Local interface on which the advertising peer was discovered.
pub if_name: String,
}

impl From<ImportedMulticastRoute> for v4::db::MulticastRoute {
fn from(imported: ImportedMulticastRoute) -> Self {
imported.route
}
}
10 changes: 10 additions & 0 deletions ddm-api-types/versions/src/multicast_interfaces/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// 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/.

//! Version `MULTICAST_INTERFACES` of the DDM Admin API.
//!
//! Imported multicast routes convey the interface that their peer was
//! discovered on.

pub mod db;
31 changes: 26 additions & 5 deletions ddm-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +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 ddm_api_types_versions::latest;
use ddm_api_types_versions::v1;
use ddm_api_types_versions::v2;
use ddm_api_types_versions::{latest, v1, v2, v4};
use dropshot::HttpError;
use dropshot::HttpResponseOk;
use dropshot::HttpResponseUpdatedNoContent;
Expand All @@ -27,6 +25,7 @@ api_versions!([
// | example for the next person.
// v
// (next_int, IDENT),
(5, MULTICAST_INTERFACES),
(4, MULTICAST_SUPPORT),
(3, EXTERNAL_PEERS),
(2, PEER_DURATIONS),
Expand Down Expand Up @@ -177,11 +176,33 @@ pub trait DdmAdminApi {
#[endpoint {
method = GET,
path = "/multicast_groups",
versions = VERSION_MULTICAST_SUPPORT..
versions = VERSION_MULTICAST_INTERFACES..
}]
async fn get_multicast_groups(
ctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<HashSet<latest::db::MulticastRoute>>, HttpError>;
) -> Result<
HttpResponseOk<HashSet<latest::db::ImportedMulticastRoute>>,
HttpError,
>;

#[endpoint {
operation_id = "get_multicast_groups",
method = GET,
path = "/multicast_groups",
versions = VERSION_MULTICAST_SUPPORT..VERSION_MULTICAST_INTERFACES
}]
async fn get_multicast_groups_v4(
ctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<HashSet<v4::db::MulticastRoute>>, HttpError>
{
let resp = Self::get_multicast_groups(ctx).await?;
Ok(HttpResponseOk(
resp.0
.into_iter()
.map(v4::db::MulticastRoute::from)
.collect(),
))
}

#[endpoint {
method = PUT,
Expand Down
2 changes: 2 additions & 0 deletions ddm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2024"
pretty_assertions.workspace = true
camino-tempfile.workspace = true
serde_urlencoded.workspace = true
tokio = { workspace = true, features = ["test-util"] }

[dependencies]
slog.workspace = true
Expand Down Expand Up @@ -38,6 +39,7 @@ oxnet.workspace = true
uuid.workspace = true
ddm-api.workspace = true
dpd-client.workspace = true
dpd-types-versions.workspace = true

# illumos-only deps used by the routing state machine and platform sys layer.
# Gated by the `backend` feature so stub builds (e.g. Linux test fixtures
Expand Down
14 changes: 11 additions & 3 deletions ddm/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use camino::Utf8PathBuf;
use ddm_api::DdmAdminApi;
use ddm_api::ddm_admin_api_mod;
use ddm_api_types::admin::{EnableStatsRequest, ExpirePathParams, PrefixMap};
use ddm_api_types::db::{MulticastRoute, PeerInfo, RouterKind, TunnelRoute};
use ddm_api_types::db::{
ImportedMulticastRoute, PeerInfo, RouterKind, TunnelRoute,
};
use ddm_api_types::exchange::{PathVector, RouterId};
use ddm_api_types::external_peers::ExternalPeers;
use ddm_api_types::net::{MulticastOrigin, TunnelOrigin};
Expand Down Expand Up @@ -436,9 +438,15 @@ impl DdmAdminApi for DdmAdminApiImpl {

async fn get_multicast_groups(
ctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<HashSet<MulticastRoute>>, HttpError> {
) -> Result<HttpResponseOk<HashSet<ImportedMulticastRoute>>, HttpError>
{
let ctx = lock!(ctx.context());
let imported = ctx.db.imported_mcast();
let imported = ctx
.db
.imported_mcast_links()
.into_iter()
.map(|(route, if_name)| ImportedMulticastRoute { route, if_name })
.collect();
Ok(HttpResponseOk(imported))
}

Expand Down
Loading
Loading