Skip to content

zebra: show nexthop-group rib brief json#224

Open
mwinter-osr wants to merge 3 commits intoopensourcerouting:masterfrom
mwinter-osr:PR20953
Open

zebra: show nexthop-group rib brief json#224
mwinter-osr wants to merge 3 commits intoopensourcerouting:masterfrom
mwinter-osr:PR20953

Conversation

@mwinter-osr
Copy link
Copy Markdown
Member

Commands supported:
1)show nexthop-group rib brief json
2)show nexthop-group rib 117 brief json
3)show nexthop-group rib singleton ip brief json
4)show nexthop-group rib singleton ipv6 brief json
5)show nexthop-group rib zebra brief json

r1# show nexthop-group rib brief json
{"default":{"64":{"uptime":"00:00:59","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":5,"nexthops":[{"interfaceIndex":5,"interfaceName":"r1-eth3","vrf":"default"}]},"67":{"uptime":"00:00:59","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":4,"nexthops":[{"interfaceIndex":4,"interfaceName":"r1-eth2","vrf":"default"}]},"68":{"uptime":"00:01:00","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":7,"nexthops":[{"interfaceIndex":7,"interfaceName":"r1-eth5","vrf":"default"}]},"37":{"uptime":"00:01:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"nexthops":[{}]},"38":{"uptime":"00:01:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"nexthops":[{}]},"39":{"uptime":"00:00:59","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"72":{"uptime":"00:00:59","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":10,"nexthops":[{"interfaceIndex":10,"interfaceName":"r1-eth8","vrf":"default"}]},"40":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"ip":"192.168.0.2","interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"41":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":1,"valid":true,"interfaceIndex":2,"nexthops":[{"ip":"192.168.0.4","interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"74":{"uptime":"00:00:59","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":3,"nexthops":[{"interfaceIndex":3,"interfaceName":"r1-eth1","vrf":"default"}]},"11":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"12":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":3,"nexthops":[{"interfaceIndex":3,"interfaceName":"r1-eth1","vrf":"default"}]},"13":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":4,"nexthops":[{"interfaceIndex":4,"interfaceName":"r1-eth2","vrf":"default"}]},"14":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":5,"nexthops":[{"interfaceIndex":5,"interfaceName":"r1-eth3","vrf":"default"}]},"15":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":6,"nexthops":[{"interfaceIndex":6,"interfaceName":"r1-eth4","vrf":"default"}]},"16":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":7,"nexthops":[{"interfaceIndex":7,"interfaceName":"r1-eth5","vrf":"default"}]},"81":{"uptime":"00:00:59","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"ip":"fc00::2","interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"17":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":8,"nexthops":[{"interfaceIndex":8,"interfaceName":"r1-eth6","vrf":"default"}]},"50":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":0,"nexthops":[{"ip":"192.168.161.4","vrf":"default"}]},"18":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":9,"nexthops":[{"interfaceIndex":9,"interfaceName":"r1-eth7","vrf":"default"}]},"19":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":10,"nexthops":[{"interfaceIndex":10,"interfaceName":"r1-eth8","vrf":"default"}]},"52":{"uptime":"00:01:01","vrf":"default","afi":"No AFI","nexthopCount":4,"flags":3,"valid":true,"installed":true,"depends":[40,50,53,54]},"20":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":11,"nexthops":[{"interfaceIndex":11,"interfaceName":"r1-eth9","vrf":"default"}]},"53":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":3,"nexthops":[{"ip":"192.168.1.2","interfaceIndex":3,"interfaceName":"r1-eth1","vrf":"default"}]},"54":{"uptime":"00:01:01","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":4,"nexthops":[{"ip":"192.168.2.2","interfaceIndex":4,"interfaceName":"r1-eth2","vrf":"default"}]},"56":{"uptime":"00:00:59","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":9,"nexthops":[{"interfaceIndex":9,"interfaceName":"r1-eth7","vrf":"default"}]},"58":{"uptime":"00:00:59","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":8,"nexthops":[{"interfaceIndex":8,"interfaceName":"r1-eth6","vrf":"default"}]},"60":{"uptime":"00:00:59","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":6,"nexthops":[{"interfaceIndex":6,"interfaceName":"r1-eth4","vrf":"default"}]},"62":{"uptime":"00:00:59","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":11,"nexthops":[{"interfaceIndex":11,"interfaceName":"r1-eth9","vrf":"default"}]}}}
r1#
r1# show nexthop-group rib 64 brief json
{
"64":{
"uptime":"00:03:25",
"vrf":"default",
"afi":"IPv6",
"nexthopCount":1,
"flags":515,
"valid":true,
"installed":true,
"initialDelay":true,
"interfaceIndex":5,
"nexthops":[
{
"interfaceIndex":5,
"interfaceName":"r1-eth3",
"vrf":"default"
}
]
}
}
r1# r1# show nexthop-group rib singleton ip brief json
{"default":{"40":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"ip":"192.168.0.2","interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"41":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":1,"valid":true,"interfaceIndex":2,"nexthops":[{"ip":"192.168.0.4","interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"11":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"12":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":3,"nexthops":[{"interfaceIndex":3,"interfaceName":"r1-eth1","vrf":"default"}]},"13":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":4,"nexthops":[{"interfaceIndex":4,"interfaceName":"r1-eth2","vrf":"default"}]},"14":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":5,"nexthops":[{"interfaceIndex":5,"interfaceName":"r1-eth3","vrf":"default"}]},"15":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":6,"nexthops":[{"interfaceIndex":6,"interfaceName":"r1-eth4","vrf":"default"}]},"16":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":7,"nexthops":[{"interfaceIndex":7,"interfaceName":"r1-eth5","vrf":"default"}]},"17":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":8,"nexthops":[{"interfaceIndex":8,"interfaceName":"r1-eth6","vrf":"default"}]},"50":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":0,"nexthops":[{"ip":"192.168.161.4","vrf":"default"}]},"18":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":9,"nexthops":[{"interfaceIndex":9,"interfaceName":"r1-eth7","vrf":"default"}]},"19":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":10,"nexthops":[{"interfaceIndex":10,"interfaceName":"r1-eth8","vrf":"default"}]},"20":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":11,"nexthops":[{"interfaceIndex":11,"interfaceName":"r1-eth9","vrf":"default"}]},"53":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":3,"nexthops":[{"ip":"192.168.1.2","interfaceIndex":3,"interfaceName":"r1-eth1","vrf":"default"}]},"54":{"uptime":"00:03:59","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":4,"nexthops":[{"ip":"192.168.2.2","interfaceIndex":4,"interfaceName":"r1-eth2","vrf":"default"}]}}}
r1# show nexthop-group rib singleton ipv6 brief json
{"default":{"64":{"uptime":"00:04:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":5,"nexthops":[{"interfaceIndex":5,"interfaceName":"r1-eth3","vrf":"default"}]},"67":{"uptime":"00:04:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":4,"nexthops":[{"interfaceIndex":4,"interfaceName":"r1-eth2","vrf":"default"}]},"68":{"uptime":"00:04:02","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":7,"nexthops":[{"interfaceIndex":7,"interfaceName":"r1-eth5","vrf":"default"}]},"37":{"uptime":"00:04:03","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"nexthops":[{}]},"38":{"uptime":"00:04:03","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"nexthops":[{}]},"39":{"uptime":"00:04:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"72":{"uptime":"00:04:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":10,"nexthops":[{"interfaceIndex":10,"interfaceName":"r1-eth8","vrf":"default"}]},"74":{"uptime":"00:04:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":3,"nexthops":[{"interfaceIndex":3,"interfaceName":"r1-eth1","vrf":"default"}]},"81":{"uptime":"00:04:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"ip":"fc00::2","interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"56":{"uptime":"00:04:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":9,"nexthops":[{"interfaceIndex":9,"interfaceName":"r1-eth7","vrf":"default"}]},"58":{"uptime":"00:04:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":8,"nexthops":[{"interfaceIndex":8,"interfaceName":"r1-eth6","vrf":"default"}]},"60":{"uptime":"00:04:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":6,"nexthops":[{"interfaceIndex":6,"interfaceName":"r1-eth4","vrf":"default"}]},"62":{"uptime":"00:04:01","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":11,"nexthops":[{"interfaceIndex":11,"interfaceName":"r1-eth9","vrf":"default"}]}}}
r1# show nexthop-group rib zebra brief json
{"default":{"64":{"uptime":"00:04:27","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":5,"nexthops":[{"interfaceIndex":5,"interfaceName":"r1-eth3","vrf":"default"}]},"67":{"uptime":"00:04:27","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":4,"nexthops":[{"interfaceIndex":4,"interfaceName":"r1-eth2","vrf":"default"}]},"68":{"uptime":"00:04:28","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":7,"nexthops":[{"interfaceIndex":7,"interfaceName":"r1-eth5","vrf":"default"}]},"37":{"uptime":"00:04:29","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"nexthops":[{}]},"38":{"uptime":"00:04:29","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"nexthops":[{}]},"39":{"uptime":"00:04:27","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"72":{"uptime":"00:04:27","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":10,"nexthops":[{"interfaceIndex":10,"interfaceName":"r1-eth8","vrf":"default"}]},"40":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"ip":"192.168.0.2","interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"41":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":1,"valid":true,"interfaceIndex":2,"nexthops":[{"ip":"192.168.0.4","interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"74":{"uptime":"00:04:27","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":3,"nexthops":[{"interfaceIndex":3,"interfaceName":"r1-eth1","vrf":"default"}]},"11":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"12":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":3,"nexthops":[{"interfaceIndex":3,"interfaceName":"r1-eth1","vrf":"default"}]},"13":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":4,"nexthops":[{"interfaceIndex":4,"interfaceName":"r1-eth2","vrf":"default"}]},"14":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":5,"nexthops":[{"interfaceIndex":5,"interfaceName":"r1-eth3","vrf":"default"}]},"15":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":6,"nexthops":[{"interfaceIndex":6,"interfaceName":"r1-eth4","vrf":"default"}]},"16":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":7,"nexthops":[{"interfaceIndex":7,"interfaceName":"r1-eth5","vrf":"default"}]},"81":{"uptime":"00:04:27","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":2,"nexthops":[{"ip":"fc00::2","interfaceIndex":2,"interfaceName":"r1-eth0","vrf":"default"}]},"17":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":8,"nexthops":[{"interfaceIndex":8,"interfaceName":"r1-eth6","vrf":"default"}]},"50":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":0,"nexthops":[{"ip":"192.168.161.4","vrf":"default"}]},"18":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":9,"nexthops":[{"interfaceIndex":9,"interfaceName":"r1-eth7","vrf":"default"}]},"19":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":10,"nexthops":[{"interfaceIndex":10,"interfaceName":"r1-eth8","vrf":"default"}]},"52":{"uptime":"00:04:29","vrf":"default","afi":"No AFI","nexthopCount":4,"flags":3,"valid":true,"installed":true,"depends":[40,50,53,54]},"20":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":11,"nexthops":[{"interfaceIndex":11,"interfaceName":"r1-eth9","vrf":"default"}]},"53":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":3,"nexthops":[{"ip":"192.168.1.2","interfaceIndex":3,"interfaceName":"r1-eth1","vrf":"default"}]},"54":{"uptime":"00:04:29","vrf":"default","afi":"IPv4","nexthopCount":1,"flags":3,"valid":true,"installed":true,"interfaceIndex":4,"nexthops":[{"ip":"192.168.2.2","interfaceIndex":4,"interfaceName":"r1-eth2","vrf":"default"}]},"56":{"uptime":"00:04:27","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":9,"nexthops":[{"interfaceIndex":9,"interfaceName":"r1-eth7","vrf":"default"}]},"58":{"uptime":"00:04:27","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":8,"nexthops":[{"interfaceIndex":8,"interfaceName":"r1-eth6","vrf":"default"}]},"60":{"uptime":"00:04:27","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":6,"nexthops":[{"interfaceIndex":6,"interfaceName":"r1-eth4","vrf":"default"}]},"62":{"uptime":"00:04:27","vrf":"default","afi":"IPv6","nexthopCount":1,"flags":515,"valid":true,"installed":true,"initialDelay":true,"interfaceIndex":11,"nexthops":[{"interfaceIndex":11,"interfaceName":"r1-eth9","vrf":"default"}]}}}
r1#

Original PR20953 by hnattamaisub

Commands supported:
1)show nexthop-group rib brief json
2)show nexthop-group rib 117 brief json
3)show nexthop-group rib singleton ip brief json
4)show nexthop-group rib singleton ipv6 brief json
5)show nexthop-group rib zebra brief json

