From 9742796ff1b34699297b64c72b31a27fbafd23b0 Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Tue, 16 Nov 2021 00:00:00 +0300 Subject: [PATCH] zebra: fix memleak on shutdown During shutdown, when table_manager_disable is called for the default VRF, its vrf_id is already set to VRF_UNKNOWN, so the expression is true and the table manager memory is not freed. Change the expression to compare the VRF name instead of the id. The check in table_manager_enable is changed for consistency. Signed-off-by: Igor Ryzhov --- zebra/table_manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zebra/table_manager.c b/zebra/table_manager.c index 82d6a0a6a2..ffc7a48eb9 100644 --- a/zebra/table_manager.c +++ b/zebra/table_manager.c @@ -72,7 +72,8 @@ void table_manager_enable(struct zebra_vrf *zvrf) if (zvrf->tbl_mgr) return; - if (!vrf_is_backend_netns() && zvrf_id(zvrf) != VRF_DEFAULT) { + if (!vrf_is_backend_netns() + && strcmp(zvrf_name(zvrf), VRF_DEFAULT_NAME)) { struct zebra_vrf *def = zebra_vrf_lookup_by_id(VRF_DEFAULT); if (def) @@ -284,7 +285,8 @@ void table_manager_disable(struct zebra_vrf *zvrf) { if (!zvrf->tbl_mgr) return; - if (!vrf_is_backend_netns() && zvrf_id(zvrf) != VRF_DEFAULT) { + if (!vrf_is_backend_netns() + && strcmp(zvrf_name(zvrf), VRF_DEFAULT_NAME)) { zvrf->tbl_mgr = NULL; return; } -- 2.39.5