]> git.puffer.fish Git - mirror/frr.git/commitdiff
vrrpd: gracefully shutdown on SIGTERM / SIGINT
authorQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 22 Apr 2019 18:04:56 +0000 (18:04 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 17 May 2019 00:27:08 +0000 (00:27 +0000)
Handle kill signals by gracefully destroying all of our VRRP instances.
If any of them are in Master state, send an advert with 0 priority to
notify Backup routers we are going down.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
vrrpd/vrrp.c
vrrpd/vrrp.h
vrrpd/vrrp_main.c

index f98b230c62492af174015c9fd98071f3b1dbadfa..7b66492c11ff8b800e924046ba4b143a3f1d6d8b 100644 (file)
@@ -2354,3 +2354,21 @@ void vrrp_init(void)
                                         "VRRP virtual router hash");
        vrf_init(NULL, NULL, NULL, NULL, NULL);
 }
+
+void vrrp_fini(void)
+{
+       /* Destroy all instances */
+       struct list *vrs = hash_to_list(vrrp_vrouters_hash);
+
+       struct listnode *ln;
+       struct vrrp_vrouter *vr;
+
+       for (ALL_LIST_ELEMENTS_RO(vrs, ln, vr)) {
+               vrrp_vrouter_destroy(vr);
+       }
+
+       list_delete(&vrs);
+
+       hash_clean(vrrp_vrouters_hash, NULL);
+       hash_free(vrrp_vrouters_hash);
+}
index ee2a8249a50b3d11686c15c8a402e749cad74b15..fd4901fe22fed7c7cd4f1bb20089731942398bf5 100644 (file)
@@ -265,6 +265,14 @@ struct vrrp_vrouter {
  */
 void vrrp_init(void);
 
+/*
+ * Destroy all VRRP instances and gracefully shutdown.
+ *
+ * For instances in Master state, VRRP advertisements with 0 priority will be
+ * sent if possible to notify Backup routers that we are going away.
+ */
+void vrrp_fini(void);
+
 
 /* Creation and destruction ------------------------------------------------ */
 
index d6a43be8e80ab8457c3db469125a03daeafa54fd..98b907d013849aef71a56f6217be994555fc1d7f 100644 (file)
@@ -69,10 +69,12 @@ static void sighup(void)
 }
 
 /* SIGINT / SIGTERM handler. */
-static void sigint(void)
+static void __attribute__((noreturn)) sigint(void)
 {
        zlog_notice("Terminating on signal");
 
+       vrrp_fini();
+
        exit(0);
 }