Signed-off-by: harini <hnattamaisub@nvidia.com>
Signed-off-by: harini <hnattamaisub@nvidia.com>
Signed-off-by: harini <hnattamaisub@nvidia.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 14, 2026

Greptile Summary

Adds json brief output to show nexthop-group rib and its filtered variants (by ID, singleton ip/ipv6, and type). In brief mode the per-entry JSON omits type, refCount, and timeToDeletion; NHGs with dependencies emit a depends array in place of per-nexthop detail; all five variants have a topotest and the CLI reference is updated.

Note: the PR description and title show the arguments in the order brief json, but the CLI grammar (and documentation) correctly requires json [brief]; the code and topotests use the correct order.

Confidence Score: 5/5

  • Safe to merge; P0 criteria (topotest and user docs) are both satisfied and no P1 defects were found.
  • All remaining findings are P2: a pretty/compact inconsistency for the ID-based brief path, in-memory accumulation when the NHG table is large, weaker per-entry validation in three of the five topotest sub-cases, and a minor field-ordering change in non-brief nexthop JSON. None of these block correctness of the feature.
  • zebra/zebra_vty.c (brief output flushing and vty_json consistency) and tests/topotests/all_protocol_startup/test_all_protocol_startup.py (extend per-entry checks to commands 3–5)

