Skip to content

Commit

Permalink
vrrp: introduce InterfaceNet to mvlan
Browse files Browse the repository at this point in the history
We need sockets for handling vrrp request
and responses. This makes sure that the
macvlan interfaces are hooked to a raw socket
and also makes sure the tasks are started
successfully.

Signed-off-by: Paul Wekesa <paul1tw1@gmail.com>
  • Loading branch information
Paul-weqe committed Sep 18, 2024
1 parent ce7e673 commit 52eabe9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions holo-vrrp/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub struct MacVlanInterface {
// Interface system data.
pub system: InterfaceSys,
// Interface raw sockets and Tx/Rx tasks.
pub net: Option<InterfaceNet>,
}

#[derive(Debug, Default)]
Expand Down Expand Up @@ -280,8 +281,16 @@ impl MacVlanInterface {
Self {
name,
system: InterfaceSys::default(),
net: None,
}
}

pub fn create_net(&mut self, tx_channels: &InstanceChannelsTx<Interface>) {
let net = InterfaceNet::new(&self.name, tx_channels)
.expect("Failed to initialize VRRP tasks");
self.net = Some(net);
println!("...");
}
}

// ===== impl InterfaceNet =====
Expand Down
2 changes: 1 addition & 1 deletion holo-vrrp/src/southbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use ipnetwork::IpNetwork;
use crate::interface::Interface;

// ===== global functions =====

pub(crate) fn process_iface_update(
iface: &mut Interface,
msg: InterfaceUpdateMsg,
Expand Down Expand Up @@ -42,6 +41,7 @@ pub(crate) fn process_iface_update(
mvlan_iface.system.flags = msg.flags;
mvlan_iface.system.ifindex = Some(msg.ifindex);
mvlan_iface.system.mac_address = msg.mac_address;
mvlan_iface.create_net(&iface.tx);
return;
}
}
Expand Down

0 comments on commit 52eabe9

Please sign in to comment.