mirror of
https://git.proxmox.com/git/mirror_frr
synced 2026-01-04 13:42:56 +00:00
bgpd: fix memory leak in evpn json outputs
Found memory leak in json output of evpn's route commands. After executing 'show bgp l2vpn evpn route type prefix json' and 'show bgp l2vpn evpn route type macip json' few times (6 times) with more than 600 routes in total seeing memory footprint for bgpd continue to grow. Memory statistics for bgpd: System allocator statistics: Total heap allocated: 12 MiB Holding block headers: 0 bytes Used small blocks: 0 bytes Used ordinary blocks: 8390 KiB Free small blocks: 1760 bytes Free ordinary blocks: 3762 KiB Ordinary blocks: 1161 Small blocks: 51 Holding blocks: 0 Ticket:CM-27920 Testing Done: After fix: excute few times, 'show bgp l2vpn evpn route type prefix json' and 'show bgp l2vpn evpn route type macip json' commands where used ordinary blocks (uordblks) is in steady state. Memory statistics for bgpd: System allocator statistics: Total heap allocated: 9968 KiB Holding block headers: 0 bytes Used small blocks: 0 bytes Used ordinary blocks: 6486 KiB Free small blocks: 1984 bytes Free ordinary blocks: 3482 KiB Ordinary blocks: 1110 Small blocks: 54 Holding blocks: 0 Memory statistics for bgpd: System allocator statistics: Total heap allocated: 10100 KiB Holding block headers: 0 bytes Used small blocks: 0 bytes Used ordinary blocks: 6488 KiB Free small blocks: 1984 bytes Free ordinary blocks: 3612 KiB Ordinary blocks: 1113 Small blocks: 54 Holding blocks: 0 Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
This commit is contained in:
parent
be3a8fa8f8
commit
a1df2ac599
@ -2579,18 +2579,29 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
|
||||
add_rd_to_json = 1;
|
||||
}
|
||||
|
||||
if (json && add_prefix_to_json) {
|
||||
json_object_object_add(json_prefix, "paths",
|
||||
json_paths);
|
||||
json_object_object_add(json_rd, prefix_str,
|
||||
json_prefix);
|
||||
if (json) {
|
||||
if (add_prefix_to_json) {
|
||||
json_object_object_add(json_prefix, "paths",
|
||||
json_paths);
|
||||
json_object_object_add(json_rd, prefix_str,
|
||||
json_prefix);
|
||||
} else {
|
||||
json_object_free(json_paths);
|
||||
json_object_free(json_prefix);
|
||||
json_paths = NULL;
|
||||
json_prefix = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (json && add_rd_to_json)
|
||||
json_object_object_add(json, rd_str, json_rd);
|
||||
|
||||
if (json) {
|
||||
if (add_rd_to_json)
|
||||
json_object_object_add(json, rd_str, json_rd);
|
||||
else {
|
||||
json_object_free(json_rd);
|
||||
json_rd = NULL;
|
||||
}
|
||||
|
||||
json_object_int_add(json, "numPrefix", prefix_cnt);
|
||||
json_object_int_add(json, "numPaths", path_cnt);
|
||||
} else {
|
||||
@ -2732,16 +2743,31 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
|
||||
json_path);
|
||||
}
|
||||
|
||||
if (json && add_prefix_to_json) {
|
||||
json_object_object_add(json_prefix, "paths",
|
||||
json_paths);
|
||||
json_object_object_add(json_rd, prefix_str,
|
||||
json_prefix);
|
||||
if (json) {
|
||||
if (add_prefix_to_json) {
|
||||
json_object_object_add(json_prefix,
|
||||
"paths",
|
||||
json_paths);
|
||||
json_object_object_add(json_rd,
|
||||
prefix_str,
|
||||
json_prefix);
|
||||
} else {
|
||||
json_object_free(json_prefix);
|
||||
json_object_free(json_paths);
|
||||
json_prefix = NULL;
|
||||
json_paths = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (json && add_rd_to_json)
|
||||
json_object_object_add(json, rd_str, json_rd);
|
||||
if (json) {
|
||||
if (add_rd_to_json)
|
||||
json_object_object_add(json, rd_str, json_rd);
|
||||
else {
|
||||
json_object_free(json_rd);
|
||||
json_rd = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (json) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user