summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-12-11 13:41:36 -0500
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2023-12-12 06:45:31 +0000
commitff23fdfb4b33aa636aa09d144f0865dd5751551a (patch)
treec9cd94a6d8212b29f07fd229f4fa090506e09f53
parenta32620de4e27285c0c3482f385fcf03c3b6542f1 (diff)
zebra: The dplane_fpm_nl return path leaks memory
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)
-rw-r--r--zebra/rib.h2
-rw-r--r--zebra/rt_netlink.c2
-rw-r--r--zebra/zebra_rib.c6
3 files changed, 10 insertions, 0 deletions
diff --git a/zebra/rib.h b/zebra/rib.h
index e70b5c1423..f53c02bc2c 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -345,6 +345,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,
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index b8362bbba5..7b29c05498 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -1025,6 +1025,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
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 51af8953ed..0f559e874f 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -4267,6 +4267,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