Important Files Changed

Filename Overview
zebra/zebra_vty.c Core implementation of brief JSON mode; adds brief flag through the call chain and manages JSON accumulation correctly. Minor inconsistencies: ID-based brief query uses vty_json (pretty) while bulk brief uses vty_json_no_pretty, and brief mode disables streaming flush causing full in-memory accumulation.
lib/nexthop.c Adds brief parameter to nexthop_json_helper; correctly gates verbose fields. Side effect: vrf field is now emitted before type-specific detail fields in non-brief mode, changing serialisation order for existing JSON output.
zebra/zebra_rnh.c Signature update for show_nexthop_json_helper; all existing callers correctly pass false for brief.
doc/user/zebra.rst CLI reference updated with [json [brief]] syntax and a brief prose description of what each modifier omits; accurate and complete.
tests/topotests/all_protocol_startup/test_all_protocol_startup.py New test_show_nexthop_group_rib_brief_json covers all five command variants. Commands 1 and 2 validate per-entry field constraints; commands 3–5 only check top-level structure, leaving brief-mode regressions on singleton/type-filtered paths undetected.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    CMD["show nexthop-group rib ... json [brief]"]
    CMD --> ID{id present?}
    ID -- yes --> IDHELPER["show_nexthop_group_id_cmd_helper(brief)"]
    ID -- no --> VRFALL{vrf all?}
    VRFALL -- yes --> FOREACH["RB_FOREACH vrfs → show_nexthop_group_cmd_helper(brief)"]
    VRFALL -- no --> SINGLE["show_nexthop_group_cmd_helper(brief)"]
    FOREACH --> WALKER
    SINGLE --> WALKER["nhe_show_walker → show_nexthop_group_out(brief)"]
    IDHELPER --> NHG_OUT["show_nexthop_group_out(brief)"]
    NHG_OUT --> HAS_DEPS{NHG has\ndependencies?}
    HAS_DEPS -- yes\nbriefJSON --> DEP_ONLY["emit uptime/vrf/flags/depends\nskip nexthop loop\nfree nexthop_array\nearly return"]
    HAS_DEPS -- no\nbriefJSON --> NEXTHOP_LOOP["loop nexthops\nnexthop_json_helper(brief=true)\nskips flags/afi/resolver/labels…"]
    HAS_DEPS -- any\nnon-brief --> FULL["full nexthop_json_helper\n+ backups + dependents + buckets"]
    DEP_ONLY --> ATTACH["json_object_object_addf(json_nhe_hdr, json, id)"]
    NEXTHOP_LOOP --> ATTACH
    FULL --> ATTACH
    IDHELPER --> OUT_PRETTY["vty_json (pretty)"]
    WALKER --> OUT_COMPACT["vty_json_no_pretty (compact)"]
