diff options
author | Jafar Al-Gharaibeh <Jafaral@users.noreply.github.com> | 2020-10-28 19:57:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-28 19:57:11 +0100 |
commit | 4220c2cc9b69d221e8a5d0f546dd64af4f588a15 (patch) | |
tree | 8f9a809926c7a29fb4b85d35cb4dfe8d2129feca /pbrd | |
parent | Merge pull request #7396 from AnuradhaKaruppiah/es-docs (diff) | |
parent | pbrd: Fix memory leak (diff) | |
download | frr-4220c2cc9b69d221e8a5d0f546dd64af4f588a15.tar.xz frr-4220c2cc9b69d221e8a5d0f546dd64af4f588a15.zip |
Merge pull request #7378 from donaldsharp/pbr_ifp_leak
pbrd: Fix memory leak
Diffstat (limited to 'pbrd')
-rw-r--r-- | pbrd/pbr_main.c | 2 | ||||
-rw-r--r-- | pbrd/pbr_vrf.c | 12 | ||||
-rw-r--r-- | pbrd/pbr_vrf.h | 1 | ||||
-rw-r--r-- | pbrd/pbr_zebra.c | 5 | ||||
-rw-r--r-- | pbrd/pbr_zebra.h | 3 |
5 files changed, 23 insertions, 0 deletions
diff --git a/pbrd/pbr_main.c b/pbrd/pbr_main.c index 9a9edd79c..01c52f24e 100644 --- a/pbrd/pbr_main.c +++ b/pbrd/pbr_main.c @@ -82,6 +82,8 @@ static void sigint(void) { zlog_notice("Terminating on signal"); + pbr_vrf_terminate(); + frr_fini(); exit(0); diff --git a/pbrd/pbr_vrf.c b/pbrd/pbr_vrf.c index 389e5e8be..328460740 100644 --- a/pbrd/pbr_vrf.c +++ b/pbrd/pbr_vrf.c @@ -26,6 +26,7 @@ #include "pbr_map.h" #include "pbr_debug.h" #include "pbr_nht.h" +#include "pbr_zebra.h" DEFINE_MTYPE_STATIC(PBRD, PBR_MAP_VRF, "PBR Map VRF") @@ -137,3 +138,14 @@ void pbr_vrf_init(void) vrf_init(pbr_vrf_new, pbr_vrf_enable, pbr_vrf_disable, pbr_vrf_delete, NULL); } + +void pbr_vrf_terminate(void) +{ + struct vrf *vrf; + struct interface *ifp; + + RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { + FOR_ALL_INTERFACES (vrf, ifp) + pbr_if_del(ifp); + } +} diff --git a/pbrd/pbr_vrf.h b/pbrd/pbr_vrf.h index c9448762e..5953387de 100644 --- a/pbrd/pbr_vrf.h +++ b/pbrd/pbr_vrf.h @@ -40,4 +40,5 @@ extern bool pbr_vrf_is_valid(const struct pbr_vrf *pbr_vrf); extern bool pbr_vrf_is_enabled(const struct pbr_vrf *pbr_vrf); extern void pbr_vrf_init(void); +extern void pbr_vrf_terminate(void); #endif diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c index 697c65ca4..32660b4de 100644 --- a/pbrd/pbr_zebra.c +++ b/pbrd/pbr_zebra.c @@ -59,6 +59,11 @@ struct pbr_interface *pbr_if_new(struct interface *ifp) return pbr_ifp; } +void pbr_if_del(struct interface *ifp) +{ + XFREE(MTYPE_PBR_INTERFACE, ifp->info); +} + /* Inteface addition message from zebra. */ int pbr_ifp_create(struct interface *ifp) { diff --git a/pbrd/pbr_zebra.h b/pbrd/pbr_zebra.h index e8f9bff5d..d0f9ff910 100644 --- a/pbrd/pbr_zebra.h +++ b/pbrd/pbr_zebra.h @@ -46,4 +46,7 @@ extern int pbr_ifp_up(struct interface *ifp); extern int pbr_ifp_down(struct interface *ifp); extern int pbr_ifp_destroy(struct interface *ifp); +/* Free the ifp->info pointer */ +extern void pbr_if_del(struct interface *ifp); + #endif |