From: Louis Scalbert Date: Wed, 12 Feb 2025 11:50:42 +0000 (+0100) Subject: bgpd: fix incorrect json in bgp_show_table_rd X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=be6659ad298ac73605b1121e99bdc6c6b126c6a3;p=matthieu%2Ffrr.git bgpd: fix incorrect json in bgp_show_table_rd In bgp_show_table_rd(), the is_last argument is determined using the expression "next == NULL" to check if the RD table is the last one. This helps ensure proper JSON formatting. However, if next is not NULL but is no longer associated with a BGP table, the JSON output becomes malformed. Updates the condition to also verify the existence of the next bgp_dest table. Fixes: 1ae44dfcba ("bgpd: unify 'show bgp' with RD with normal unicast bgp show") Signed-off-by: Louis Scalbert (cherry picked from commit cf0269649cdd09b8d3f2dd8815caf6ecf9cdeef9) --- diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index aa2c3a6a56..ed38f61d9a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -11704,10 +11704,9 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, memcpy(&prd, dest_p, sizeof(struct prefix_rd)); prefix_rd2str(&prd, rd, sizeof(rd), bgp->asnotation); - bgp_show_table(vty, bgp, afi, safi, itable, type, output_arg, - rd, next == NULL, &output_cum, - &total_cum, &json_header_depth, - show_flags, RPKI_NOT_BEING_USED); + bgp_show_table(vty, bgp, afi, safi, itable, type, output_arg, rd, + !bgp_dest_get_bgp_table_info(next), &output_cum, &total_cum, + &json_header_depth, show_flags, RPKI_NOT_BEING_USED); if (next == NULL) show_msg = false; }