]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Fix the json output of show bgp all json to be in a valid format
authorRajasekar Raja <rajasekarr@nvidia.com>
Mon, 22 May 2023 20:08:34 +0000 (13:08 -0700)
committerRajasekar Raja <rajasekarr@nvidia.com>
Mon, 22 May 2023 21:02:54 +0000 (14:02 -0700)
In the json output of show bgp all json, the l2VpnEvpn afi-safi is
missing the 'routes' key making the json output format invalid.

Before Fix:
torm-11# sh bgp all json
{
<SNIP>....................
"l2VpnEvpn":{
{
  "27.0.0.15:2":{
    "rd":"27.0.0.15:2",
    "[4]:[03:44:38:39:ff:ff:01:00:00:01]:[32]:[27.0.0.15]":{
      "prefix":"[4]:[03:44:38:39:ff:ff:01:00:00:01]:[32]:[27.0.0.15]",
      "prefixLen":352,
      "paths":[
<SNIP>....................

After Fix:
torm-11# sh bgp all json
{
<SNIP>....................
"l2VpnEvpn":{
"routes":{
  "27.0.0.15:2":{
    "rd":"27.0.0.15:2",
    "[1]:[0]:[03:44:38:39:ff:ff:01:00:00:01]:[128]:[::]:[0]":{
      "prefix":"[1]:[0]:[03:44:38:39:ff:ff:01:00:00:01]:[128]:[::]:[0]",
      "prefixLen":352,
      "paths":[

Issue: 3472865
Ticket:#3472865

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
bgpd/bgp_route.c

index eb51bc1fd672333a5ecb3dbb63205af66645e690..85f08bbed5b5b7369e893a943aaf06368db1ccff 100644 (file)
@@ -13068,6 +13068,15 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
                                                        get_afi_safi_str(afi,
                                                                         safi,
                                                                         true));
+
+                                               /* Adding 'routes' key to make
+                                                * the json output format valid
+                                                * for evpn
+                                                */
+                                               if (safi == SAFI_EVPN)
+                                                       vty_out(vty,
+                                                               "\"routes\":");
+
                                        } else
                                                vty_out(vty,
                                                        "\nFor address family: %s\n",