]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: The dplane_fpm_nl return path leaks memory
authorDonald Sharp <sharpd@nvidia.com>
Mon, 11 Dec 2023 18:41:36 +0000 (13:41 -0500)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Tue, 12 Dec 2023 06:45:53 +0000 (06:45 +0000)
The route entry created when using a ctx to pass route
entry data backup to the master pthread in zebra is
being leaked.  Prevent this from happening.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 7f9c5c7fa2d927033549a806fd9025a9459f22bc)

zebra/rib.h
zebra/rt_netlink.c
zebra/zebra_rib.c

index a02a461e8927a076bdf703f5de043a2263eb34b6..2e62148ea08ad5c4b46600f0d07447263c764947 100644 (file)
@@ -352,6 +352,8 @@ extern void _route_entry_dump(const char *func, union prefixconstptr pp,
                              union prefixconstptr src_pp,
                              const struct route_entry *re);
 
+void zebra_rib_route_entry_free(struct route_entry *re);
+
 struct route_entry *
 zebra_rib_route_entry_new(vrf_id_t vrf_id, int type, uint8_t instance,
                          uint32_t flags, uint32_t nhe_id, uint32_t table_id,
index 5d236291433694984b7b05fc201199dda7958efd..ce839cafee5fa1320bf3407786c561ae92b90809 100644 (file)
@@ -992,6 +992,8 @@ int netlink_route_change_read_unicast_internal(struct nlmsghdr *h,
                                                 re, ng, startup, ctx);
                        if (ng)
                                nexthop_group_delete(&ng);
+                       if (ctx)
+                               zebra_rib_route_entry_free(re);
                } else {
                        /*
                         * I really don't see how this is possible
index 2c3bb28d6c2eefc8adbe16667fd81f0f1b759bb8..67d4e4c35b42ed76b396b05dfa099b080e9e6168 100644 (file)
@@ -4159,6 +4159,12 @@ struct route_entry *zebra_rib_route_entry_new(vrf_id_t vrf_id, int type,
 
        return re;
 }
+
+void zebra_rib_route_entry_free(struct route_entry *re)
+{
+       XFREE(MTYPE_RE, re);
+}
+
 /*
  * Internal route-add implementation; there are a couple of different public
  * signatures. Callers in this path are responsible for the memory they