summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorSarita Patra <saritap@vmware.com>2021-01-12 11:46:35 +0100
committerSarita Patra <saritap@vmware.com>2021-01-22 06:15:23 +0100
commitd5f20468407f6932669de731a0590b7e2854bc54 (patch)
tree690f5901de75d4cd684541a5a508d21cab042c41 /bgpd
parentMerge pull request #7832 from pjdruddy/snmp-test-infra (diff)
downloadfrr-d5f20468407f6932669de731a0590b7e2854bc54.tar.xz
frr-d5f20468407f6932669de731a0590b7e2854bc54.zip
bgpd : multiple memory leak fixes in show commands
Issue: bgpd got kill due to out of memory, when show bgp neighbor json and show ip bgp neighbor <ip> routes json commands executed multiple times in a setup having 320554 routes. RCA: Heap allocated for bgpd keeps increasing. This is verified using top command and show memory command. Memleak Fix-1: show ip bgp route json command When dumping a large bit of table data via bgp_show_route and if there is no information to display for a particular struct bgp_node *` the data allocated via json_object_new_array() is not freed. This is resolved now. Memleak Fix-2: The function bgp_peer_counts() doesn't free the memory allocated for json_loop when there is No such neighbor or address family. This is fixed now. Signed-off-by: Sarita Patra <saritap@vmware.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_route.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index c4ab223b7..1d1f3d9b2 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -11262,8 +11262,13 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
vty,
use_json,
json_paths);
- if (use_json && display)
- json_object_object_add(json, "paths", json_paths);
+ if (use_json) {
+ if (display)
+ json_object_object_add(json, "paths",
+ json_paths);
+ else
+ json_object_free(json_paths);
+ }
} else {
if ((dest = bgp_node_match(rib, &match)) != NULL) {
const struct prefix *dest_p = bgp_dest_get_prefix(dest);
@@ -12742,6 +12747,7 @@ static int bgp_peer_counts(struct vty *vty, struct peer *peer, afi_t afi,
"No such neighbor or address family");
vty_out(vty, "%s\n", json_object_to_json_string(json));
json_object_free(json);
+ json_object_free(json_loop);
} else
vty_out(vty, "%% No such neighbor or address family\n");