Skip to content
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

VRRP v2 setup #26

Closed
wants to merge 23 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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"holo-system",
"holo-tools",
"holo-utils",
"holo-vrrp",
"holo-yang",
]
default-members = ["holo-daemon"]
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ Holo supports the following IETF RFCs and Internet drafts:
* RFC 2453 - RIP Version 2
* RFC 4822 - RIPv2 Cryptographic Authentication

##### VRRP

* RFC 3768 - Virtual Router Redundancy Protocol (VRRP)

##### IETF YANG implementation coverage

| Module | Configuration | State | RPCs | Notifications | Total |
Expand All @@ -234,6 +238,7 @@ Holo supports the following IETF RFCs and Internet drafts:
| ietf-routing@2018-03-13 | 100.00% | 85.71% | - | - | [92.31%](http://westphal.com.br/holo/ietf-routing.html) |
| 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
14 changes: 9 additions & 5 deletions holo-daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ 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" }

[build-dependencies]
Expand All @@ -69,6 +70,7 @@ default = [
"ldp",
"ospf",
"rip",
"vrrp",
]

# Base components
Expand All @@ -79,11 +81,13 @@ routing = ["dep:holo-routing", "dep:holo-interface"]
system = ["dep:holo-system"]

# Protocols
bfd = ["dep:holo-bfd", "holo-routing/bfd"]
bgp = ["dep:holo-bgp", "holo-routing/bgp"]
ldp = ["dep:holo-ldp", "holo-routing/ldp"]
ospf = ["dep:holo-ospf", "holo-routing/ospf"]
rip = ["dep:holo-rip", "holo-routing/rip"]
bfd = ["holo-bfd", "holo-routing/bfd"]
bgp = ["holo-bgp", "holo-routing/bgp"]
ldp = ["holo-ldp", "holo-routing/ldp"]
ospf = ["holo-ospf", "holo-routing/ospf"]
rip = ["holo-rip", "holo-routing/rip"]
vrrp = ["holo-vrrp", "holo-interface/vrrp"]


# Other features
tokio_console = ["dep:console-subscriber"]
Expand Down
17 changes: 10 additions & 7 deletions holo-daemon/src/northbound/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use holo_northbound::configuration::{CommitPhase, ConfigChange};
use holo_northbound::{
api as papi, CallbackKey, CallbackOp, NbDaemonSender, NbProviderReceiver,
};
use holo_protocol::InstanceShared;
use holo_utils::ibus::{IbusReceiver, IbusSender};
use holo_utils::task::TimeoutTask;
use holo_utils::yang::SchemaNodeExt;
Expand Down Expand Up @@ -641,13 +642,20 @@ fn start_providers(
let ibus_rx_policy = ibus_tx.subscribe();
let ibus_rx_system = ibus_rx;

let shared = InstanceShared {
db: Some(db),
event_recorder_config: Some(config.event_recorder.clone()),
..Default::default()
};

// Start holo-interface.
#[cfg(feature = "interface")]
{
let daemon_tx = holo_interface::start(
provider_tx.clone(),
ibus_tx.clone(),
ibus_rx_interface,
shared.clone(),
);
providers.push(daemon_tx);
}
Expand Down Expand Up @@ -688,13 +696,8 @@ fn start_providers(
// Start holo-routing.
#[cfg(feature = "routing")]
{
let daemon_tx = holo_routing::start(
provider_tx,
ibus_tx,
ibus_rx_routing,
db,
config.event_recorder.clone(),
);
let daemon_tx =
holo_routing::start(provider_tx, ibus_tx, ibus_rx_routing, shared);
providers.push(daemon_tx);
}

Expand Down
5 changes: 5 additions & 0 deletions holo-daemon/src/northbound/yang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ pub(crate) fn create_context() {
modules_add::<Instance<Ripv2>>(&mut modules);
modules_add::<Instance<Ripng>>(&mut modules);
}
#[cfg(feature = "vrrp")]
{
use holo_vrrp::interface::Interface;
modules_add::<Interface>(&mut modules);
}

// Create YANG context and load all required modules and their deviations.
let mut yang_ctx = yang::new_context();
Expand Down
7 changes: 7 additions & 0 deletions holo-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ ipnetwork.workspace = true
netlink-packet-route.workspace = true
netlink-packet-core.workspace = true
netlink-sys.workspace = true
regex.workspace = true
rtnetlink.workspace = true
tokio.workspace = true
tracing.workspace = true
yang3.workspace = true

holo-northbound = { path = "../holo-northbound" }
holo-protocol = { path = "../holo-protocol" }
holo-utils = { path = "../holo-utils" }
holo-yang = { path = "../holo-yang" }

holo-vrrp = { path = "../holo-vrrp", optional = true }

[lints]
workspace = true

[features]
vrrp = ["holo-vrrp"]
1 change: 1 addition & 0 deletions holo-interface/src/ibus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub(crate) fn notify_interface_update(ibus_tx: &IbusSender, iface: &Interface) {
ifindex: iface.ifindex.unwrap_or(0),
mtu: iface.mtu.unwrap_or(0),
flags: iface.flags,
mac_address: iface.mac_address.clone(),
});
notify(ibus_tx, msg);
}
Expand Down
10 changes: 10 additions & 0 deletions holo-interface/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::net::{IpAddr, Ipv4Addr};

use bitflags::bitflags;
use generational_arena::{Arena, Index};
use holo_northbound::NbDaemonSender;
use holo_utils::ibus::IbusSender;
use holo_utils::ip::Ipv4NetworkExt;
use holo_utils::southbound::{AddressFlags, InterfaceFlags};
Expand Down Expand Up @@ -37,7 +38,9 @@ pub struct Interface {
pub mtu: Option<u32>,
pub flags: InterfaceFlags,
pub addresses: BTreeMap<IpNetwork, InterfaceAddress>,
pub mac_address: [u8; 6],
pub owner: Owner,
pub vrrp: Option<NbDaemonSender>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -123,6 +126,8 @@ impl Interfaces {
flags: InterfaceFlags::default(),
addresses: Default::default(),
owner: Owner::CONFIG,
vrrp: None,
mac_address: Default::default(),
};

let iface_idx = self.arena.insert(iface);
Expand All @@ -136,6 +141,7 @@ impl Interfaces {
ifindex: u32,
mtu: u32,
flags: InterfaceFlags,
mac_address: [u8; 6],
netlink_handle: &rtnetlink::Handle,
ibus_tx: Option<&IbusSender>,
) {
Expand All @@ -152,6 +158,7 @@ impl Interfaces {
if iface.name == ifname
&& iface.mtu == Some(mtu)
&& iface.flags == flags
&& iface.mac_address == mac_address
{
return;
}
Expand All @@ -170,6 +177,7 @@ impl Interfaces {
iface.owner.insert(Owner::SYSTEM);
iface.mtu = Some(mtu);
iface.flags = flags;
iface.mac_address = mac_address;

// Notify protocol instances about the interface update.
//
Expand Down Expand Up @@ -214,6 +222,8 @@ impl Interfaces {
flags,
addresses: Default::default(),
owner: Owner::SYSTEM,
vrrp: None,
mac_address: Default::default(),
};

// Notify protocol instances about the interface update.
Expand Down
5 changes: 5 additions & 0 deletions holo-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use holo_northbound::{
process_northbound_msg, NbDaemonReceiver, NbDaemonSender, NbProviderSender,
ProviderBase,
};
use holo_protocol::InstanceShared;
use holo_utils::ibus::{IbusReceiver, IbusSender};
use tokio::sync::mpsc;
use tracing::Instrument;
Expand All @@ -29,6 +30,8 @@ pub struct Master {
pub nb_tx: NbProviderSender,
// Internal bus Tx channel.
pub ibus_tx: IbusSender,
// Shared data among all protocol instances.
pub shared: InstanceShared,
// Netlink socket.
pub netlink_handle: rtnetlink::Handle,
// List of interfaces.
Expand Down Expand Up @@ -73,6 +76,7 @@ pub fn start(
nb_tx: NbProviderSender,
ibus_tx: IbusSender,
ibus_rx: IbusReceiver,
shared: InstanceShared,
) -> NbDaemonSender {
let (nb_daemon_tx, nb_daemon_rx) = mpsc::channel(4);

Expand All @@ -83,6 +87,7 @@ pub fn start(
let mut master = Master {
nb_tx,
ibus_tx,
shared,
netlink_handle,
interfaces: Default::default(),
};
Expand Down
18 changes: 17 additions & 1 deletion holo-interface/src/netlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ async fn process_newlink_msg(
let ifindex = msg.header.index;
let mut ifname = None;
let mut mtu = None;
let mut mac_address: [u8; 6] = [0u8; 6];

let mut flags = InterfaceFlags::empty();
if msg.header.link_layer_type == ARPHRD_LOOPBACK {
flags.insert(InterfaceFlags::LOOPBACK);
Expand All @@ -54,6 +56,12 @@ async fn process_newlink_msg(
match nla {
Nla::IfName(nla_ifname) => ifname = Some(nla_ifname),
Nla::Mtu(nla_mtu) => mtu = Some(nla_mtu),
Nla::Address(addr) => {
mac_address = match addr.try_into() {
Ok(a) => a,
Err(e) => [0u8; 6],
};
}
_ => (),
}
}
Expand All @@ -65,7 +73,15 @@ async fn process_newlink_msg(
let ibus_tx = notify.then_some(&master.ibus_tx);
master
.interfaces
.update(ifname, ifindex, mtu, flags, &master.netlink_handle, ibus_tx)
.update(
ifname,
ifindex,
mtu,
flags,
mac_address,
&master.netlink_handle,
ibus_tx,
)
.await;
}

Expand Down
Loading
Loading