]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Cleanup dplane provider owned ctx's on shutdown
authorDonald Sharp <sharpd@nvidia.com>
Wed, 15 Nov 2023 19:41:18 +0000 (14:41 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 21 Nov 2023 17:41:18 +0000 (12:41 -0500)
On shutdown go through and ensure that any contexts the
dplane provider holds are freed.

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

index 4063951233b9eff0d2c30cf68ee65b75a494aa3a..e1d1e84172aea2d9b04e23164ba995eecc05ffcb 100644 (file)
@@ -6859,6 +6859,31 @@ static int kernel_dplane_process_func(struct zebra_dplane_provider *prov)
        return 0;
 }
 
+static int kernel_dplane_shutdown_func(struct zebra_dplane_provider *prov,
+                                      bool early)
+{
+       struct zebra_dplane_ctx *ctx;
+
+       if (early)
+               return 1;
+
+       ctx = dplane_provider_dequeue_in_ctx(prov);
+       while (ctx) {
+               dplane_ctx_free(&ctx);
+
+               ctx = dplane_provider_dequeue_in_ctx(prov);
+       }
+
+       ctx = dplane_provider_dequeue_out_ctx(prov);
+       while (ctx) {
+               dplane_ctx_free(&ctx);
+
+               ctx = dplane_provider_dequeue_out_ctx(prov);
+       }
+
+       return 1;
+}
+
 #ifdef DPLANE_TEST_PROVIDER
 
 /*
@@ -6931,12 +6956,10 @@ static void dplane_provider_init(void)
 {
        int ret;
 
-       ret = dplane_provider_register("Kernel",
-                                      DPLANE_PRIO_KERNEL,
+       ret = dplane_provider_register("Kernel", DPLANE_PRIO_KERNEL,
                                       DPLANE_PROV_FLAGS_DEFAULT, NULL,
                                       kernel_dplane_process_func,
-                                      NULL,
-                                      NULL, NULL);
+                                      kernel_dplane_shutdown_func, NULL, NULL);
 
        if (ret != AOK)
                zlog_err("Unable to register kernel dplane provider: %d",