zebra: support brief json for show ip route command - #20950
Conversation
d537804 to
29f04da
Compare
Greptile SummaryThis PR adds a Key changes:
Previously flagged issues (early return bypassing Confidence Score: 5/5Safe to merge β all previously flagged critical issues are resolved and no new bugs found. All P0/P1 issues raised in prior review rounds (early JSON return bypassing array_add, brief hardcoded false in vrf-all paths, duplicate nexthopGroupId) are fixed in the current commit. The brief flag propagates correctly through the No files require special attention.
|
| Filename | Overview |
|---|---|
| zebra/zebra_vty.c | Core implementation of brief JSON output; brief flag correctly propagated via route_show_ctx.brief through all VRF/table iterations; JSON block properly restructured with shared brief/full fields followed by if (!brief) guarded detail section. |
| tests/topotests/static_route_blackhole/test_static_route_blackhole.py | Two new tests cover brief JSON output and VRF consistency; test routes (blackhole, reject, Null0) will have selected/destSelected/installed flags set so conditional-field assertions are valid for this config. |
| doc/user/zebra.rst | Documents new brief option, brief JSON field list, and VRF-all structure; accurately describes behavior including VRF-all nesting. |
| tests/topotests/static_route_blackhole/r1/frr.conf | No changes to route config; existing blackhole/reject/Null0 routes plus interface-derived connected/local routes supply all prefixes tested by the new brief JSON tests. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["show ip route [vrf NAME|all] [brief] json"] --> B["DEFPY show_route handler\nctx.brief = !!brief"]
B --> C{vrf_all?}
C -- yes --> D["RB_FOREACH vrfs\nvty_json_key(vrf_name)"]
D --> E["do_show_ip_route(ctx)"]
C -- no --> E
E --> F["do_show_route_helper(ctx)"]
F --> G["vty_show_ip_route(ctx->brief)"]
G --> H{json?}
H -- no --> I["Text output\n(brief ignored)"]
H -- yes --> J["Emit shared brief fields\nprotocol, selected, distance,\nmetric, installed, nexthopGroupId,\nvrfId, vrfName, uptime"]
J --> K{brief?}
K -- yes --> L["json_object_array_add\nReturn brief JSON"]
K -- no --> M["Emit full fields\nprefix, prefixLen, instance,\ntag, nexthops, backupNexthops,\nNHG detail/summary"]
M --> L
Reviews (4): Last reviewed commit: "doc: add documentation for 'show ip/ipv6..." | Re-trigger Greptile
6b034c8 to
9e758c9
Compare
|
@greptileio rereview |
|
@greptileai review this draft |
|
ci:rerun |
111c11d to
970eb41
Compare
|
ci:rerun |
970eb41 to
a0202ef
Compare
|
this is zebra, not bgpd, right? |
a0202ef to
a95ab54
Compare
yes, changed now, thanks |
Implementation of show ip route brief command Signed-off-by: harini <hnattamaisub@nvidia.com>
Signed-off-by: harini <hnattamaisub@nvidia.com>
Signed-off-by: harini <hnattamaisub@nvidia.com>
a95ab54 to
c302910
Compare
|
ci:rerun |
1 similar comment
|
ci:rerun |
|
@riw777 can we please merge this , if there is no concern? |
|
@greptileai review |
|
let's get another pass |
|
looks good, waiting for @mjstapp to clear his comments |
Added brief option for 'show ip route' command.
The new cli will look like below:
r1# show ip route brief json
{"10.0.0.1/32":[{"protocol":"static","selected":true,"destSelected":true,"distance":1,"metric":0,"installed":true,"nexthopGroupId":6,"vrfId":0,"vrfName":"default","uptime":"00:00:17"}]
,"10.0.0.2/32":[{"protocol":"static","selected":true,"destSelected":true,"distance":1,"metric":0,"installed":true,"nexthopGroupId":5,"vrfId":0,"vrfName":"default","uptime":"00:00:17"}]
,"10.0.0.3/32":[{"protocol":"static","selected":true,"destSelected":true,"distance":1,"metric":0,"installed":true,"nexthopGroupId":6,"vrfId":0,"vrfName":"default","uptime":"00:00:17"}]
,"192.168.1.0/24":[{"protocol":"connected","selected":true,"destSelected":true,"distance":0,"metric":0,"installed":true,"nexthopGroupId":4,"vrfId":0,"vrfName":"default","uptime":"00:00:17"}]
,"192.168.1.1/32":[{"protocol":"local","selected":true,"destSelected":true,"distance":0,"metric":0,"installed":true,"nexthopGroupId":4,"vrfId":0,"vrfName":"default","uptime":"00:00:17"}]
}
r1# show ipv6 route brief json
{"fe80::/64":[{"protocol":"connected","selected":true,"destSelected":true,"distance":0,"metric":0,"installed":true,"nexthopGroupId":8,"vrfId":0,"vrfName":"default","uptime":"00:05:47"}]
}
r1#