Skip to content

bgpd: support brief json for bgp l2vpn-evpn neighbors route#21788

Open
hnattamaisub wants to merge 3 commits into
FRRouting:masterfrom
hnattamaisub:bgp
Open

bgpd: support brief json for bgp l2vpn-evpn neighbors route#21788
hnattamaisub wants to merge 3 commits into
FRRouting:masterfrom
hnattamaisub:bgp

Conversation

@hnattamaisub
Copy link
Copy Markdown
Contributor

@hnattamaisub hnattamaisub commented Apr 28, 2026

brief-json support is added for show bgp l2vpn-evpn neighbour routes

Commands supported:
show bgp l2vpn evpn neighbors routes brief json

Logs:
PE1# show bgp l2vpn evpn neighbors 10.30.30.30 routes
BGP table version is 6, local router ID is 10.10.10.10
Status codes: s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete
EVPN type-1 prefix: [1]:[EthTag]:[ESI]:[IPlen]:[VTEP-IP]:[Frag-id]
EVPN type-2 prefix: [2]:[EthTag]:[MAClen]:[MAC]:[IPlen]:[IP]
EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:[OrigIP]
EVPN type-4 prefix: [4]:[ESI]:[IPlen]:[OrigIP]
EVPN type-5 prefix: [5]:[EthTag]:[IPlen]:[IP]

Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 10.30.30.30:2
*>i [2]:[0]:[48]:[2a:9e:6e:39:dd:c8]:[32]:[10.10.1.3]
10.30.30.30 100 0 i
RT:65000:101 ET:8
*>i [2]:[0]:[48]:[2a:9e:6e:39:dd:c8]:[128]:[fe80::24bb:c3ff:fe91:e6f7]
10.30.30.30 100 0 i
RT:65000:101 ET:8
*>i [2]:[0]:[48]:[6e:35:13:59:1d:da]
10.30.30.30 100 0 i
RT:65000:101 ET:8
*>i [2]:[0]:[48]:[7e:46:d3:44:06:b7]
10.30.30.30 100 0 i
RT:65000:101 ET:8
*>i [2]:[0]:[48]:[ae:c3:1e:3a:fc:31]
10.30.30.30 100 0 i
RT:65000:101 ET:8
*>i [3]:[0]:[32]:[10.30.30.30]
10.30.30.30 100 0 i
RT:65000:101 ET:8