Loading

Comments Outside Diff (2)

  1. zebra/zebra_vty.c, line 1435-1438 (link)

    P2 Pretty vs compact inconsistency for brief ID queries

    show_nexthop_group_id_cmd_helper always calls vty_json (pretty-print) for both brief and non-brief output. Every other brief code path uses vty_json_no_pretty. Callers automating on brief output from a single-NHG query will receive formatted JSON while the bulk commands return compact JSON.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: zebra/zebra_vty.c
    Line: 1435-1438
    
    Comment:
    **Pretty vs compact inconsistency for brief ID queries**
    
    `show_nexthop_group_id_cmd_helper` always calls `vty_json` (pretty-print) for both brief and non-brief output. Every other brief code path uses `vty_json_no_pretty`. Callers automating on brief output from a single-NHG query will receive formatted JSON while the bulk commands return compact JSON.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
  2. zebra/zebra_vty.c, line 1474-1479 (link)

    P2 All-in-memory accumulation for brief mode

    In brief mode the per-5-entry streaming flush is disabled and every NHG entry is accumulated in the in-process json tree before vty_json_no_pretty outputs it all at once. On a router with thousands of NHG entries (common with large BGP tables) this creates a single allocation many times larger than the non-brief streaming path produces. Consider adding a flush threshold for brief mode too, or documenting the trade-off.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: zebra/zebra_vty.c
    Line: 1474-1479
    
    Comment:
    **All-in-memory accumulation for brief mode**
    
    In brief mode the per-5-entry streaming flush is disabled and every NHG entry is accumulated in the in-process `json` tree before `vty_json_no_pretty` outputs it all at once. On a router with thousands of NHG entries (common with large BGP tables) this creates a single allocation many times larger than the non-brief streaming path produces. Consider adding a flush threshold for brief mode too, or documenting the trade-off.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: zebra/zebra_vty.c
