Skip to content

Commit

Permalink
vrrp: macvlan network creation.
Browse files Browse the repository at this point in the history
Add an `is_ready()` to macvlan to confirm if the
macvlan address is ready to configure network
details e.g sockets, read and write loops etc

Signed-off-by: Paul Wekesa <paul1tw1@gmail.com>
  • Loading branch information
Paul-weqe committed Nov 4, 2024
1 parent b303e33 commit 8a8c432
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion holo-vrrp/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@ impl Interface {
.expect("Failed to intialize VRRP tasks");

if let Some(instance) = self.instances.get_mut(&vrid) {
instance.mac_vlan.net = Some(net);
// check if the macvlan is ready for the
// network items to be created
if instance.mac_vlan.is_ready() {
instance.mac_vlan.net = Some(net);
}
}
}

Expand Down Expand Up @@ -429,6 +433,11 @@ impl ProtocolInstance for Interface {

// ==== impl MacVlanInterface ====
impl MacVlanInterface {
pub(crate) fn is_ready(&self) -> bool {
// return true if the ifindex exists
!self.system.ifindex.is_none()
}

pub fn new(vrid: u8) -> Self {
let name = format!("mvlan-vrrp-{}", vrid);
Self {
Expand Down

0 comments on commit 8a8c432

Please sign in to comment.