]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Cleanup leaked memory on shutdown from GR code 15539/head
authorDonald Sharp <sharpd@nvidia.com>
Wed, 13 Mar 2024 01:15:29 +0000 (21:15 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 13 Mar 2024 01:18:02 +0000 (21:18 -0400)
Recent commit: 6b2554b94a
Exposed, via Address Sanitation, that memory was being
leaked.  Unfortunately the CI system did not catch this.

Two pieces of memory were being lost: The zserv client
data structure as well as anything on the client->gr_info_queue.
Clean these up.

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

index f4241f1d72c5edd533c3bd1d59c3aaeb4318b0a8..cee66cc05545630e145038c998548ddc49bb96b9 100644 (file)
@@ -298,6 +298,16 @@ struct zebra_gr_afi_clean {
  * Functions to deal with capabilities
  */
 
+void zebra_gr_client_final_shutdown(struct zserv *client)
+{
+       struct client_gr_info *info;
+
+       while (!TAILQ_EMPTY(&client->gr_info_queue)) {
+               info = TAILQ_FIRST(&client->gr_info_queue);
+               zebra_gr_client_info_delete(client, info);
+       }
+}
+
 /*
  * Function to decode and call appropriate functions
  * to handle client capabilities.
index 3671fdb50799bdd0b5ecd5b17804522045262571..e2681289b1341cc35b6a7d70b7f01fb15de2e486 100644 (file)
@@ -675,10 +675,14 @@ static void zserv_client_free(struct zserv *client)
         * If any instance are graceful restart enabled,
         * client is not deleted
         */
-       if (DYNAMIC_CLIENT_GR_DISABLED(client)) {
+       if (DYNAMIC_CLIENT_GR_DISABLED(client) || zebra_router_in_shutdown()) {
                if (IS_ZEBRA_DEBUG_EVENT)
                        zlog_debug("%s: Deleting client %s", __func__,
                                   zebra_route_string(client->proto));
+
+               if (zebra_router_in_shutdown())
+                       zebra_gr_client_final_shutdown(client);
+
                zserv_client_delete(client);
        } else {
                /* Handle cases where client has GR instance. */
index e1c990fb05cb6140f5f1966509841f39da333182..57d673060fe75bd6284a53b6db44e41a4ec3dfc0 100644 (file)
@@ -378,6 +378,7 @@ __attribute__((__noreturn__)) void zebra_finalize(struct event *event);
 /*
  * Graceful restart functions.
  */
+extern void zebra_gr_client_final_shutdown(struct zserv *client);
 extern int zebra_gr_client_disconnect(struct zserv *client);
 extern void zebra_gr_client_reconnect(struct zserv *client);
 extern void zebra_gr_stale_client_cleanup(struct list *client_list);