From 3c2850733fe5f205eb1c4690e2dcb438503b9674 Mon Sep 17 00:00:00 2001 From: dgsudharsan Date: Mon, 11 Dec 2023 22:46:02 +0000 Subject: [PATCH 1/3] [FRR] Fix zebra memory leak when bgp fib suppress pending is enabled --- ...The-dplane_fpm_nl-return-path-leaks-memory | 54 +++++++++++++++++++ src/sonic-frr/patch/series | 1 + 2 files changed, 55 insertions(+) create mode 100644 src/sonic-frr/patch/0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory diff --git a/src/sonic-frr/patch/0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory b/src/sonic-frr/patch/0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory new file mode 100644 index 000000000000..e47069d86710 --- /dev/null +++ b/src/sonic-frr/patch/0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory @@ -0,0 +1,54 @@ +From d3e22a5fe94422304f008e44962ca56086f96414 Mon Sep 17 00:00:00 2001 +From: dgsudharsan +Date: Mon, 11 Dec 2023 22:41:23 +0000 +Subject: [PATCH] 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. + + +diff --git a/zebra/rib.h b/zebra/rib.h +index 016106312..e99eee67c 100644 +--- a/zebra/rib.h ++++ b/zebra/rib.h +@@ -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, +diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c +index 6bdc15592..fc9e8c457 100644 +--- a/zebra/rt_netlink.c ++++ b/zebra/rt_netlink.c +@@ -1001,6 +1001,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 f2f20bcf7..1cefdfae7 100644 +--- a/zebra/zebra_rib.c ++++ b/zebra/zebra_rib.c +@@ -4136,6 +4136,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 +-- +2.17.1 + diff --git a/src/sonic-frr/patch/series b/src/sonic-frr/patch/series index c87c5e61f986..e292fa621200 100644 --- a/src/sonic-frr/patch/series +++ b/src/sonic-frr/patch/series @@ -32,3 +32,4 @@ cross-compile-changes.patch 0030-bgpd-Treat-EOR-as-withdrawn-to-avoid-unwanted-handli.patch 0031-bgpd-Ignore-handling-NLRIs-if-we-received-MP_UNREACH.patch 0032-zebra-Fix-fpm-multipath-encap-addition.patch +0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory From f77920f01e45595859adb5ad844b760da28300cc Mon Sep 17 00:00:00 2001 From: dgsudharsan Date: Wed, 13 Dec 2023 02:46:39 +0000 Subject: [PATCH 2/3] Aligning the patch --- ...-dplane_fpm_nl-return-path-leaks-memory.patch} | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) rename src/sonic-frr/patch/{0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory => 0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory.patch} (81%) diff --git a/src/sonic-frr/patch/0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory b/src/sonic-frr/patch/0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory.patch similarity index 81% rename from src/sonic-frr/patch/0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory rename to src/sonic-frr/patch/0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory.patch index e47069d86710..00e8cc0062ca 100644 --- a/src/sonic-frr/patch/0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory +++ b/src/sonic-frr/patch/0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory.patch @@ -1,10 +1,13 @@ -From d3e22a5fe94422304f008e44962ca56086f96414 Mon Sep 17 00:00:00 2001 -From: dgsudharsan -Date: Mon, 11 Dec 2023 22:41:23 +0000 -Subject: [PATCH] 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. +From c13964525dae96299dc54daf635609971576a09e Mon Sep 17 00:00:00 2001 +From: Donald Sharp +Date: Mon, 11 Dec 2023 13:41:36 -0500 +Subject: [PATCH] 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 diff --git a/zebra/rib.h b/zebra/rib.h index 016106312..e99eee67c 100644 From c1a8f712cb1080f7809278ab26d2bb6bbcd5f5bf Mon Sep 17 00:00:00 2001 From: dgsudharsan Date: Wed, 13 Dec 2023 02:47:20 +0000 Subject: [PATCH 3/3] Correcting patch name --- src/sonic-frr/patch/series | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-frr/patch/series b/src/sonic-frr/patch/series index e292fa621200..bcb29008824f 100644 --- a/src/sonic-frr/patch/series +++ b/src/sonic-frr/patch/series @@ -32,4 +32,4 @@ cross-compile-changes.patch 0030-bgpd-Treat-EOR-as-withdrawn-to-avoid-unwanted-handli.patch 0031-bgpd-Ignore-handling-NLRIs-if-we-received-MP_UNREACH.patch 0032-zebra-Fix-fpm-multipath-encap-addition.patch -0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory +0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory.patch