diff --git a/holo-vrrp/src/instance.rs b/holo-vrrp/src/instance.rs index 4bae69db..3c294e7a 100644 --- a/holo-vrrp/src/instance.rs +++ b/holo-vrrp/src/instance.rs @@ -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 diff --git a/holo-vrrp/src/interface.rs b/holo-vrrp/src/interface.rs index 4f90e6bc..6e93701c 100644 --- a/holo-vrrp/src/interface.rs +++ b/holo-vrrp/src/interface.rs @@ -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( @@ -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() { @@ -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 { diff --git a/holo-vrrp/src/tasks.rs b/holo-vrrp/src/tasks.rs index 85ff565e..2a200af1 100644 --- a/holo-vrrp/src/tasks.rs +++ b/holo-vrrp/src/tasks.rs @@ -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();