Skip to content

Commit

Permalink
Merge branch 'master' into vrrp
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-weqe authored Aug 1, 2024
2 parents 768e233 + 79fb0d7 commit 638aac7
Show file tree
Hide file tree
Showing 92 changed files with 1,912 additions and 376 deletions.
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"holo-protocol",
"holo-rip",
"holo-routing",
"holo-system",
"holo-tools",
"holo-utils",
"holo-vrrp",
Expand Down Expand Up @@ -49,14 +50,14 @@ itertools = "0.10"
libc = "0.2"
maplit = "1.0"
md5 = "0.7"
nix = "0.26"
nix = { version = "0.29", features = ["fs", "net", "socket", "uio", "user"] }
netlink-packet-core = "0.7"
netlink-packet-route = "0.17"
netlink-sys = "0.8"
num-derive = "0.4"
num-traits = "0.2"
pickledb = "0.5"
prefix-trie = { version = "0.4.1", features = ["ipnetwork"] }
prefix-trie = { version = "0.4.1", default-features = false, features = ["ipnetwork"] }
prost = "0.12"
rand = "0.8.5"
regex = "1.10"
Expand All @@ -74,7 +75,7 @@ tonic = { version = "0.11", features = ["tls"] }
tonic-build = "0.11"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
yang2 = { version = "0.13", features = ["bundled"] }
yang3 = { version = "0.5", features = ["bundled"] }

[workspace.lints.rust]
rust_2018_idioms = { level = "warn", priority = -1 }
Expand All @@ -83,6 +84,7 @@ unsafe_code = "forbid"
[workspace.lints.clippy]
borrowed_box = "allow"
manual_range_contains = "allow"
single_match = "allow"
too_many_arguments = "allow"

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $ git clone https://github.com/holo-routing/holo-cli.git

3. Install build dependencies:

Holo requires a few dependencies for building and embedding the libyang2 library.
Holo requires a few dependencies for building and embedding the libyang library.
You can install them using your system's package manager. For example, on Debian-based systems:

