Skip to content

Commit

Permalink
vrrp: add shutdown functionality
Browse files Browse the repository at this point in the history
Send advertisement with priority 0
when shutdown is called with state as
Master

Signed-off-by: Paul Wekesa <[email protected]>
  • Loading branch information
Paul-weqe committed Dec 9, 2024
1 parent 491f785 commit f869d79
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions holo-vrrp/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,22 @@ impl Instance {
}

pub(crate) fn shutdown(&mut self, interface: &InterfaceView) {
if self.state.state == fsm::State::Master {
if self.state.state == fsm::State::Master
&& let Some(src_ip) = interface.system.addresses.first()
&& let Some(net) = &self.net
{
// Send an advertisement with Priority = 0.
// TODO
let mut pkt = self.generate_vrrp_packet();
pkt.priority = 0;
pkt.generate_checksum();

let packet = VrrpPacket {
ip: self.generate_ipv4_packet(src_ip.ip()),
vrrp: pkt,
};

let msg = NetTxPacketMsg::Vrrp { packet };
let _ = net.net_tx_packetp.send(msg);
}

// Transition to the Initialize state.
Expand Down

0 comments on commit f869d79

Please sign in to comment.