bgpd: support brief json for bgp l2vpn-evpn neighbors route#21788
bgpd: support brief json for bgp l2vpn-evpn neighbors route#21788hnattamaisub wants to merge 3 commits into
Conversation
Greptile SummaryThis PR adds Confidence Score: 5/5Safe 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
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"]
Reviews (3): Last reviewed commit: "tests: Enhanced tests to validate new co..." | Re-trigger Greptile |
76e4bec to
52da918
Compare
e39d871 to
44b512c
Compare
|
@greptileai review |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
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>
064ccbd to
379ee3b
Compare
|
@ton31337 All the comments are addressed, please help in re-review and merging this , thanks |
|
@ton31337 Can we merge this , if everything looks good? Thanks |
ton31337
left a comment
There was a problem hiding this comment.
Fine, but let's wait for the freeze to end.
sure thanks |
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#