From 321a4387d93aa7dac6de2b93c48c32686d5e7f67 Mon Sep 17 00:00:00 2001 From: Paul Wekesa Date: Wed, 11 Dec 2024 20:08:57 +0300 Subject: [PATCH] vrrp: add advertisement on shutdown Add an advertisement with priority 0 sent when shutdown event is called. Signed-off-by: Paul Wekesa --- holo-vrrp/src/instance.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/holo-vrrp/src/instance.rs b/holo-vrrp/src/instance.rs index e585ec52..e1498f2e 100644 --- a/holo-vrrp/src/instance.rs +++ b/holo-vrrp/src/instance.rs @@ -194,7 +194,20 @@ impl Instance { pub(crate) fn shutdown(&mut self, interface: &InterfaceView) { if self.state.state == fsm::State::Master { // Send an advertisement with Priority = 0. - // TODO + let src_ip = interface.system.addresses.first().unwrap(); + let net = self.net.as_ref().unwrap(); + + 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.