Displayed 6 out of 12 total prefixes
PE1# show bgp l2vpn evpn neighbors 10.30.30.30 routes json brief
{"10.30.30.30:2":{"rd":"10.30.30.30:2","[2]:[0]:[48]:[2a:9e:6e:39:dd:c8]:[32]:[10.10.1.3]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[2a:9e:6e:39:dd:c8]:[128]:[fe80::24bb:c3ff:fe91:e6f7]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[6e:35:13:59:1d:da]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[7e:46:d3:44:06:b7]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[ae:c3:1e:3a:fc:31]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"[3]:[0]:[32]:[10.30.30.30]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"numPrefixes":6}}
PE1# show bgp l2vpn evpn neighbors 10.30.30.30 routes json
{
"bgpTableVersion":6,
"bgpLocalRouterId":"10.10.10.10",
"defaultLocPrf":100,
"localAS":65000,
"10.30.30.30:2":{
"rd":"10.30.30.30:2",
"[2]:[0]:[48]:[2a:9e:6e:39:dd:c8]:[32]:[10.10.1.3]":{
"prefix":"[2]:[0]:[48]:[2a:9e:6e:39:dd:c8]:[32]:[10.10.1.3]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"routeType":2,
"ethTag":0,
"macLen":48,
"mac":"2a:9e:6e:39:dd:c8",
"ipLen":32,
"ip":"10.10.1.3",
"locPrf":100,
"weight":0,
"peerId":"10.30.30.30",
"path":"",
"origin":"IGP",
"extendedCommunity":{
"string":"RT:65000:101 ET:8"
},
"nexthops":[
{
"ip":"10.30.30.30",
"hostname":"PE2",
"afi":"ipv4",
"used":true
}
]
}
],
"pathCount":1,
"multiPathCount":1,
"flags":{
"bestPathExists":true
}
},
"[2]:[0]:[48]:[2a:9e:6e:39:dd:c8]:[128]:[fe80::24bb:c3ff:fe91:e6f7]":{
"prefix":"[2]:[0]:[48]:[2a:9e:6e:39:dd:c8]:[128]:[fe80::24bb:c3ff:fe91:e6f7]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"routeType":2,
"ethTag":0,
"macLen":48,
"mac":"2a:9e:6e:39:dd:c8",
"ipLen":128,
"ip":"fe80::24bb:c3ff:fe91:e6f7",
"locPrf":100,
"weight":0,
"peerId":"10.30.30.30",
"path":"",
"origin":"IGP",
"extendedCommunity":{
"string":"RT:65000:101 ET:8"
},
"nexthops":[
{
"ip":"10.30.30.30",
"hostname":"PE2",
"afi":"ipv4",
"used":true
}
]
}
],
"pathCount":1,
"multiPathCount":1,
"flags":{
"bestPathExists":true
}
},
"[2]:[0]:[48]:[6e:35:13:59:1d:da]":{
"prefix":"[2]:[0]:[48]:[6e:35:13:59:1d:da]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"routeType":2,
"ethTag":0,
"macLen":48,
"mac":"6e:35:13:59:1d:da",
"locPrf":100,
"weight":0,
"peerId":"10.30.30.30",
"path":"",
"origin":"IGP",
"extendedCommunity":{
"string":"RT:65000:101 ET:8"
},
"nexthops":[
{
"ip":"10.30.30.30",
"hostname":"PE2",
"afi":"ipv4",
"used":true
}
]
}
],
"pathCount":1,
"multiPathCount":1,
"flags":{
"bestPathExists":true
}
},
"[2]:[0]:[48]:[7e:46:d3:44:06:b7]":{
"prefix":"[2]:[0]:[48]:[7e:46:d3:44:06:b7]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"routeType":2,
"ethTag":0,
"macLen":48,
"mac":"7e:46:d3:44:06:b7",
"locPrf":100,
"weight":0,
"peerId":"10.30.30.30",
"path":"",
"origin":"IGP",
"extendedCommunity":{
"string":"RT:65000:101 ET:8"
},
"nexthops":[
{
"ip":"10.30.30.30",
"hostname":"PE2",
"afi":"ipv4",
"used":true
}
]
}
],
"pathCount":1,
"multiPathCount":1,
"flags":{
"bestPathExists":true
}
},
"[2]:[0]:[48]:[ae:c3:1e:3a:fc:31]":{
"prefix":"[2]:[0]:[48]:[ae:c3:1e:3a:fc:31]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"routeType":2,
"ethTag":0,
"macLen":48,
"mac":"ae:c3:1e:3a:fc:31",
"locPrf":100,
"weight":0,
"peerId":"10.30.30.30",
"path":"",
"origin":"IGP",
"extendedCommunity":{
"string":"RT:65000:101 ET:8"
},
"nexthops":[
{
"ip":"10.30.30.30",
"hostname":"PE2",
"afi":"ipv4",
"used":true
}
]
}
],
"pathCount":1,
"multiPathCount":1,
"flags":{
"bestPathExists":true
}
},
"[3]:[0]:[32]:[10.30.30.30]":{
"prefix":"[3]:[0]:[32]:[10.30.30.30]",
"prefixLen":352,
"paths":[
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"internal",
"routeType":3,
"ethTag":0,
"ipLen":32,
"ip":"10.30.30.30",
"locPrf":100,
"weight":0,
"peerId":"10.30.30.30",
"path":"",
"origin":"IGP",
"extendedCommunity":{
"string":"RT:65000:101 ET:8"
},
"nexthops":[
{
"ip":"10.30.30.30",
"hostname":"PE2",
"afi":"ipv4",
"used":true
}
]
}
],
"pathCount":1,
"multiPathCount":1,
"flags":{
"bestPathExists":true
}
},
"numPrefixes":6
},
"numPrefix":6,
"totalPrefix":12
}
PE1#

@frrbot frrbot Bot added bgp documentation tests Topotests, make check, etc labels Apr 28, 2026
@hnattamaisub hnattamaisub marked this pull request as draft April 28, 2026 04:53
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR adds brief JSON support to show bgp l2vpn evpn neighbors <peer> routes, producing compact JSON with per-prefix pathCount, multiPathCount, and flags.bestPathExists instead of full path arrays. The old DEFUN handler is replaced by a DEFPY that parses the optional json [brief] modifier, and bgp_show_ethernet_vpn gains a brief parameter respected by all callers. All issues identified in previous review rounds (memory leaks, pathCount overcounting, numPrefixes counter, community-filter bypass, and output-format regression) have been addressed in this revision.

Confidence Score: 5/5

Safe to merge — all previously identified P1 issues have been resolved and no new defects are present.

All memory leaks, counter-overcounting, filter-bypass, and output-format issues flagged in prior review rounds are addressed. The new code correctly gates JSON header fields and path-array population behind the brief flag, places all counter increments after filter continues, writes numPrefixes once outside the inner loop, and uses vty_json_no_pretty only on the brief path. No new P0 or P1 issues were found.

No files require special attention.

Important Files Changed

