From a4155a1b355b5ff93aadab8743f6ff8cf061be90 Mon Sep 17 00:00:00 2001 From: rgirada Date: Sat, 7 Mar 2020 17:22:52 -0800 Subject: [PATCH] staticd: Fixing memory leak issue Memory allotted for staticd specific vrf structers is not being deallocated when the corresponding vrf is destroyed. Signed-off-by: Rajesh Girada --- staticd/static_main.c | 2 ++ staticd/static_vrf.c | 6 ++++++ staticd/static_vrf.h | 1 + 3 files changed, 9 insertions(+) diff --git a/staticd/static_main.c b/staticd/static_main.c index 43cb7db51d..3aa8a8db3e 100644 --- a/staticd/static_main.c +++ b/staticd/static_main.c @@ -73,6 +73,8 @@ static void sigint(void) { zlog_notice("Terminating on signal"); + static_vrf_terminate(); + exit(0); } diff --git a/staticd/static_vrf.c b/staticd/static_vrf.c index abb64aad3f..6c065932a1 100644 --- a/staticd/static_vrf.c +++ b/staticd/static_vrf.c @@ -111,6 +111,7 @@ static int static_vrf_delete(struct vrf *vrf) svrf->stable[afi][safi] = NULL; } } + XFREE(MTYPE_TMP, svrf); return 0; } @@ -204,3 +205,8 @@ void static_vrf_init(void) vrf_cmd_init(static_vrf_config_write, &static_privs); } + +void static_vrf_terminate(void) +{ + vrf_terminate(); +} diff --git a/staticd/static_vrf.h b/staticd/static_vrf.h index 28fcdd0d36..6951e56712 100644 --- a/staticd/static_vrf.h +++ b/staticd/static_vrf.h @@ -35,4 +35,5 @@ void static_vrf_init(void); struct route_table *static_vrf_static_table(afi_t afi, safi_t safi, struct static_vrf *svrf); +extern void static_vrf_terminate(void); #endif