]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: modify rib_update to be a bit smarter about malloc 9811/head
authorDonald Sharp <sharpd@nvidia.com>
Tue, 12 Oct 2021 17:23:40 +0000 (13:23 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 20 Oct 2021 12:28:52 +0000 (08:28 -0400)
rib_update() was mallocing memory then attempting to schedule
and if the schedule failed( it was already going to be run )
FRR would then free the memory.  Fix this memory usage pattern

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/zebra_rib.c

index 12e82dde948867649d7dbec7838eea11e70ecd2f..fcac3328c97b6d9bc833588a18ded9bb658ba32b 100644 (file)
@@ -3890,14 +3890,16 @@ void rib_update(enum rib_update_event event)
 {
        struct rib_update_ctx *ctx;
 
-       ctx = rib_update_ctx_init(0, event);
+       if (thread_is_scheduled(t_rib_update_threads[event]))
+               return;
 
+       ctx = rib_update_ctx_init(0, event);
        ctx->vrf_all = true;
 
-       if (!thread_add_event(zrouter.master, rib_update_handler, ctx, 0,
-                             &t_rib_update_threads[event]))
-               rib_update_ctx_fini(&ctx); /* Already scheduled */
-       else if (IS_ZEBRA_DEBUG_EVENT)
+       thread_add_event(zrouter.master, rib_update_handler, ctx, 0,
+                        &t_rib_update_threads[event]);
+
+       if (IS_ZEBRA_DEBUG_EVENT)
                zlog_debug("%s: Scheduled VRF (ALL), event %s", __func__,
                           rib_update_event2str(event));
 }