```
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ Holo supports the following IETF RFCs and Internet drafts:
| ietf-segment-routing-mpls@2021-05-26 | 62.50% | 0.00% | - | 23.53% | [32.76%](http://westphal.com.br/holo/ietf-segment-routing-mpls.html) |
| ietf-segment-routing@2021-05-26 | 100.00% | - | - | - | [100.00%](http://westphal.com.br/holo/ietf-segment-routing.html) |
| ietf-vrrp@2018-03-13 | 25.53% | 40.00% | - | 25.00% | [31.73%](http://westphal.com.br/holo/[email protected]) |
| ietf-system@2014-08-06 | 26.67% | 60.00% | 0.00% | - | [38.24%](http://westphal.com.br/holo/[email protected]) |

## Funding

Expand Down
2 changes: 1 addition & 1 deletion holo-bfd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ serde_json.workspace = true
socket2.workspace = true
tokio.workspace = true
tracing.workspace = true
yang2.workspace = true
yang3.workspace = true

holo-northbound = { path = "../holo-northbound" }
holo-protocol = { path = "../holo-protocol" }
Expand Down
2 changes: 1 addition & 1 deletion holo-bfd/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub(crate) async fn read_loop(
Ok(msg) => {
// Retrieve source and destination addresses.
let src = get_packet_src(msg.address.as_ref());
let dst = get_packet_dst(msg.cmsgs());
let dst = get_packet_dst(msg.cmsgs().unwrap());
Ok((src, dst, msg.bytes))
}
Err(errno) => Err(errno.into()),
Expand Down
6 changes: 4 additions & 2 deletions holo-bfd/src/northbound/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ fn state_change_singlehop(
time_of_last_state_change: sess
.statistics
.last_state_change_time
.as_ref(),
.as_ref()
.map(Cow::Borrowed),
dest_addr: Some(Cow::Borrowed(dst)),
source_addr: sess.config.src.as_ref().map(Cow::Borrowed),
session_index: Some(sess.id as u32),
Expand All @@ -71,7 +72,8 @@ fn state_change_multihop(
time_of_last_state_change: sess
.statistics
.last_state_change_time
.as_ref(),
.as_ref()
.map(Cow::Borrowed),
dest_addr: Some(Cow::Borrowed(dst)),
source_addr: Some(Cow::Borrowed(src)),
session_index: Some(sess.id as u32),
Expand Down
12 changes: 6 additions & 6 deletions holo-bfd/src/northbound/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ fn load_callbacks() -> Callbacks<Master> {
use bfd::ip_mh::session_groups::session_group::sessions::session_statistics::SessionStatistics;
let sess = args.list_entry.as_session().unwrap();
Box::new(SessionStatistics {
create_time: Some(&sess.statistics.create_time).ignore_in_testing(),
last_down_time: sess.statistics.last_down_time.as_ref().ignore_in_testing(),
last_up_time: sess.statistics.last_up_time.as_ref().ignore_in_testing(),
create_time: Some(Cow::Borrowed(&sess.statistics.create_time)).ignore_in_testing(),
last_down_time: sess.statistics.last_down_time.as_ref().map(Cow::Borrowed).ignore_in_testing(),
last_up_time: sess.statistics.last_up_time.as_ref().map(Cow::Borrowed).ignore_in_testing(),
down_count: Some(sess.statistics.down_count).ignore_in_testing(),
admin_down_count: Some(sess.statistics.admin_down_count).ignore_in_testing(),
receive_packet_count: Some(sess.statistics.rx_packet_count).ignore_in_testing(),
Expand Down Expand Up @@ -176,9 +176,9 @@ fn load_callbacks() -> Callbacks<Master> {
use bfd::ip_sh::sessions::session::session_statistics::SessionStatistics;
let sess = args.list_entry.as_session().unwrap();
Box::new(SessionStatistics {
create_time: Some(&sess.statistics.create_time).ignore_in_testing(),
last_down_time: sess.statistics.last_down_time.as_ref().ignore_in_testing(),
last_up_time: sess.statistics.last_up_time.as_ref().ignore_in_testing(),
create_time: Some(Cow::Borrowed(&sess.statistics.create_time)).ignore_in_testing(),
last_down_time: sess.statistics.last_down_time.as_ref().map(Cow::Borrowed).ignore_in_testing(),
last_up_time: sess.statistics.last_up_time.as_ref().map(Cow::Borrowed).ignore_in_testing(),
down_count: Some(sess.statistics.down_count).ignore_in_testing(),
admin_down_count: Some(sess.statistics.admin_down_count).ignore_in_testing(),
receive_packet_count: Some(sess.statistics.rx_packet_count).ignore_in_testing(),
Expand Down
2 changes: 1 addition & 1 deletion holo-bgp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ serde_json.workspace = true
serde_with.workspace = true
tokio.workspace = true
tracing.workspace = true
yang2.workspace = true
yang3.workspace = true

holo-northbound = { path = "../holo-northbound" }
holo-protocol = { path = "../holo-protocol" }
Expand Down
4 changes: 2 additions & 2 deletions holo-bgp/src/northbound/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub(crate) fn backward_transition(
notification_received: nbr.notification_rcvd.as_ref().map(
|(time, notif)| {
Box::new(NotificationReceived {
last_notification: Some(time),
last_notification: Some(Cow::Borrowed(time)),
last_error: Some(notif.to_yang()),
last_error_code: Some(notif.error_code),
last_error_subcode: Some(notif.error_subcode),
Expand All @@ -52,7 +52,7 @@ pub(crate) fn backward_transition(
notification_sent: nbr.notification_sent.as_ref().map(
|(time, notif)| {
Box::new(NotificationSent {
last_notification: Some(time),
last_notification: Some(Cow::Borrowed(time)),
last_error: Some(notif.to_yang()),
last_error_code: Some(notif.error_code),
last_error_subcode: Some(notif.error_subcode),
Expand Down
2 changes: 1 addition & 1 deletion holo-bgp/src/northbound/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::LazyLock as Lazy;
use holo_northbound::rpc::{Callbacks, CallbacksBuilder, Provider};
use holo_northbound::yang::control_plane_protocol::bgp;
use holo_utils::yang::DataNodeRefExt;
use yang2::data::Data;
use yang3::data::Data;

use crate::instance::Instance;

Expand Down
6 changes: 3 additions & 3 deletions holo-bgp/src/northbound/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn load_callbacks() -> Callbacks<Instance> {
identifier: nbr.identifier.map(Cow::Owned),
dynamically_configured: None,
session_state: Some(nbr.state.to_yang()),
last_established: nbr.last_established.as_ref().ignore_in_testing(),
last_established: nbr.last_established.as_ref().map(Cow::Borrowed).ignore_in_testing(),
})
})
.path(bgp::neighbors::neighbor::timers::PATH)
Expand Down Expand Up @@ -298,7 +298,7 @@ fn load_callbacks() -> Callbacks<Instance> {
let mut last_error_subcode = None;
let mut last_error_data = None;
if let Some((time, notif)) = &nbr.notification_rcvd {
last_notification = Some(time);
last_notification = Some(Cow::Borrowed(time));
last_error = Some(notif.to_yang());
last_error_code = Some(notif.error_code);
last_error_subcode = Some(notif.error_subcode);
Expand All @@ -322,7 +322,7 @@ fn load_callbacks() -> Callbacks<Instance> {
let mut last_error_subcode = None;
let mut last_error_data = None;
if let Some((time, notif)) = &nbr.notification_sent {
last_notification = Some(time);
last_notification = Some(Cow::Borrowed(time));
last_error = Some(notif.to_yang());
last_error_code = Some(notif.error_code);
last_error_subcode = Some(notif.error_subcode);
Expand Down
19 changes: 12 additions & 7 deletions holo-daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license.workspace = true
edition.workspace = true

[dependencies]
console-subscriber = "0.3"
console-subscriber = { version = "0.3", optional = true }
prost-types = "0.12"
toml = "0.5"
tokio-uring = { version = "0.5", optional = true }
Expand All @@ -28,7 +28,7 @@ tokio.workspace = true
tonic.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
yang2.workspace = true
yang3.workspace = true

holo-interface = { path = "../holo-interface", optional = true }
holo-bfd = { path = "../holo-bfd", optional = true }
Expand All @@ -41,6 +41,7 @@ holo-policy = { path = "../holo-policy", optional = true }
holo-protocol = { path = "../holo-protocol" }
holo-rip = { path = "../holo-rip", optional = true }
holo-routing = { path = "../holo-routing", optional = true }
holo-system = { path = "../holo-system", optional = true }
holo-utils = { path = "../holo-utils" }
holo-vrrp = { path = "../holo-vrrp", optional = true }
holo-yang = { path = "../holo-yang" }
Expand All @@ -62,6 +63,7 @@ default = [
"keychain",
"policy",
"routing",
"system",
# Protocols
"bfd",
"bgp",
Expand All @@ -72,10 +74,11 @@ default = [
]

# Base components
interface = ["holo-interface"]
keychain = ["holo-keychain"]
policy = ["holo-policy", "holo-routing"]
routing = ["holo-routing", "holo-interface"]
interface = ["dep:holo-interface"]
keychain = ["dep:holo-keychain"]
policy = ["dep:holo-policy", "dep:holo-routing"]
routing = ["dep:holo-routing", "dep:holo-interface"]
system = ["dep:holo-system"]

# Protocols
bfd = ["holo-bfd", "holo-routing/bfd"]
Expand All @@ -85,5 +88,7 @@ ospf = ["holo-ospf", "holo-routing/ospf"]
rip = ["holo-rip", "holo-routing/rip"]
vrrp = ["holo-vrrp", "holo-interface/vrrp"]


# Other features
io_uring = ["tokio-uring"]
tokio_console = ["dep:console-subscriber"]
io_uring = ["dep:tokio-uring"]
5 changes: 0 additions & 5 deletions holo-daemon/holod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ database_path = "/var/run/holo/holo.db"
# Sets whether or not an event’s source code file path and line number are displayed
show_source = false

# Instrumentation using tokio-console (a diagnostics and debugging tool)
[tokio_console]
# Enable or disable
enabled = false

# Event recorder (useful for bug reporting)
[event_recorder]
# Enable or disable the event recorder
Expand Down
8 changes: 0 additions & 8 deletions holo-daemon/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub struct Config {
pub group: String,
pub database_path: String,
pub logging: Logging,
pub tokio_console: TokioConsole,
pub event_recorder: event_recorder::Config,
pub plugins: Plugins,
}
Expand Down Expand Up @@ -73,12 +72,6 @@ pub enum LoggingFmtStyle {
Pretty,
}

#[derive(Debug, Default, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct TokioConsole {
pub enabled: bool,
}

#[derive(Debug, Default, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct Plugins {
Expand Down Expand Up @@ -139,7 +132,6 @@ impl Default for Config {
group: "holo".to_owned(),
database_path: "/var/run/holo/holo.db".to_owned(),
logging: Default::default(),
tokio_console: Default::default(),
event_recorder: Default::default(),
plugins: Default::default(),
}
Expand Down
57 changes: 33 additions & 24 deletions holo-daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use tracing_appender::rolling;
use tracing_subscriber::prelude::*;
use tracing_subscriber::Layer;

fn init_tracing(config: &config::Logging, tokio_console: bool) {
fn init_tracing(config: &config::Logging) {
// Enable logging to journald.
let journald = config.journald.enabled.then(|| {
tracing_journald::layer().expect("couldn't connect to journald")
Expand Down Expand Up @@ -78,29 +78,38 @@ fn init_tracing(config: &config::Logging, tokio_console: bool) {
layer.with_filter(log_level_filter)
});

// Enable tokio-console instrumentation.
let console = tokio_console.then(console_subscriber::spawn);

// Configure the tracing fmt layer.
let env_filter = tracing_subscriber::EnvFilter::builder()
.with_default_directive("holo=debug".parse().unwrap())
.from_env_lossy();
let env_filter = match tokio_console {
true => {
// Enable targets needed by the console.
env_filter
.add_directive("tokio=trace".parse().unwrap())
.add_directive("runtime=trace".parse().unwrap())
}
false => env_filter,
};
tracing_subscriber::registry()
.with(env_filter)
.with(journald)
.with(file)
.with(stdout)
.with(console)
.init();
#[cfg(feature = "tokio_console")]
{
// Enable tokio-console instrumentation.
let console = console_subscriber::spawn();
let env_filter = tracing_subscriber::EnvFilter::builder()
.with_default_directive("holo=debug".parse().unwrap())
.from_env_lossy();
// Enable targets needed by the console.
let env_filter = env_filter
.add_directive("tokio=trace".parse().unwrap())
.add_directive("runtime=trace".parse().unwrap());
tracing_subscriber::registry()
.with(env_filter)
.with(journald)
.with(file)
.with(stdout)
.with(console)
.init();
}
#[cfg(not(feature = "tokio_console"))]
{
let env_filter = tracing_subscriber::EnvFilter::builder()
.with_default_directive("holo=debug".parse().unwrap())
.from_env_lossy();
tracing_subscriber::registry()
.with(env_filter)
.with(journald)
.with(file)
.with(stdout)
.init();
}
}

fn init_db<P: AsRef<Path>>(
Expand Down Expand Up @@ -174,7 +183,7 @@ fn main() {
}

// Initialize tracing.
init_tracing(&config.logging, config.tokio_console.enabled);
init_tracing(&config.logging);

// Initialize non-volatile storage.
let db = init_db(&config.database_path)
Expand Down
2 changes: 1 addition & 1 deletion holo-daemon/src/northbound/client/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//

use holo_utils::Responder;
use yang2::data::{DataDiff, DataTree};
use yang3::data::{DataDiff, DataTree};

use crate::northbound::core::Transaction;
use crate::northbound::Result;
Expand Down
4 changes: 2 additions & 2 deletions holo-daemon/src/northbound/client/gnmi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use tokio_stream::wrappers::ReceiverStream;
use tonic::transport::{Server, ServerTlsConfig};
use tonic::{Request, Response, Status, Streaming};
use tracing::{debug, debug_span, error, trace};
use yang2::data::{Data, DataFormat, DataPrinterFlags, DataTree};
use yang2::schema::SchemaNodeKind;
use yang3::data::{Data, DataFormat, DataPrinterFlags, DataTree};
use yang3::schema::SchemaNodeKind;

use crate::config;
use crate::northbound::client::api;
Expand Down
Loading

0 comments on commit 638aac7

Please sign in to comment.