Skip to content

Commit

Permalink
vrrp: add mvlan checks
Browse files Browse the repository at this point in the history
Add checks for mvlan to see if it is ready for
operations.

Signed-off-by: Paul Wekesa <[email protected]>
  • Loading branch information
Paul-weqe committed Nov 11, 2024
1 parent ad61528 commit cd52be9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions holo-vrrp/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ impl Instance {
// send a gratuitous for each of the
// virutal IP addresses
for addr in self.config.virtual_addresses.clone() {
if !self.mac_vlan.is_ready() {
return;
}
let arp_hdr = ArpHdr {
hw_type: 1,
// for Ipv4
Expand Down
9 changes: 7 additions & 2 deletions holo-vrrp/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ impl Interface {
}

pub(crate) fn start_instance(&mut self, vrid: u8) {
// `mvlan-vrrp{primary-interface-ifindex}{vrid}`
let name = format!("mvlan-vrrp-{}", vrid);
let mac_address: [u8; 6] = [0x00, 0x00, 0x5e, 0x00, 0x01, vrid];
southbound::tx::create_macvlan_iface(
Expand Down Expand Up @@ -159,7 +158,10 @@ impl Interface {
) {
if let Some(instance) = self.instances.get_mut(&vrid) {
debug_span!("change-state").in_scope(|| {
if state == State::Backup {
if state == State::Initialize {
debug!(%vrid, "state to INITIALIZE.");
instance.state.new_master_reason = new_master_reason;
} else if state == State::Backup {
debug!(%vrid, "state to BACKUP.");
if let Some(ifindex) = instance.mac_vlan.system.ifindex {
for addr in instance.config.virtual_addresses.clone() {
Expand Down Expand Up @@ -245,6 +247,9 @@ impl Interface {
// ...and confirm if the instance's parent Interface has an IP address
&& let Some(addr) = self.system.addresses.first()
{
if !instance.mac_vlan.is_ready() {
return;
}
let ip_hdr = instance.adver_ipv4_pkt(addr.ip());
let vrrp_hdr = instance.adver_vrrp_pkt();
let pkt = VrrpPacket {
Expand Down
3 changes: 3 additions & 0 deletions holo-vrrp/src/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ pub(crate) fn set_timer(
// in case we are Master, we will be sending VRRP advertisements
// every ADVERT_INTERVAL seconds until otherwise.
crate::instance::State::Master => {
if !instance.mac_vlan.is_ready() {
return;
}
let src_ip =
interface.system.addresses.first().unwrap().ip();

Expand Down

0 comments on commit cd52be9

Please sign in to comment.