Line: 1435-1438

Comment:
**Pretty vs compact inconsistency for brief ID queries**

`show_nexthop_group_id_cmd_helper` always calls `vty_json` (pretty-print) for both brief and non-brief output. Every other brief code path uses `vty_json_no_pretty`. Callers automating on brief output from a single-NHG query will receive formatted JSON while the bulk commands return compact JSON.

```suggestion
	if (json) {
		if (brief)
			vty_json_no_pretty(vty, json);
		else
			vty_json(vty, json);
	}
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: zebra/zebra_vty.c
Line: 1474-1479

Comment:
**All-in-memory accumulation for brief mode**

In brief mode the per-5-entry streaming flush is disabled and every NHG entry is accumulated in the in-process `json` tree before `vty_json_no_pretty` outputs it all at once. On a router with thousands of NHG entries (common with large BGP tables) this creates a single allocation many times larger than the non-brief streaming path produces. Consider adding a flush threshold for brief mode too, or documenting the trade-off.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: tests/topotests/all_protocol_startup/test_all_protocol_startup.py
Line: 1747-1799

Comment:
**Per-entry field validation missing for commands 3–5**

Commands 3 (`singleton ip`), 4 (`singleton ipv6`), and 5 (`zebra`) only validate that the top-level output is a dict. They do not iterate entries and verify that `type`, `refCount`, and `timeToDeletion` are absent — the same check that command 1 performs via `_check_brief_nhg_entry`. If a regression reintroduced those fields for any of those filter paths the tests would pass silently.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: lib/nexthop.c
Line: 1289-1293

Comment:
**Non-brief nexthop JSON field ordering change**

The `vrf` field is now emitted earlier — before `resolver`, `active`, `onLink`, `linkDown`, and the type-specific extensions — rather than after them as before. JSON semantics are unaffected, but any downstream tooling that relies on `jq` slurp order or exact serialisation snapshots in non-brief mode will see a change. Mention this in the commit message so it's searchable.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "doc: document show nexthop-group rib bri..." | Re-trigger Greptile

Comment on lines +1747 to 1799
assert (
False
), f"show nexthop-group rib {nhg_id_used} json brief: invalid JSON: {parse_err}"
if data_id is None:
data_id = {}
# Output is {"<id>": { brief NHG object }}
if not isinstance(data_id, dict) or len(data_id) != 1:
assert (
False
), f"show nexthop-group rib {nhg_id_used} json brief: expected single key"
nhg_obj = next(iter(data_id.values()))
err = _check_brief_nhg_entry(nhg_obj)
assert err is None, f"show nexthop-group rib {nhg_id_used} json brief: {err}"
print(f"r1 show nexthop-group rib {nhg_id_used} json brief ok")

# 3) show nexthop-group rib singleton ip json brief
out = r1.vtysh_cmd("show nexthop-group rib singleton ip json brief").strip()
data3, parse_err = _extract_json(out)
if parse_err:
assert (
False
), f"show nexthop-group rib singleton ip json brief: invalid JSON: {parse_err}"
assert isinstance(
data3, dict
), "show nexthop-group rib singleton ip json brief: top-level is not a dict"
print("r1 show nexthop-group rib singleton ip json brief ok")

# 4) show nexthop-group rib singleton ipv6 json brief
out = r1.vtysh_cmd("show nexthop-group rib singleton ipv6 json brief").strip()
data4, parse_err = _extract_json(out)
if parse_err:
assert (
False
), f"show nexthop-group rib singleton ipv6 json brief: invalid JSON: {parse_err}"
assert isinstance(
data4, dict
), "show nexthop-group rib singleton ipv6 json brief: top-level is not a dict"
print("r1 show nexthop-group rib singleton ipv6 json brief ok")

# 5) show nexthop-group rib zebra json brief
out = r1.vtysh_cmd("show nexthop-group rib zebra json brief").strip()
data5, parse_err = _extract_json(out)
if parse_err:
assert (
False
), f"show nexthop-group rib zebra json brief: invalid JSON: {parse_err}"
assert isinstance(
data5, dict
), "show nexthop-group rib zebra json brief: top-level is not a dict"
print("r1 show nexthop-group rib zebra json brief ok")


def test_mpls_interfaces():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Per-entry field validation missing for commands 3–5

Commands 3 (singleton ip), 4 (singleton ipv6), and 5 (zebra) only validate that the top-level output is a dict. They do not iterate entries and verify that type, refCount, and timeToDeletion are absent — the same check that command 1 performs via _check_brief_nhg_entry. If a regression reintroduced those fields for any of those filter paths the tests would pass silently.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/topotests/all_protocol_startup/test_all_protocol_startup.py
Line: 1747-1799

Comment:
**Per-entry field validation missing for commands 3–5**

Commands 3 (`singleton ip`), 4 (`singleton ipv6`), and 5 (`zebra`) only validate that the top-level output is a dict. They do not iterate entries and verify that `type`, `refCount`, and `timeToDeletion` are absent — the same check that command 1 performs via `_check_brief_nhg_entry`. If a regression reintroduced those fields for any of those filter paths the tests would pass silently.

How can I resolve this? If you propose a fix, please make it concise.

Comment thread lib/nexthop.c
Comment on lines +1289 to +1293
if (display_vrfid)
json_object_string_add(json_nexthop, "vrf", vrf_id_to_name(nexthop->vrf_id));

if (brief)
return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Non-brief nexthop JSON field ordering change

The vrf field is now emitted earlier — before resolver, active, onLink, linkDown, and the type-specific extensions — rather than after them as before. JSON semantics are unaffected, but any downstream tooling that relies on jq slurp order or exact serialisation snapshots in non-brief mode will see a change. Mention this in the commit message so it's searchable.

Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/nexthop.c
Line: 1289-1293

Comment:
**Non-brief nexthop JSON field ordering change**

The `vrf` field is now emitted earlier — before `resolver`, `active`, `onLink`, `linkDown`, and the type-specific extensions — rather than after them as before. JSON semantics are unaffected, but any downstream tooling that relies on `jq` slurp order or exact serialisation snapshots in non-brief mode will see a change. Mention this in the commit message so it's searchable.

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants