Skip to content

Commit

Permalink
bgpd: Fix memberCount bgp peer-grp json output
Browse files Browse the repository at this point in the history
memberCount object is moved to outer dict as better not to add into
existing collections.

Supported commands:

```
show bgp peer-group json ==> default vrf
show bgp vrf tenant1 peer-group json => non default vrf
```

Before Fix:

```
leaf-11# show bgp peer-group json
{
  "ISL":{
    "remoteAs":0,
    "type":"external",
    "addressFamiliesConfigured":[
      "IPv4 Unicast"
    ],
    "members":{
      "swp1":{
        "status":"Established"
      },
      "swp2":{
        "status":"Established"
      },
      "swp3":{
        "status":"Established"
      },
      "swp4":{
        "status":"Established"
      },
      "memberCount":4
    }
  }
}
leaf-11#
```

```
superspine1# show bgp vrf tenant1 peer-group json
{
  "vrfpeers":{
    "remoteAs":0,
    "type":"external",
    "addressFamiliesConfigured":[
      "IPv4 Unicast",
      "IPv6 Unicast"
    ],
    "dynamicRanges":{
      "IPv4":{
        "count":1,
        "ranges":[
          "0.0.0.0/0"
        ]
      },
      "IPv6":{
        "count":1,
        "ranges":[
          "::/0"
        ]
      }
    },
    "members":{
      "101.101.1.1":{
        "status":"Established",
        "dynamic":true
      },
      "memberCount":1
    }
  }
}
```

After fix:

```
leaf-11# show bgp peer-group json
{
  "ISL":{
    "remoteAs":0,
    "type":"external",
    "addressFamiliesConfigured":[
      "IPv4 Unicast"
    ],
    "memberCount":4,
    "members":{
      "swp1":{
        "status":"Established"
      },
      "swp2":{
        "status":"Established"
      },
      "swp3":{
        "status":"Established"
      },
      "swp4":{
        "status":"Established"
      }
    }
  }
}
leaf-11#
```

```
superspine1# show bgp vrf tenant1 peer-group json
{
  "vrfpeers":{
    "remoteAs":0,
    "type":"external",
    "addressFamiliesConfigured":[
      "IPv4 Unicast",
      "IPv6 Unicast"
    ],
    "dynamicRanges":{
      "IPv4":{
        "count":1,
        "ranges":[
          "0.0.0.0/0"
        ]
      },
      "IPv6":{
        "count":1,
        "ranges":[
          "::/0"
        ]
      }
    },
    "memberCount":1,
    "members":{
      "101.101.1.1":{
        "status":"Established",
        "dynamic":true
      }
    }
  }
}
```

UT done

Ticket:#4152925

Issue: 4152925

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
  • Loading branch information
Sindhu Parvathi Gopinathan authored and donaldsharp committed Feb 5, 2025
1 parent e76ef7f commit 1317e8b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -17029,8 +17029,8 @@ static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group,
member_count++;
}
if (json) {
json_object_int_add(json_peer_group_members,
"memberCount", member_count);
json_object_int_add(json_peer_group, "memberCount",
member_count);
json_object_object_add(json_peer_group, "members",
json_peer_group_members);
}
Expand Down

0 comments on commit 1317e8b

Please sign in to comment.