Skip to content

Commit 27b05dd

Browse files
authored
[FRR] Fix zebra memory leak when bgp fib suppress pending is enabled (sonic-net#17484) (sonic-net#17977)
Fix zebra leaking memory with fib suppress enabled. Porting the fix from FRRouting/frr#14983 While running test_stress_route.py, systems with lower memory started to throw low memory logs. On further investigation, a memory leak has been found in zebra which was fixed in the FRR community.
1 parent e676ad1 commit 27b05dd

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+

src/sonic-frr/patch/series

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ cross-compile-changes.patch
2929
0030-bgpd-Treat-EOR-as-withdrawn-to-avoid-unwanted-handli.patch
3030
0031-bgpd-Ignore-handling-NLRIs-if-we-received-MP_UNREACH.patch
3131
0032-zebra-Fix-fpm-multipath-encap-addition.patch
32+
0033-zebra-The-dplane_fpm_nl-return-path-leaks-memory.patch
3233
0034-fpm-Use-vrf_id-for-vrf-not-tabled_id.patch
3334
0035-fpm-ignore-route-from-default-table.patch
3435
0036-Add-support-of-bgp-l3vni-evpn.patch

0 commit comments

Comments
 (0)