Skip to content
Draft
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
37 changes: 15 additions & 22 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ dplane-rpc = { git = "https://github.com/githedgehog/dplane-rpc.git", rev = "e8f
errno = { path = "./errno", package = "dataplane-errno", features = [] }
flow-entry = { path = "./flow-entry", package = "dataplane-flow-entry", features = [] }
flow-filter = { path = "./flow-filter", package = "dataplane-flow-filter", features = [] }
hardware = { path = "./hardware", package = "dataplane-hardware", features = [] }
hardware = { path = "./hardware", package = "dataplane-hardware", default-features = false, features = [] }
id = { path = "./id", package = "dataplane-id", features = [] }
init = { path = "./init", package = "dataplane-init", features = [] }
interface-manager = { path = "./interface-manager", package = "dataplane-interface-manager", features = [] }
k8s-intf = { path = "./k8s-intf", package = "dataplane-k8s-intf", features = [] }
k8s-intf = { path = "./k8s-intf", package = "dataplane-k8s-intf", default-features = false, features = [] }
k8s-less = { path = "./k8s-less", package = "dataplane-k8s-less", features = [] }
left-right-tlcache = { path = "./left-right-tlcache", package = "dataplane-left-right-tlcache", features = [] }
lpm = { path = "./lpm", package = "dataplane-lpm", features = [] }
Expand Down Expand Up @@ -141,7 +141,7 @@ multi_index_map = { version = "0.15.1", default-features = false, features = []
n-vm = { git = "https://github.com/githedgehog/testn.git", tag = "v0.0.9", default-features = false, features = [], package = "n-vm" }
netdev = { version = "0.41.0", default-features = false, features = [] }
nix = { version = "0.31.2", default-features = false, features = [] }
netgauze-bgp-pkt = { version = "0.10.0", features = [] }
netgauze-bgp-pkt = { version = "0.10.0", features = [] }
netgauze-bmp-pkt = { version = "0.10.0", features = ["codec"] }
num-derive = { version = "0.4.2", default-features = false, features = [] }
num-traits = { version = "0.2.19", default-features = false, features = [] }
Expand Down Expand Up @@ -178,9 +178,9 @@ strum_macros = { version = "0.28.0", default-features = false, features = [] }
syn = { version = "2.0.117", default-features = false, features = [] }
thiserror = { version = "2.0.18", default-features = false, features = [] }
thread_local = { version = "1.1.9", default-features = false, features = [] }
tokio = { version = "1.50.0", default-features = false, features = ["rt-multi-thread"] }
tokio = { version = "1.50.0", default-features = false, features = [] }
tracing = { version = "0.1.44", default-features = false, features = [] }
tokio-util = { version = "0.7.18", default-features = false, features = ["codec"] }
tokio-util = { version = "0.7.18", default-features = false, features = [] }
tonic = { version = "0.14.5", default-features = false, features = [] }
tracing-error = { version = "0.2.1", default-features = false, features = [] }
tracing-subscriber = { version = "0.3.23", default-features = false, features = [] }
Expand Down
4 changes: 2 additions & 2 deletions args/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version.workspace = true

[dependencies]
# internal
hardware = { workspace = true, features = ["serde"] }
hardware = { workspace = true, features = ["serde", "sysfs"] }
id = { workspace = true, features = [] }
net = { workspace = true, features = [] }

Expand All @@ -27,7 +27,7 @@ uuid = { workspace = true, features = [] }

[dev-dependencies]
# internal
hardware = { workspace = true, features = ["serde"] }
hardware = { workspace = true, features = ["serde", "sysfs"] }
net = { workspace = true, features = ["test_buffer"] }
# external
serde_yaml_ng = { workspace = true, features = [] }
Expand Down
14 changes: 8 additions & 6 deletions config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,33 @@ version.workspace = true
# internal
common = { workspace = true }
hardware = { workspace = true }
k8s-intf = { workspace = true }
net = { workspace = true }
lpm = { workspace = true }
tracectl = { workspace = true }
k8s-intf = { workspace = true }

# external
arc-swap = { workspace = true }
chrono = { workspace = true, features = ["alloc", "std"] }
derive_builder = { workspace = true, default-features = false, features = ["default"] }
derive_builder = { workspace = true, features = [] }
ipnet = { workspace = true }
linkme = { workspace = true }
multi_index_map = { workspace = true, features = ["serde"] }
ordermap = { workspace = true, features = ["std"] }
thiserror = { workspace = true }
tracing = { workspace = true, features = ["attributes"] }

[target.'cfg(unix)'.dependencies]
linkme = { workspace = true }
tracectl = { workspace = true }

[dev-dependencies]
# internal
pipeline = { workspace = true } # should be removed w/ NAT
lpm = { workspace = true, features = ["testing"] }
hardware = { workspace = true, features = ["bolero"] }
hardware = { workspace = true, features = ["bolero", "sysfs"] }
k8s-intf = { workspace = true, features = ["bolero"] }

# external
bolero = { workspace = true, default-features = false, features = ["alloc"] }
bolero = { workspace = true, features = ["alloc"] }
caps = { workspace = true }
ipnet = { workspace = true }
pretty_assertions = { workspace = true, features = ["std"] }
3 changes: 3 additions & 0 deletions config/src/converters/k8s/config/tracecfg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Open Network Fabric Authors

#[cfg(unix)]
use tracectl::LevelFilter;
#[cfg(not(unix))]
use tracing::metadata::LevelFilter;

use k8s_intf::gateway_agent_crd::GatewayAgentGatewayLogs;

Expand Down
2 changes: 1 addition & 1 deletion config/src/converters/k8s/status/bgp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Open Network Fabric Authors

//! Converters for internal BGP status -> K8s GatewayAgentStatusStateBgp CRD.
//! Converters for internal BGP status -> K8s `GatewayAgentStatusStateBgp` CRD.

use std::collections::BTreeMap;

Expand Down
2 changes: 1 addition & 1 deletion config/src/converters/k8s/status/dataplane_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ mod tests {
let last_applied_time = time_gen.generate(d)?;
let status = d
.produce::<Option<LegalValue<DataplaneStatus>>>()?
.map(|v| v.take());
.map(LegalValue::take);
let last_collected_time_raw = time_gen.generate(d)?;
let last_collected_time = status.as_ref().map(|_| last_collected_time_raw);
let last_heartbeat_raw = time_gen.generate(d)?;
Expand Down
2 changes: 1 addition & 1 deletion config/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl Display for GwConfigMeta {
let error = self
.error
.as_ref()
.map_or("none".to_string(), |e| e.to_string());
.map_or("none".to_string(), std::string::ToString::to_string);

let is_rollback = if self.is_rollback { "(rollback)" } else { "" };

Expand Down
4 changes: 4 additions & 0 deletions config/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ pub enum ConfigError {
Invalid(String),

// tracing
#[cfg(unix)]
#[error("Failed to set tracing configuration: {0}")]
Tracing(#[from] tracectl::TraceCtlError),
#[cfg(not(unix))]
#[error("Failed to set tracing configuration: {0}")]
Tracing(String),

// Community mappings
#[error("Could not assign BGP community to VPC peering {0}")]
Expand Down
4 changes: 4 additions & 0 deletions config/src/external/communities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ impl PriorityCommunityTable {
Self::default()
}
/// Insert a community
///
/// # Errors
///
/// Returns [`ConfigError::DuplicateCommunity`] if the community already exists in the table.
pub fn insert(&mut self, order: usize, community: &str) -> Result<(), ConfigError> {
if self.0.iter().any(|(_, comm)| comm == community) {
return Err(ConfigError::DuplicateCommunity(community.to_string()));
Expand Down
13 changes: 12 additions & 1 deletion config/src/external/gwgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ impl GwGroup {
//N.B. we reverse the operands since want the most preferred first
self.members.sort_by(|m1, m2| m2.cmp(m1));
}
/// Add a member to the gateway group.
///
/// # Errors
///
/// Returns [`ConfigError::DuplicateMember`] if a member with the same name already exists.
/// Returns [`ConfigError::DuplicateMemberAddress`] if a member with the same IP address already exists.
pub fn add_member(&mut self, member: GwGroupMember) -> Result<(), ConfigError> {
if self.get_member_by_name(&member.name).is_some() {
return Err(ConfigError::DuplicateMember(member.name.clone()));
Expand Down Expand Up @@ -126,6 +132,11 @@ impl GwGroupTable {
pub fn new() -> Self {
Self::default()
}
/// Add a gateway group to the table.
///
/// # Errors
///
/// Returns [`ConfigError::DuplicateGroup`] if a group with the same name already exists.
pub fn add_group(&mut self, group: GwGroup) -> Result<(), ConfigError> {
if self.0.contains_key(group.name()) {
return Err(ConfigError::DuplicateGroup(group.name().to_owned()));
Expand Down Expand Up @@ -332,7 +343,7 @@ mod test {
fn test_bgp_community_setup() {
let comtable = sample_community_table();
let mut gwtable = build_sample_gw_groups();
gwtable.iter_mut().for_each(|group| group.sort_members());
gwtable.iter_mut().for_each(GwGroup::sort_members);

println!("{gwtable}");
println!("{comtable}");
Expand Down
5 changes: 5 additions & 0 deletions config/src/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ impl ExternalConfig {
}
Ok(())
}
/// Validate the external configuration.
///
/// # Errors
///
/// Returns a [`ConfigError`] if validation fails.
pub fn validate(&mut self) -> ConfigResult {
self.device.validate()?;
self.underlay.validate()?;
Expand Down
8 changes: 8 additions & 0 deletions config/src/external/overlay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ impl Overlay {
}

/// Validate all peerings, checking if the VPCs they refer to exist in vpc table
///
/// # Errors
///
/// Returns an error if a peering references a VPC that does not exist in the VPC table.
pub fn validate_peerings(&self) -> ConfigResult {
debug!("Validating VPC peerings...");
for peering in self.peering_table.values() {
Expand All @@ -60,6 +64,10 @@ impl Overlay {
}

/// Top most validation function for `Overlay` configuration
///
/// # Errors
///
/// Returns an error if the overlay configuration is invalid.
pub fn validate(&mut self) -> ConfigResult {
debug!("Validating overlay configuration...");

Expand Down
2 changes: 1 addition & 1 deletion config/src/external/overlay/validation_tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Open Network Fabric Authors

//! Validation tests for VpcExpose / VpcPeering / Overlay
//! Validation tests for `VpcExpose` / `VpcPeering` / Overlay
//!
//! These tests cover the expected semantics and restrictions for Expose objects in VPC peerings.
//!
Expand Down
1 change: 0 additions & 1 deletion config/src/external/overlay/vpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::collections::BTreeMap;
use std::collections::BTreeSet;
use tracing::{debug, error, warn};

use crate::converters::k8s::config::peering;
use crate::external::overlay::VpcManifest;
use crate::external::overlay::VpcPeeringTable;
use crate::external::overlay::vpcpeering::VpcExposeNatConfig;
Expand Down
Loading
Loading