mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 07:23:41 +00:00
bgpd: resolve memory leaks in "show ip bgp neighbor json"
Found several leaks in bgp_show_peer and bgp_show_peer_afi where json objects are created and then not attached to the parent, causing them to be leaked. If not attaching them, freeing the created objects. Manual testing performed successfully. Fix tested succesfully by the submitter and bgp-smoke completed with same failures as base. Ticket: CM-12846 Signed-off-by: Don Slice Reviewed-by: CCR-5181
This commit is contained in:
parent
87aea55d34
commit
b6df409032
@ -10971,8 +10971,6 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
|
|||||||
{
|
{
|
||||||
json_addr = json_object_new_object();
|
json_addr = json_object_new_object();
|
||||||
json_af = json_object_new_object();
|
json_af = json_object_new_object();
|
||||||
json_prefA = json_object_new_object();
|
|
||||||
json_prefB = json_object_new_object();
|
|
||||||
filter = &p->filter[afi][safi];
|
filter = &p->filter[afi][safi];
|
||||||
|
|
||||||
if (peer_group_active(p))
|
if (peer_group_active(p))
|
||||||
@ -10992,6 +10990,7 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
|
|||||||
|| CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
|
|| CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
|
||||||
{
|
{
|
||||||
json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX);
|
json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX);
|
||||||
|
json_prefA = json_object_new_object();
|
||||||
bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
|
bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
|
||||||
PEER_CAP_ORF_PREFIX_SM_ADV,
|
PEER_CAP_ORF_PREFIX_SM_ADV,
|
||||||
PEER_CAP_ORF_PREFIX_RM_ADV,
|
PEER_CAP_ORF_PREFIX_RM_ADV,
|
||||||
@ -11006,6 +11005,7 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
|
|||||||
|| CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
|
|| CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
|
||||||
{
|
{
|
||||||
json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD);
|
json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD);
|
||||||
|
json_prefB = json_object_new_object();
|
||||||
bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
|
bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
|
||||||
PEER_CAP_ORF_PREFIX_SM_ADV,
|
PEER_CAP_ORF_PREFIX_SM_ADV,
|
||||||
PEER_CAP_ORF_PREFIX_RM_ADV,
|
PEER_CAP_ORF_PREFIX_RM_ADV,
|
||||||
@ -11021,6 +11021,8 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
|
|||||||
|| CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
|
|| CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
|
||||||
|| CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
|
|| CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
|
||||||
json_object_object_add(json_addr, "afDependentCap", json_af);
|
json_object_object_add(json_addr, "afDependentCap", json_af);
|
||||||
|
else
|
||||||
|
json_object_free(json_af);
|
||||||
|
|
||||||
sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
|
sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
|
||||||
orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
|
orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
|
||||||
@ -11743,6 +11745,8 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js
|
|||||||
CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
|
CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
|
||||||
CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
|
CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
|
||||||
json_object_object_add(json_add, print_store, json_sub);
|
json_object_object_add(json_add, print_store, json_sub);
|
||||||
|
else
|
||||||
|
json_object_free(json_sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
json_object_object_add(json_cap, "addPath", json_add);
|
json_object_object_add(json_cap, "addPath", json_add);
|
||||||
@ -11767,7 +11771,6 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js
|
|||||||
json_object *json_nxt = NULL;
|
json_object *json_nxt = NULL;
|
||||||
const char *print_store;
|
const char *print_store;
|
||||||
|
|
||||||
json_nxt = json_object_new_object();
|
|
||||||
|
|
||||||
if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
|
if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
|
||||||
json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived");
|
json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived");
|
||||||
@ -11778,6 +11781,8 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js
|
|||||||
|
|
||||||
if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
|
if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
|
||||||
{
|
{
|
||||||
|
json_nxt = json_object_new_object();
|
||||||
|
|
||||||
for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
|
for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
|
||||||
{
|
{
|
||||||
if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
|
if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
|
||||||
@ -11875,7 +11880,10 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! restart_af_count)
|
if (! restart_af_count)
|
||||||
json_object_string_add(json_cap, "addressFamiliesByPeer", "none");
|
{
|
||||||
|
json_object_string_add(json_cap, "addressFamiliesByPeer", "none");
|
||||||
|
json_object_free(json_restart);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart);
|
json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user