diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2023-05-05 11:05:12 -0400 |
|---|---|---|
| committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-05-09 15:55:27 +0300 |
| commit | 3a9376d3f8b48e10f3ba4ffe7de01cf6840ab333 (patch) | |
| tree | b4a6e54b02e6dd9c3777ce955526f00e84a52383 /zebra/zebra_rib.c | |
| parent | 7f0d80461139311d00b837f1f6882fc8e458a6a6 (diff) | |
zebra: Reduce creation and fix memory leak of frrscripting pointers
There are two issues being addressed:
a) The ZEBRA_ON_RIB_PROCESS_HOOK_CALL script point
was creating a fs pointer per dplane ctx in
rib_process_dplane_results().
b) The fs pointer was not being deleted and directly
leaked.
For (a) Move the creation of the fs to outside
the do while loop.
For (b) At function end ensure that the pointer
is actually deleted.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'zebra/zebra_rib.c')
| -rw-r--r-- | zebra/zebra_rib.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 5e50d720a6..b0faa422c3 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -4614,6 +4614,21 @@ static void rib_process_dplane_results(struct thread *thread) struct dplane_ctx_list_head ctxlist; bool shut_p = false; +#ifdef HAVE_SCRIPTING + char *script_name = + frrscript_names_get_script_name(ZEBRA_ON_RIB_PROCESS_HOOK_CALL); + + int ret = 1; + struct frrscript *fs = NULL; + + if (script_name) { + fs = frrscript_new(script_name); + if (fs) + ret = frrscript_load(fs, ZEBRA_ON_RIB_PROCESS_HOOK_CALL, + NULL); + } +#endif /* HAVE_SCRIPTING */ + /* Dequeue a list of completed updates with one lock/unlock cycle */ do { @@ -4647,24 +4662,7 @@ static void rib_process_dplane_results(struct thread *thread) continue; } -#ifdef HAVE_SCRIPTING - char *script_name = frrscript_names_get_script_name( - ZEBRA_ON_RIB_PROCESS_HOOK_CALL); - - int ret = 1; - struct frrscript *fs; - - if (script_name) { - fs = frrscript_new(script_name); - if (fs) - ret = frrscript_load( - fs, ZEBRA_ON_RIB_PROCESS_HOOK_CALL, - NULL); - } -#endif /* HAVE_SCRIPTING */ - while (ctx) { - #ifdef HAVE_SCRIPTING if (ret == 0) frrscript_call(fs, @@ -4779,6 +4777,11 @@ static void rib_process_dplane_results(struct thread *thread) } } while (1); + +#ifdef HAVE_SCRIPTING + if (fs) + frrscript_delete(fs); +#endif } /* |
