Skip to content

Pr/daniel noland/host gateway #622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
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
250 changes: 204 additions & 46 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 9 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]

members = [ "cli",
members = [
"cli",
"dataplane",
"dpdk",
"dpdk-sys",
Expand All @@ -16,21 +17,6 @@ members = [ "cli",
"test-utils",
]

default-members = [
"cli",
"dataplane",
"dpdk-sysroot-helper",
"errno",
"id",
"interface-manager",
"mgmt",
"net",
"pipeline",
"rekon",
"routing",
"test-utils",
]

resolver = "3"

[workspace.dependencies]
Expand All @@ -45,7 +31,7 @@ errno = { path = "./errno", package = "dataplane-errno" }
gateway_config = { git = "https://github.com/githedgehog/gateway-proto", tag="v0.11.0", version = "0.11.0" }
id = { path = "./id", package = "dataplane-id" }
interface-manager = { path = "./interface-manager", package = "dataplane-interface-manager" }
mgmt = { path = "./mgmt", package = "dataplane-mgmt"}
mgmt = { path = "./mgmt", package = "dataplane-mgmt" }
net = { path = "./net", package = "dataplane-net", features = ["test_buffer"] }
pipeline = { path = "./pipeline", package = "dataplane-pipeline" }
rekon = { path = "./rekon", package = "dataplane-rekon" }
Expand All @@ -55,17 +41,16 @@ test-utils = { path = "./test-utils", package = "dataplane-test-utils" }
# External
afpacket = { version = "0.2.3", default-features = false, features = [] }
ahash = { git = "https://github.com/githedgehog/aHash", branch = "pr/daniel-noland/bump-zero-copy", default-features = false, features = ["no-rng"] }
arbitrary = { version = "1.4.1", default-features = false, features = [] }
arc-swap = { version = "1.7.1", default-features = false, features = [] }
arrayvec = { version = "0.7.6", default-features = false, features = [] }
async-trait = { version = "0.1" }
bindgen = { version = "0.72.0", default-features = false, features = [] }
bolero = { version = "0.13.3", default-features = false, features = [] }
bytes = { version = "1.10.1", default-features = false, features = [] }
caps = { version = "0.5.5", default-features = false, features = [] }
chrono = { version = "0.4.41", default-features = false, features = ["clock"] }
clap = { version = "4.5.40", default-features = true, features = [] }
ctrlc = { version = "3.4.7", default-features = false, features = [] }
chrono = { version = "0.4.41", default-features = false, features = ["clock"] }
dashmap = { version = "6.1.0", default-features = false, features = [] }
derive_builder = { version = "0.20.2", default-features = false, features = ["default", "std"] }
doxygen-bindgen = { version = "0.1.3", default-features = false, features = [] }
Expand All @@ -77,15 +62,18 @@ ipnet = { version = "2.11.0", default-features = false, features = [] }
iptrie = { version = "0.10.3", default-features = false, features = [] }
left-right = { version = "0.11.5" }
linux-raw-sys = { version = "0.9.4", default-features = false, features = [] }
mac_address= { version = "1.1.8", default-features = false, features = [] }
mac_address = { version = "1.1.8", default-features = false, features = [] }
mio = { version = "1.0.4", default-features = false, features = [] }
multi_index_map = { version = "0.15.0", default-features = false, features = [] }
netdev = { version = "0.35.2", default-features = false, features = [] }
netlink-packet-route = { version = "0.24.0", default-features = false, features = [] }
nix = { version = "0.30.1", default-features = false, features = ["socket"] }
ordermap = { version = "0.5.7", default-features = false, features = [] }
pretty_assertions = { version = "1.4.1", default-features = false, features = ["std"] }
procfs = { version = "0.17.0", default-features = false, features = [] }
rtnetlink = { version = "0.17.0", default-features = false, features = [] }
#rtnetlink = { git = "https://github.com/daniel-noland/rtnetlink.git", branch = "hh/tc-actions", default-features = false, features = [] }
#rtnetlink = { version = "0.17.0", default-features = false, features = [] }
rtnetlink = { path = "../rtnetlink", default-features = false, features = [] }
rustyline = { version = "16.0.0", default-features = false, features = [] }
serde = { version = "1.0.219", default-features = false, features = [] }
serde_yml = { version = "0.0.12", default-features = false, features = [] }
Expand Down
9 changes: 5 additions & 4 deletions interface-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0"
publish = false

[features]
default = ["bolero"]
default = []
bolero = ["dep:bolero", "net/bolero"]

[dependencies]
Expand All @@ -17,11 +17,13 @@ rekon = { workspace = true }
# external
bolero = { workspace = true, optional = true, default-features = false, features = ["alloc"] }
derive_builder = { workspace = true, default-features = false, features = ["default"] }
futures = { workspace = true, features = ["default"] }
multi_index_map = { workspace = true, features = ["serde"] }
nix = { workspace = true, features = ["sched"] }
pci-ids = { version = "0.2.5", default-features = false, features = [] }
pci-info = { version = "0.3.2", features = ["pci_subclass_debug_strings", "default", "pci_interface_func_debug_strings", "pci_class_debug_strings"] }
rtnetlink = { workspace = true, features = ["default", "tokio"] }
serde = { workspace = true, features = ["std"] }
tokio = { workspace = true, features = ["macros", "rt", "sync", "time"] }
thiserror = { workspace = true, features = ["std"] }
tracing = { workspace = true, features = ["attributes"] }

[dev-dependencies]
Expand All @@ -30,5 +32,4 @@ net = { workspace = true, features = ["bolero"] }

# external
bolero = { workspace = true, default-features = false, features = ["alloc"] }
tokio = { workspace = true, features = ["macros", "rt", "sync", "time", "test-util"] }

2 changes: 1 addition & 1 deletion interface-manager/src/interface/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
#[cfg(doc)]
use net::interface::Interface;

/// An "observed" association (or lack of same) from one network interface with another.
/// An "observed" association (or lack of same) of one network interface with another.
///
/// For example, putting a VTEP in a bridge, or a bridge in a VRF.
///
Expand Down
116 changes: 116 additions & 0 deletions interface-manager/src/interface/bridge/fdb.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Open Network Fabric Authors

use derive_builder::Builder;
use multi_index_map::MultiIndexMap;
use net::eth::mac::Mac;
use net::interface::InterfaceIndex;
use net::ipv4::UnicastIpv4Addr;
use net::vxlan::Vni;
use serde::{Deserialize, Serialize};

/// TODO: vlan aware bridge
#[derive(
Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize, MultiIndexMap,
)]
pub struct Fdb {
#[multi_index(ordered_non_unique)]
pub mac: Mac, // note: deliberately NOT unicast scoped, multicast is common here
#[multi_index(ordered_non_unique)]
pub action: FdbAction,
}