Filename Overview
bgpd/bgp_evpn_vty.c Adds bool brief to bgp_show_ethernet_vpn and replaces the old DEFUN with a DEFPY; all counter, memory, and filter issues from prior review rounds are resolved.
tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py New test test_bgp_evpn_neighbor_routes_json_brief covers full-JSON and brief-JSON assertions with a capability probe guard; state dependency on earlier tests is acceptable per project convention.
doc/user/bgp.rst Adds CLI documentation for both neighbors … routes [json [brief]] and the RD-scoped variant; accurate and consistent with the implemented behaviour.
doc/user/evpn.rst Adds a brief forward-reference to the BGP chapter for EVPN neighbor route commands; no issues.
doc/user/basic.rst Updates the find output example to reflect the new [json [brief]] grammar; no issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["DEFPY: routes [json [brief]]"] --> B{peer valid?}
    B -- No --> C[return CMD_WARNING]
    B -- Yes --> D{afc L2VPN EVPN set?}
    D -- No --> E[warn + return CMD_WARNING]
    D -- Yes --> F["bgp_show_ethernet_vpn\nuse_json=uj, brief=brief"]
    F --> G{use_json?}
    G -- Yes --> H[allocate top-level json object]
    G -- No --> H2[text mode]
    H --> I[for each RD dest]
    I --> J[for each prefix rm]
    J --> K[for each path pi]
    K --> L{pass neighbor and community filters?}
    L -- No --> K
    L -- Yes --> M{rd_header==1?}
    M -- Yes --> N["alloc json_nroute, populate rd_str"]
    M -- No --> O
    N --> O{brief?}
    O -- No --> P["alloc json_array\nroute_vty_out"]
    O -- Yes --> Q[skip display output]
    P --> R
    Q --> R["prefix_path_count++\nadd_rd_to_json=1\ntrack multipath/best flags"]
    R --> K
    J --> S{no_display==1?}
    S -- Yes --> T["build json_prefix_info\npathCount, multiPathCount, flags\nadd to json_nroute"]
    S -- No --> J
    I --> U["add numPrefixes to json_nroute\nif add_rd_to_json: attach to json"]
    F --> V{brief?}
    V -- No --> W["add numPrefix + totalPrefix\nvty_json pretty-printed"]
    V -- Yes --> X["vty_json_no_pretty compact"]
Loading

Reviews (3): Last reviewed commit: "tests: Enhanced tests to validate new co..." | Re-trigger Greptile

Comment thread bgpd/bgp_evpn_vty.c Outdated
Comment thread bgpd/bgp_evpn_vty.c Outdated
Comment thread bgpd/bgp_evpn_vty.c Outdated
Comment thread bgpd/bgp_evpn_vty.c Outdated
Comment thread bgpd/bgp_evpn_vty.c Outdated
@hnattamaisub hnattamaisub force-pushed the bgp branch 3 times, most recently from 76e4bec to 52da918 Compare April 30, 2026 09:30
@hnattamaisub hnattamaisub marked this pull request as ready for review April 30, 2026 09:46
Comment thread bgpd/bgp_evpn_vty.c Outdated
Comment thread bgpd/bgp_evpn_vty.c Outdated
@hnattamaisub hnattamaisub force-pushed the bgp branch 2 times, most recently from e39d871 to 44b512c Compare April 30, 2026 10:10
@ton31337
Copy link
Copy Markdown
Member

@greptileai review

Comment thread bgpd/bgp_evpn_vty.c Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Comment thread bgpd/bgp_evpn_vty.c Outdated
Comment thread bgpd/bgp_evpn_vty.c
@hnattamaisub
Copy link
Copy Markdown
Contributor Author

ci:rerun

brief-json support is added for show bgp l2vpn-evpn neighbour routes
Commands supported:
show bgp l2vpn evpn neighbors <neigh> routes brief json

Signed-off-by: harini <hnattamaisub@nvidia.com>
Signed-off-by: harini <hnattamaisub@nvidia.com>
show bgp l2vpn evpn neighbors 10.30.30.30 routes json brief

Signed-off-by: harini <hnattamaisub@nvidia.com>
@hnattamaisub hnattamaisub force-pushed the bgp branch 2 times, most recently from 064ccbd to 379ee3b Compare May 12, 2026 04:04
@hnattamaisub
Copy link
Copy Markdown
Contributor Author

@ton31337 All the comments are addressed, please help in re-review and merging this , thanks

@hnattamaisub
Copy link
Copy Markdown
Contributor Author

@ton31337 Can we merge this , if everything looks good? Thanks

Copy link
Copy Markdown
Member

@ton31337 ton31337 left a comment

Choose a reason for hiding this comment

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

Fine, but let's wait for the freeze to end.

@hnattamaisub
Copy link
Copy Markdown
Contributor Author

Fine, but let's wait for the freeze to end.

sure thanks

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

Labels

bgp documentation master rebase PR needs rebase size/XL tests Topotests, make check, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants