From ed07bd83ef06dc33365c286654a9fddc08fbb8f5 Mon Sep 17 00:00:00 2001
From: Quentin Armitage <quentin@armitage.org.uk>
Date: Wed, 14 Oct 2020 16:19:54 +0100
Subject: [PATCH 381/691] vrrp: ensure memory used for entries in /etc/iproute2
 is freed

Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
---
 keepalived/vrrp/vrrp_daemon.c | 2 ++
 keepalived/vrrp/vrrp_data.c   | 2 --
 lib/parser.c                  | 4 +---
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/keepalived/vrrp/vrrp_daemon.c b/keepalived/vrrp/vrrp_daemon.c
index 4533f06..ea950c9 100644
--- a/keepalived/vrrp/vrrp_daemon.c
+++ b/keepalived/vrrp/vrrp_daemon.c
@@ -246,6 +246,8 @@ vrrp_terminate_phase2(int exit_status)
 		dbus_stop();
 #endif
 
+	clear_rt_names();
+
 	if (global_data->vrrp_notify_fifo.fd != -1)
 		notify_fifo_close(&global_data->notify_fifo, &global_data->vrrp_notify_fifo);
 
diff --git a/keepalived/vrrp/vrrp_data.c b/keepalived/vrrp/vrrp_data.c
index 31f4b82..40d10ba 100644
--- a/keepalived/vrrp/vrrp_data.c
+++ b/keepalived/vrrp/vrrp_data.c
@@ -1157,6 +1157,4 @@ dump_data_vrrp(FILE *fp)
 		conf_write(fp, "------< Interfaces >------");
 		dump_list(fp, ifl);
 	}
-
-	clear_rt_names();
 }
diff --git a/lib/parser.c b/lib/parser.c
index 73911d9..c13e133 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -2099,8 +2099,6 @@ init_data(const char *conf_file, const vector_t * (*init_keywords) (void))
 
 	free_keywords(keywords);
 	free_parser_data();
-#ifdef _WITH_VRRP_
-	clear_rt_names();
-#endif
+
 	notify_resource_release();
 }
-- 
1.8.3.1