impl Fdb {
#[must_use]
pub fn new(mac: Mac, action: impl Into<FdbAction>) -> Self {
Self {
mac,
action: action.into(),
}
}

#[must_use]
pub fn mac(&self) -> Mac {
self.mac
}

#[must_use]
pub fn action(&self) -> &FdbAction {
&self.action
}
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[cfg_attr(any(test, feature = "bolero"), derive(bolero::TypeGenerator))]
pub enum FdbAction {
Dev(InterfaceIndex),
Encap(Encap),
}

#[derive(Clone, Default, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[cfg_attr(any(test, feature = "bolero"), derive(bolero::TypeGenerator))]
pub struct FdbEntryBuilder {
mac: Option<Mac>,
dev: Option<InterfaceIndex>,
dst: Option<UnicastIpv4Addr>,
vni: Option<Vni>,
}

impl FdbEntryBuilder {
#[must_use]
pub const fn new() -> Self {
Self {
mac: None,
dev: None,
dst: None,
vni: None,
}
}

pub fn mac(&mut self, mac: impl Into<Mac>) -> &mut Self {
self.mac = Some(mac.into());
self
}

pub fn dev(&mut self, dev: impl Into<InterfaceIndex>) -> &mut Self {
self.dev = Some(dev.into());
self
}

pub fn dst(&mut self, ip: impl Into<UnicastIpv4Addr>) -> &mut Self {
self.dst = Some(ip.into());
self
}

pub fn vni(&mut self, vni: impl Into<Vni>) -> &mut Self {
self.vni = Some(vni.into());
self
}

/// Build an FDB entry
///
/// # Errors
///
/// Errors if the entry
///
/// 1. is lacking `mac` or `dev`
/// 2. has a `via` but no `vni`
pub fn build(self) -> Result<Fdb, Self> {
match (self.mac, self.dev) {
(_, None) | (None, _) => Err(self),
(Some(mac), Some(dev)) => match (self.dst, self.vni) {
(None, None) => Ok(Fdb::new(mac, FdbAction::Dev(dev))),
(Some(via), vni) => Ok(Fdb::new(mac, FdbAction::Encap(Encap { dev, via, vni }))),
_ => Err(self),
},
}
}
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Builder, Serialize, Deserialize)]
#[cfg_attr(any(test, feature = "bolero"), derive(bolero::TypeGenerator))]
pub struct Encap {
dev: InterfaceIndex,
via: UnicastIpv4Addr,
vni: Option<Vni>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use net::interface::BridgeProperties;
use rekon::AsRequirement;
use serde::{Deserialize, Serialize};

pub mod fdb;

/// The "planned" properties for a bridge.
#[derive(
Builder,
Expand Down
Loading
Loading