Skip to content

Add memberCount into peer-grp json AND GR fields in fields in show bgp vrfs json - #20578

Merged
riw777 merged 4 commits into
FRRouting:masterfrom
raja-rajasekar:rajasekarr/json_fixes
Feb 10, 2026
Merged

Add memberCount into peer-grp json AND GR fields in fields in show bgp vrfs json#20578
riw777 merged 4 commits into
FRRouting:masterfrom
raja-rajasekar:rajasekarr/json_fixes

Conversation

@raja-rajasekar

Copy link
Copy Markdown
Contributor

Add memberCount into peer-grp json AND GR fields in fields in show bgp vrfs json

2026-01-22 22:08:33,826 DEBUG: r3: cmd_status("/bin/bash -c 'vtysh  -c '"'"'show bgp vrfs default json'"'"' 2>/dev/null'")
2026-01-22 22:08:34,456 DEBUG: r3:
        stdout: ...
2026-01-22 22:08:34,456 DEBUG: r3: vtysh result:
        {
          "default":{
            "type":"DFLT",
            "vrfId":0,
            "routerId":"172.16.255.3",
            "as":65003,
            "numConfiguredPeers":1,
            "numEstablishedPeers":1,
            "l3vni":0,
            "rmac":"00:00:00:00:00:00",
            "interface":"unknown",
            "grRestartTime":120,
            "grStalePathTime":360,
            "grSelectDeferTime":120,
            "grMode":"Helper",
            "waitforFIBset":false,
            "gShutEnabled":false
          }

@frrbot frrbot Bot added bgp tests Topotests, make check, etc labels Jan 22, 2026
@greptile-apps

greptile-apps Bot commented Jan 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR enhances JSON output observability for BGP by adding two sets of fields:

  1. Graceful Restart fields in VRF JSON (show bgp vrfs json):

    • Added as field for AS number
    • Added GR timing fields: grRestartTime, grStalePathTime, grSelectDeferTime
    • Added grMode to show global GR mode (Helper/Restart/etc)
    • Added operational flags: waitforFIBset and gShutEnabled
  2. Member count in peer group JSON (show bgp peer-group json):

    • Added memberCount field to track number of peers in group

The implementation correctly extracts GR mode and configuration values from BGP structures, and both JSON and text output paths have been updated consistently. Tests validate the new fields match expected values. The GR fields are displayed outside the BM_FLAG_GRACEFUL_RESTART check, which is appropriate since these configuration values are always set (via config or defaults).

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - it adds informational fields to JSON output without changing behavior
  • Score reflects straightforward observability enhancement with comprehensive tests. Minor style improvement suggested for memberCount consistency (always present in JSON even when 0), but not critical for functionality
  • No files require special attention - all changes are additive JSON fields with matching test coverage

Important Files Changed

Filename Overview
bgpd/bgp_vty.c Added GR fields (restart/stale/defer times, mode, FIB/gShut flags) to VRF JSON output and memberCount to peer group JSON. New fields enhance observability.
tests/topotests/bgp_gr_restart_retain_routes/test_bgp_gr_per_neighbor_restart_retain_routes.py Added validation test for new GR fields in VRF JSON output, checking restart/stale/defer times, mode, and flags match expected values.
tests/topotests/bgp_peergroup_gshut/test_bgp_peergroup_gshut.py Added validation for memberCount field in peer group JSON output, ensuring count matches expected value of 2 members.

Sequence Diagram

sequenceDiagram
    participant User
    participant VTY
    participant bgp_vty.c
    participant BGP

    Note over User,BGP: Show BGP VRFs Command
    User->>VTY: show bgp vrfs [name] json
    VTY->>bgp_vty.c: show_bgp_vrfs_detail_common()
    bgp_vty.c->>bgp_vty.c: print_bgp_vrfs()
    bgp_vty.c->>BGP: bgp_global_gr_mode_get(bgp)
    BGP-->>bgp_vty.c: gr_mode
    bgp_vty.c->>BGP: read restart_time, stalepath_time, select_defer_time
    bgp_vty.c->>BGP: CHECK_FLAG(BGP_FLAG_SUPPRESS_FIB_PENDING)
    bgp_vty.c->>BGP: CHECK_FLAG(BGP_FLAG_GRACEFUL_SHUTDOWN)
    bgp_vty.c->>VTY: JSON with as, GR fields, FIB/gShut flags
    VTY-->>User: Complete VRF JSON output

    Note over User,BGP: Show BGP Peer Group Command
    User->>VTY: show bgp peer-group [name] json
    VTY->>bgp_vty.c: bgp_show_one_peer_group()
    loop For each peer in group
        bgp_vty.c->>bgp_vty.c: member_count++
    end
    bgp_vty.c->>VTY: JSON with memberCount
    VTY-->>User: Peer group JSON with member count
Loading

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread bgpd/bgp_vty.c Outdated
@raja-rajasekar
raja-rajasekar force-pushed the rajasekarr/json_fixes branch 2 times, most recently from f886a35 to 4462719 Compare January 22, 2026 22:29

@donaldsharp donaldsharp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread bgpd/bgp_vty.c Outdated
json_object_int_add(json, "grStalePathTime", bgp->stalepath_time);
json_object_int_add(json, "grSelectDeferTime", bgp->select_defer_time);
json_object_string_add(json, "grMode", bgp_global_gr_mode_str[gr_mode]);
json_object_boolean_add(json, "waitforFIBset",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitForFibSet (camelCase)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sindhu Parvathi Gopinathan and others added 2 commits January 26, 2026 10:17
Member count is not part of current show bgp peer-group json output.

Fix:

memberCount attribute is added into bgp peer-grp json output.

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
Validate memberCount into peer-grp json output

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
@raja-rajasekar
raja-rajasekar force-pushed the rajasekarr/json_fixes branch 2 times, most recently from 426db9e to 0cc830f Compare January 26, 2026 19:21
Comment thread bgpd/bgp_vty.c Outdated
vty_out(vty, "Wait for FIB is set: %s\n",
CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING) ? "YES"
: "NO");
vty_out(vty, "BGP GSHUT is enabled: %s\n",

@ton31337 ton31337 Jan 27, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not shorten words for non-JSON outputs? Any reason to write like this instead of "BGP graceful shutdown is enabled"? Because now it looks like a "draft output".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

aprathik04 and others added 2 commits January 27, 2026 06:36
included vrf level bgp parameters - graceful restart timers, gshut,
suppress-fib-pending, AS number.

VTY output -

leaf11# show bgp vrfs default
BGP instance VRF default VRF id 0
Router Id 6.0.0.4
AS number 65011
Num Configured Peers 6, Established 6
Global graceful restart mode is Restarter
GR Restart Time Configured: 300s
GR Stale Path Time Configured: 900s
GR Select Defer Time Configured: 300s
Wait for FIB is set: YES
BGP GSHUT is enabled: NO

JSON output -

leaf11# show bgp vrfs default json
{
  "default":{
    "type":"DFLT",
    "vrfId":0,
    "routerId":"6.0.0.4",
    "as":65011,
    "numConfiguredPeers":6,
    "numEstablishedPeers":6,
    "l3vni":0,
    "rmac":"00:00:00:00:00:00",
    "interface":"unknown",
    "grRestartTime":300,
    "grStalePathTime":900,
    "grSelectDeferTime":300,
    "grMode":"Restarter",
    "waitforFIBset":true,
    "gShutEnabled":false
  }
}
leaf11#

Signed-off-by: Aprathi K <aprathik@nvidia.com>

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
Validate new GR fields in show bgp vrfs json

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>

@riw777 riw777 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@riw777
riw777 merged commit 1d9c965 into FRRouting:master Feb 10, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bgp master size/M tests Topotests, make check, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants