Skip to content

Commit f390cda

Browse files
Karthikeya Venkat Muppallachiragshah6
authored andcommitted
bgpd:[GR] fix crash in print_bgp_vrfs json
When BGP is in warm boot and `show bgp vrfs json` is executed more than once, bgpd crashes in print_bgp_vrfs. This is happening because of JSON object is being added multiple times to the JSON array with out allocating everytime in the for loop and when json is freed, it causes the crash. NOTE: This commit needs to be integrated with original commit 4af3b55 Ticket: #3861755 Testing: Before the fix: switch# show bgp vrfs json Warning: connecting to bgpd...success! { .. <snippet> } switch# show bgp vrfs json Warning: closing connection to bgpd because of an I/O error! Warning: connecting to bgpd...failed! After the fix: BGP no longer crashes on `show bgp vrfs json` command and it works as expected. switch# show bgp vrfs json { "vrfs":{ .. <snippet> } switch# show bgp vrfs json { "vrfs":{ .. <snippet> } switch# show bgp vrfs json { "vrfs":{ .. <snippet> } switch# show bgp vrfs json { "vrfs":{ .. <snippet> } Signed-off-by: Karthikeya Venkat Muppalla <kmuppalla@nvidia.com> Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
1 parent ef0460b commit f390cda

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bgpd/bgp_vty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11227,11 +11227,11 @@ static void print_bgp_vrfs(struct bgp *bgp, struct vty *vty, json_object *json,
1122711227
safi_t safi = SAFI_UNICAST;
1122811228
struct graceful_restart_info *gr_info;
1122911229
json_object *json_gr = NULL;
11230-
json_gr = json_object_new_object();
1123111230
json_object *json_grs = NULL;
1123211231
json_grs = json_object_new_array();
1123311232

1123411233
for (afi = AFI_IP; afi <= AFI_IP6; afi++) {
11234+
json_gr = json_object_new_object();
1123511235
json_object_string_add(
1123611236
json_gr, "addressFamily",
1123711237
get_afi_safi_str(afi, safi, false));

0 commit comments

Comments
 (0)