|
| 1 | +From c13964525dae96299dc54daf635609971576a09e Mon Sep 17 00:00:00 2001 |
| 2 | +From: Donald Sharp < [email protected]> |
| 3 | +Date: Mon, 11 Dec 2023 13:41:36 -0500 |
| 4 | +Subject: [PATCH] zebra: The dplane_fpm_nl return path leaks memory |
| 5 | + |
| 6 | +The route entry created when using a ctx to pass route |
| 7 | +entry data backup to the master pthread in zebra is |
| 8 | +being leaked. Prevent this from happening. |
| 9 | + |
| 10 | +Signed-off-by: Donald Sharp < [email protected]> |
| 11 | + |
| 12 | +diff --git a/zebra/rib.h b/zebra/rib.h |
| 13 | +index 016106312..e99eee67c 100644 |
| 14 | +--- a/zebra/rib.h |
| 15 | ++++ b/zebra/rib.h |
| 16 | +@@ -352,6 +352,8 @@ extern void _route_entry_dump(const char *func, union prefixconstptr pp, |
| 17 | + union prefixconstptr src_pp, |
| 18 | + const struct route_entry *re); |
| 19 | + |
| 20 | ++void zebra_rib_route_entry_free(struct route_entry *re); |
| 21 | ++ |
| 22 | + struct route_entry * |
| 23 | + zebra_rib_route_entry_new(vrf_id_t vrf_id, int type, uint8_t instance, |
| 24 | + uint32_t flags, uint32_t nhe_id, uint32_t table_id, |
| 25 | +diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c |
| 26 | +index 6bdc15592..fc9e8c457 100644 |
| 27 | +--- a/zebra/rt_netlink.c |
| 28 | ++++ b/zebra/rt_netlink.c |
| 29 | +@@ -1001,6 +1001,8 @@ int netlink_route_change_read_unicast_internal(struct nlmsghdr *h, |
| 30 | + re, ng, startup, ctx); |
| 31 | + if (ng) |
| 32 | + nexthop_group_delete(&ng); |
| 33 | ++ if (ctx) |
| 34 | ++ zebra_rib_route_entry_free(re); |
| 35 | + } else { |
| 36 | + /* |
| 37 | + * I really don't see how this is possible |
| 38 | +diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c |
| 39 | +index f2f20bcf7..1cefdfae7 100644 |
| 40 | +--- a/zebra/zebra_rib.c |
| 41 | ++++ b/zebra/zebra_rib.c |
| 42 | +@@ -4136,6 +4136,12 @@ struct route_entry *zebra_rib_route_entry_new(vrf_id_t vrf_id, int type, |
| 43 | + |
| 44 | + return re; |
| 45 | + } |
| 46 | ++ |
| 47 | ++void zebra_rib_route_entry_free(struct route_entry *re) |
| 48 | ++{ |
| 49 | ++ XFREE(MTYPE_RE, re); |
| 50 | ++} |
| 51 | ++ |
| 52 | + /* |
| 53 | + * Internal route-add implementation; there are a couple of different public |
| 54 | + * signatures. Callers in this path are responsible for the memory they |
| 55 | +-- |
| 56 | +2.17.1 |
| 57 | + |
0 commit comments