Skip to content

bgpd: add additional attributes for evpn detail/ipv4/ipv6 detail json#21035

Merged
riw777 merged 2 commits intoFRRouting:masterfrom
hnattamaisub:flags_add
Mar 31, 2026
Merged

bgpd: add additional attributes for evpn detail/ipv4/ipv6 detail json#21035
riw777 merged 2 commits intoFRRouting:masterfrom
hnattamaisub:flags_add

Conversation

@hnattamaisub
Copy link
Copy Markdown
Contributor

@hnattamaisub hnattamaisub commented Mar 6, 2026

Added no of rotues, pathcount, multipathcount and flags fileds into show bgp ipv4/ipv6 detail json output and show bgp l2vpn evpn route detail json output.

Commands:
1)show bgp vrf blue ipv4 unicast json detail
2)show bgp vrf blue ipv6 unicast json detail
3)show bgp l2vpn evpn route detail json
r1# show bgp vrf blue ipv4 unicast json detail
{
"vrfId": 6,
"vrfName": "blue",
"tableVersion": 1,
"routerId": "192.168.13.1",
"defaultLocPrf": 100,
"localAS": 65000,
"routes": { "10.10.10.10/32": {
"prefix": "10.10.10.10/32",
"version": 1,
"pathCount": 1,"paths": [{"aspath":{"string":"Local","segments":[],"length":0},"origin":"IGP","metric":0,"locPrf":100,"valid":true,"version":1,"bestpath":{"overall":true,"selectionReason":"First path received"},"extendedCommunity":{"string":"LB:65000:5000000 (40.000 Mbps)"},"lastUpdate":{"epoch":1774346830,"string":"Tue Mar 24 10:07:10 2026"},"lastUpdateStr":"0:00:00:08","nexthops":[{"ip":"192.168.13.3","hostname":"r3","afi":"ipv4","metric":0,"accessible":true,"used":true}],"peer":{"peerId":"192.168.13.3","routerId":"192.168.13.3","hostname":"r3","type":"internal"}}]
,"multiPathCount":1
,"flags": {"bestPathExists":true}
} } , "totalRoutes": 1, "totalPaths": 1,"numRoutes":1
}
r1# show bgp vrf blue ipv4 unicast json
{
"vrfId": 6,
"vrfName": "blue",
"tableVersion": 1,
"routerId": "192.168.13.1",
"defaultLocPrf": 100,
"localAS": 65000,
"routes": { "10.10.10.10/32": [{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"internal","prefix":"10.10.10.10","prefixLen":32,"network":"10.10.10.10/32","version":1,"metric":0,"locPrf":100,"weight":0,"peerId":"192.168.13.3","path":"","origin":"IGP","nexthops":[{"ip":"192.168.13.3","hostname":"r3","afi":"ipv4","used":true}]}]
} , "totalRoutes": 1, "totalPaths": 1,"numRoutes":1
}
r1# show bgp vrf blue ipv4 unicast json brief
{
"routes": { "10.10.10.10/32": {
"pathCount":1
,"multiPathCount":1
,"flags": {"bestPathExists":true}
} } , "totalRoutes": 1, "totalPaths": 1,"numRoutes":1
}
r1#
host1# show bgp vrf default ipv6 unicast json
{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 1,
"routerId": "10.100.0.11",
"defaultLocPrf": 100,
"localAS": 111,
"routes": { "100::21/128": [{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"external","prefix":"100::21","prefixLen":128,"network":"100::21/128","version":1,"metric":0,"weight":32768,"peerId":"(unspec)","path":"","origin":"IGP","nexthops":[{"ip":"::","hostname":"host1","afi":"ipv6","scope":"global","linkLocalOnly":false,"length":16,"used":true}]}]
} , "totalRoutes": 1, "totalPaths": 1,"numRoutes":1
}
host1# show bgp vrf default ipv6 unicast json detail
{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 1,
"routerId": "10.100.0.11",
"defaultLocPrf": 100,
"localAS": 111,
"routes": { "100::21/128": {
"prefix": "100::21/128",
"version": 1,"advertisedTo": {
"50:0:1::1":{
"hostname":"PE1"
}
}
,"pathCount": 1,"paths": [{"aspath":{"string":"Local","segments":[],"length":0},"origin":"IGP","metric":0,"weight":32768,"valid":true,"version":1,"sourced":true,"local":true,"bestpath":{"overall":true,"selectionReason":"First path received"},"lastUpdate":{"epoch":1774346897,"string":"Tue Mar 24 10:08:17 2026"},"lastUpdateStr":"0:00:00:46","bgpId":"10.100.0.11","nexthops":[{"ip":"::","hostname":"host1","afi":"ipv6","scope":"global","linkLocalOnly":false,"length":16,"metric":0,"accessible":true,"used":true}],"peer":{"peerId":"::","routerId":"10.100.0.11"}}]
,"multiPathCount":1
,"flags": {"bestPathExists":true}
} } , "totalRoutes": 1, "totalPaths": 1,"numRoutes":1
}
host1# show bgp vrf default ipv6 unicast json brief
{
"routes": { "100::21/128": {
"pathCount":1
,"multiPathCount":1
,"flags": {"bestPathExists":true}
} } , "totalRoutes": 1, "totalPaths": 1,"numRoutes":1
}
host1#
r1# show bgp l2vpn evpn route detail json brief
{
"0.0.0.0:2":{},"10.0.0.10:1":{"[5]:[0]:[24]:[10.0.0.0]":{"pathCount":2,"multiPathCount":2,"flags":{"bestPathExists":true}},"numRoutes":1}
,"10.0.0.11:3":{"[3]:[0]:[32]:[10.0.0.11]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"numRoutes":1}
,"10.0.0.12:2":{"[2]:[0]:[48]:[00:00:00:00:00:c1]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[00:00:00:00:00:c1]:[32]:[10.0.0.0]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[00:00:00:00:00:c2]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[00:00:00:00:00:c2]:[32]:[10.0.0.2]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"[3]:[0]:[32]:[10.0.0.12]":{"pathCount":1,"multiPathCount":1,"flags":{"bestPathExists":true}},"numRoutes":5}
}
r1# show bgp l2vpn evpn route json
{
"0.0.0.0:2":{},"10.0.0.10:1":{"rd":"10.0.0.10:1","[5]:[0]:[24]:[10.0.0.0]":{"prefix":"[5]:[0]:[24]:[10.0.0.0]","prefixLen":352,"pathCount":2,"multiPathCount":2,"paths":[[{"valid":true,"bestpath":true,"selectionReason":"Locally configured route","multipath":true,"pathFrom":"external","routeType":5,"ethTag":0,"ipLen":24,"ip":"10.0.0.0","metric":0,"weight":0,"peerId":"(unspec)","path":"64000","origin":"IGP","extendedCommunity":{"string":"ET:8 RT:64001:100 Rmac:a2:48:26:4b:a6:6a"},"nexthops":[{"ip":"10.0.0.10","hostname":"r1","afi":"ipv4","used":true}]}],[{"valid":true,"multipath":true,"pathFrom":"external","routeType":5,"ethTag":0,"ipLen":24,"ip":"10.0.0.0","metric":0,"weight":0,"peerId":"(unspec)","path":"64000","origin":"IGP","extendedCommunity":{"string":"ET:8 RT:64001:100 Rmac:a2:48:26:4b:a6:6a"},"nexthops":[{"ip":"10.0.0.10","hostname":"r1","afi":"ipv4","used":true}]}]],"flags":{"bestPathExists":true}},"numRoutes":1}
,"10.0.0.11:3":{"rd":"10.0.0.11:3","[3]:[0]:[32]:[10.0.0.11]":{"prefix":"[3]:[0]:[32]:[10.0.0.11]","prefixLen":352,"pathCount":1,"multiPathCount":1,"paths":[[{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"internal","routeType":3,"ethTag":0,"ipLen":32,"ip":"10.0.0.11","locPrf":100,"weight":0,"peerId":"10.0.0.9","path":"","origin":"IGP","extendedCommunity":{"string":"RT:64001:10 ET:8"},"nexthops":[{"ip":"10.0.0.11","hostname":"rr","afi":"ipv4","used":true}]}]],"flags":{"bestPathExists":true}},"numRoutes":1}
,"10.0.0.12:2":{"rd":"10.0.0.12:2","[2]:[0]:[48]:[00:00:00:00:00:c1]":{"prefix":"[2]:[0]:[48]:[00:00:00:00:00:c1]","prefixLen":352,"pathCount":1,"multiPathCount":1,"paths":[[{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"internal","routeType":2,"ethTag":0,"macLen":48,"mac":"00:00:00:00:00:c1","locPrf":100,"weight":0,"peerId":"10.0.0.9","path":"","origin":"IGP","extendedCommunity":{"string":"RT:64001:10 ET:8"},"nexthops":[{"ip":"10.0.0.12","hostname":"rr","afi":"ipv4","used":true}]}]],"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[00:00:00:00:00:c1]:[32]:[10.0.0.0]":{"prefix":"[2]:[0]:[48]:[00:00:00:00:00:c1]:[32]:[10.0.0.0]","prefixLen":352,"pathCount":1,"multiPathCount":1,"paths":[[{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"internal","routeType":2,"ethTag":0,"macLen":48,"mac":"00:00:00:00:00:c1","ipLen":32,"ip":"10.0.0.0","locPrf":100,"weight":0,"peerId":"10.0.0.9","path":"","origin":"IGP","extendedCommunity":{"string":"RT:64001:10 ET:8"},"nexthops":[{"ip":"10.0.0.12","hostname":"rr","afi":"ipv4","used":true}]}]],"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[00:00:00:00:00:c2]":{"prefix":"[2]:[0]:[48]:[00:00:00:00:00:c2]","prefixLen":352,"pathCount":1,"multiPathCount":1,"paths":[[{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"internal","routeType":2,"ethTag":0,"macLen":48,"mac":"00:00:00:00:00:c2","locPrf":100,"weight":0,"peerId":"10.0.0.9","path":"","origin":"IGP","extendedCommunity":{"string":"RT:64001:10 ET:8"},"nexthops":[{"ip":"10.0.0.12","hostname":"rr","afi":"ipv4","used":true}]}]],"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[00:00:00:00:00:c2]:[32]:[10.0.0.2]":{"prefix":"[2]:[0]:[48]:[00:00:00:00:00:c2]:[32]:[10.0.0.2]","prefixLen":352,"pathCount":1,"multiPathCount":1,"paths":[[{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"internal","routeType":2,"ethTag":0,"macLen":48,"mac":"00:00:00:00:00:c2","ipLen":32,"ip":"10.0.0.2","locPrf":100,"weight":0,"peerId":"10.0.0.9","path":"","origin":"IGP","extendedCommunity":{"string":"RT:64001:10 ET:8"},"nexthops":[{"ip":"10.0.0.12","hostname":"rr","afi":"ipv4","used":true}]}]],"flags":{"bestPathExists":true}},"[3]:[0]:[32]:[10.0.0.12]":{"prefix":"[3]:[0]:[32]:[10.0.0.12]","prefixLen":352,"pathCount":1,"multiPathCount":1,"paths":[[{"valid":true,"bestpath":true,"selectionReason":"First path received","pathFrom":"internal","routeType":3,"ethTag":0,"ipLen":32,"ip":"10.0.0.12","locPrf":100,"weight":0,"peerId":"10.0.0.9","path":"","origin":"IGP","extendedCommunity":{"string":"RT:64001:10 ET:8"},"nexthops":[{"ip":"10.0.0.12","hostname":"rr","afi":"ipv4","used":true}]}]],"flags":{"bestPathExists":true}},"numRoutes":5}
,"numPrefix":7,"numPaths":8}
r1#
r1# show bgp l2vpn evpn route detail json
{
"0.0.0.0:2":{},"10.0.0.10:1":{"rd":"10.0.0.10:1","[5]:[0]:[24]:[10.0.0.0]":{"prefix":"[5]:[0]:[24]:[10.0.0.0]","prefixLen":352,"rd":"10.0.0.10:1","routeType":5,"ethTag":0,"ipLen":24,"ip":"10.0.0.0","pathCount":2,"multiPathCount":2,"paths":[[{"vni":"100","gatewayIP":"10.0.0.0","aspath":{"string":"64000","segments":[{"type":"as-sequence","list":[64000]}],"length":1},"origin":"IGP","metric":0,"valid":true,"version":2,"sourced":true,"local":true,"multipath":true,"bestpath":{"overall":true,"selectionReason":"Locally configured route"},"extendedCommunity":{"string":"ET:8 RT:64001:100 Rmac:a2:48:26:4b:a6:6a"},"addpathRxId":2,"addpathTxId":2,"addpathTxIdAll":2,"addpathTxIdBestPerAS":0,"addpathTxIdBestSelected":0,"advertisedTo":{"10.0.0.9":{"hostname":"rr"}},"lastUpdate":{"epoch":1774347333,"string":"Tue Mar 24 10:15:33 2026"},"lastUpdateStr":"0:00:01:15","nexthops":[{"ip":"10.0.0.10","hostname":"r1","afi":"ipv4","metric":0,"accessible":true,"used":true}],"peer":{"peerId":"0.0.0.0","routerId":"10.0.0.10"}}],[{"vni":"100","gatewayIP":"10.0.0.2","aspath":{"string":"64000","segments":[{"type":"as-sequence","list":[64000]}],"length":1},"origin":"IGP","metric":0,"valid":true,"version":2,"sourced":true,"local":true,"multipath":true,"extendedCommunity":{"string":"ET:8 RT:64001:100 Rmac:a2:48:26:4b:a6:6a"},"addpathRxId":3,"addpathTxId":3,"addpathTxIdAll":3,"addpathTxIdBestPerAS":0,"addpathTxIdBestSelected":0,"advertisedTo":{"10.0.0.9":{"hostname":"rr"}},"lastUpdate":{"epoch":1774347333,"string":"Tue Mar 24 10:15:33 2026"},"lastUpdateStr":"0:00:01:15","nexthops":[{"ip":"10.0.0.10","hostname":"r1","afi":"ipv4","metric":0,"accessible":true,"used":true}],"peer":{"peerId":"0.0.0.0","routerId":"10.0.0.10"}}]],"flags":{"bestPathExists":true}},"numRoutes":1}
,"10.0.0.11:3":{"rd":"10.0.0.11:3","[3]:[0]:[32]:[10.0.0.11]":{"prefix":"[3]:[0]:[32]:[10.0.0.11]","prefixLen":352,"rd":"10.0.0.11:3","routeType":3,"ethTag":0,"ipLen":32,"ip":"10.0.0.11","pathCount":1,"multiPathCount":1,"paths":[[{"aspath":{"string":"Local","segments":[],"length":0},"origin":"IGP","locPrf":100,"valid":true,"version":1,"bestpath":{"overall":true,"selectionReason":"First path received"},"extendedCommunity":{"string":"RT:64001:10 ET:8"},"originatorId":"10.0.0.11","clusterList":{"list":["10.0.0.9"]},"addpathRxId":9,"addpathTxId":4,"addpathTxIdAll":4,"addpathTxIdBestPerAS":0,"addpathTxIdBestSelected":0,"lastUpdate":{"epoch":1774347334,"string":"Tue Mar 24 10:15:34 2026"},"lastUpdateStr":"0:00:01:14","pmsi":{"tunnelType":"Ingress Replication","label":10},"nexthops":[{"ip":"10.0.0.11","hostname":"rr","afi":"ipv4","metric":0,"accessible":true,"used":true}],"peer":{"peerId":"10.0.0.9","routerId":"10.0.0.9","hostname":"rr","type":"internal"}}]],"flags":{"bestPathExists":true}},"numRoutes":1}
,"10.0.0.12:2":{"rd":"10.0.0.12:2","[2]:[0]:[48]:[00:00:00:00:00:c1]":{"prefix":"[2]:[0]:[48]:[00:00:00:00:00:c1]","prefixLen":352,"rd":"10.0.0.12:2","routeType":2,"ethTag":0,"macLen":48,"mac":"00:00:00:00:00:c1","pathCount":1,"multiPathCount":1,"paths":[[{"vni":"10","aspath":{"string":"Local","segments":[],"length":0},"origin":"IGP","locPrf":100,"valid":true,"version":1,"bestpath":{"overall":true,"selectionReason":"First path received"},"extendedCommunity":{"string":"RT:64001:10 ET:8"},"originatorId":"10.0.0.12","clusterList":{"list":["10.0.0.9"]},"addpathRxId":4,"addpathTxId":5,"addpathTxIdAll":5,"addpathTxIdBestPerAS":0,"addpathTxIdBestSelected":0,"lastUpdate":{"epoch":1774347334,"string":"Tue Mar 24 10:15:34 2026"},"lastUpdateStr":"0:00:01:14","nexthops":[{"ip":"10.0.0.12","hostname":"rr","afi":"ipv4","metric":0,"accessible":true,"used":true}],"peer":{"peerId":"10.0.0.9","routerId":"10.0.0.9","hostname":"rr","type":"internal"}}]],"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[00:00:00:00:00:c1]:[32]:[10.0.0.0]":{"prefix":"[2]:[0]:[48]:[00:00:00:00:00:c1]:[32]:[10.0.0.0]","prefixLen":352,"rd":"10.0.0.12:2","routeType":2,"ethTag":0,"macLen":48,"mac":"00:00:00:00:00:c1","ipLen":32,"ip":"10.0.0.0","pathCount":1,"multiPathCount":1,"paths":[[{"vni":"10","aspath":{"string":"Local","segments":[],"length":0},"origin":"IGP","locPrf":100,"valid":true,"version":2,"bestpath":{"overall":true,"selectionReason":"First path received"},"extendedCommunity":{"string":"RT:64001:10 ET:8"},"originatorId":"10.0.0.12","clusterList":{"list":["10.0.0.9"]},"addpathRxId":5,"addpathTxId":6,"addpathTxIdAll":6,"addpathTxIdBestPerAS":0,"addpathTxIdBestSelected":0,"lastUpdate":{"epoch":1774347334,"string":"Tue Mar 24 10:15:34 2026"},"lastUpdateStr":"0:00:01:14","nexthops":[{"ip":"10.0.0.12","hostname":"rr","afi":"ipv4","metric":0,"accessible":true,"used":true}],"peer":{"peerId":"10.0.0.9","routerId":"10.0.0.9","hostname":"rr","type":"internal"}}]],"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[00:00:00:00:00:c2]":{"prefix":"[2]:[0]:[48]:[00:00:00:00:00:c2]","prefixLen":352,"rd":"10.0.0.12:2","routeType":2,"ethTag":0,"macLen":48,"mac":"00:00:00:00:00:c2","pathCount":1,"multiPathCount":1,"paths":[[{"vni":"10","aspath":{"string":"Local","segments":[],"length":0},"origin":"IGP","locPrf":100,"valid":true,"version":3,"bestpath":{"overall":true,"selectionReason":"First path received"},"extendedCommunity":{"string":"RT:64001:10 ET:8"},"originatorId":"10.0.0.12","clusterList":{"list":["10.0.0.9"]},"addpathRxId":6,"addpathTxId":7,"addpathTxIdAll":7,"addpathTxIdBestPerAS":0,"addpathTxIdBestSelected":0,"lastUpdate":{"epoch":1774347334,"string":"Tue Mar 24 10:15:34 2026"},"lastUpdateStr":"0:00:01:14","nexthops":[{"ip":"10.0.0.12","hostname":"rr","afi":"ipv4","metric":0,"accessible":true,"used":true}],"peer":{"peerId":"10.0.0.9","routerId":"10.0.0.9","hostname":"rr","type":"internal"}}]],"flags":{"bestPathExists":true}},"[2]:[0]:[48]:[00:00:00:00:00:c2]:[32]:[10.0.0.2]":{"prefix":"[2]:[0]:[48]:[00:00:00:00:00:c2]:[32]:[10.0.0.2]","prefixLen":352,"rd":"10.0.0.12:2","routeType":2,"ethTag":0,"macLen":48,"mac":"00:00:00:00:00:c2","ipLen":32,"ip":"10.0.0.2","pathCount":1,"multiPathCount":1,"paths":[[{"vni":"10","aspath":{"string":"Local","segments":[],"length":0},"origin":"IGP","locPrf":100,"valid":true,"version":4,"bestpath":{"overall":true,"selectionReason":"First path received"},"extendedCommunity":{"string":"RT:64001:10 ET:8"},"originatorId":"10.0.0.12","clusterList":{"list":["10.0.0.9"]},"addpathRxId":7,"addpathTxId":8,"addpathTxIdAll":8,"addpathTxIdBestPerAS":0,"addpathTxIdBestSelected":0,"lastUpdate":{"epoch":1774347334,"string":"Tue Mar 24 10:15:34 2026"},"lastUpdateStr":"0:00:01:14","nexthops":[{"ip":"10.0.0.12","hostname":"rr","afi":"ipv4","metric":0,"accessible":true,"used":true}],"peer":{"peerId":"10.0.0.9","routerId":"10.0.0.9","hostname":"rr","type":"internal"}}]],"flags":{"bestPathExists":true}},"[3]:[0]:[32]:[10.0.0.12]":{"prefix":"[3]:[0]:[32]:[10.0.0.12]","prefixLen":352,"rd":"10.0.0.12:2","routeType":3,"ethTag":0,"ipLen":32,"ip":"10.0.0.12","pathCount":1,"multiPathCount":1,"paths":[[{"aspath":{"string":"Local","segments":[],"length":0},"origin":"IGP","locPrf":100,"valid":true,"version":5,"bestpath":{"overall":true,"selectionReason":"First path received"},"extendedCommunity":{"string":"RT:64001:10 ET:8"},"originatorId":"10.0.0.12","clusterList":{"list":["10.0.0.9"]},"addpathRxId":8,"addpathTxId":9,"addpathTxIdAll":9,"addpathTxIdBestPerAS":0,"addpathTxIdBestSelected":0,"lastUpdate":{"epoch":1774347334,"string":"Tue Mar 24 10:15:34 2026"},"lastUpdateStr":"0:00:01:14","pmsi":{"tunnelType":"Ingress Replication","label":10},"nexthops":[{"ip":"10.0.0.12","hostname":"rr","afi":"ipv4","metric":0,"accessible":true,"used":true}],"peer":{"peerId":"10.0.0.9","routerId":"10.0.0.9","hostname":"rr","type":"internal"}}]],"flags":{"bestPathExists":true}},"numRoutes":5}
,"numPrefix":7,"numPaths":8}
r1#

@frrbot frrbot bot added the bgp label Mar 6, 2026
@hnattamaisub hnattamaisub marked this pull request as draft March 6, 2026 15:14
@hnattamaisub hnattamaisub force-pushed the flags_add branch 2 times, most recently from 39aa0df to c6f2ecc Compare March 6, 2026 15:18
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 6, 2026

Greptile Summary

This PR adds pathCount, multiPathCount, flags, and numRoutes fields to the JSON output of show bgp ipv4/ipv6 unicast json detail and show bgp l2vpn evpn route detail json. The changes touch two files: bgp_evpn_vty.c (EVPN-specific display path) and bgp_route.c (the shared BGP table display used by IPv4/IPv6).

Key changes:

  • bgp_evpn_vty.c: tracks prefix_path_count and best_path_selected per-prefix in the EVPN route loop; emits pathCount, multiPathCount, flags.bestPathExists, and numRoutes per RD into the JSON output.
  • bgp_route.c: tracks the same two counters per dest in bgp_show_table; after json_paths is serialised it emits multiPathCount and a flags object (with FIB-status sub-fields when suppress-fib-pending is active); emits numRoutes in the closing-bracket loop.

Issues found:

  • fibInstallFailed in bgp_route.c is derived as !(FIB_INSTALLED || FIB_INSTALL_PENDING), which is true for any newly-received route that has not yet been enqueued for FIB installation — incorrectly labelling it as a failed install rather than an un-attempted one.
  • numRoutes is only inserted at loop iteration i == 1, so it is silently absent whenever BGP_SHOW_OPT_AFI_ALL is set (json_header_depth == 1) — inconsistent between single-AFI and all-AFI JSON output.

Confidence Score: 3/5

  • This PR is mostly safe to merge but contains a logic error that produces misleading JSON output and a coverage gap for the all-AFI case.
  • The EVPN path (bgp_evpn_vty.c) looks correct and the previously-flagged issues were addressed. However, bgp_route.c has two distinct bugs: fibInstallFailed fires on un-attempted installs (incorrect semantic), and numRoutes is never emitted for the show bgp all json detail case. Neither is a crash, but both produce wrong or missing data in the JSON API that consumers may rely on.
  • bgpd/bgp_route.c — specifically the fibInstallFailed flag derivation (lines 13878–13882) and the numRoutes emission guard (line 13919).

Important Files Changed

Filename Overview
bgpd/bgp_route.c Adds multiPathCount, flags (bestPathExists, fibInstalled, fibWaitForInstall, fibInstallFailed, fibSuppress), and numRoutes to the JSON detail output per prefix. Two issues found: fibInstallFailed is derived by inverting the installed/pending flags, incorrectly marking un-attempted installs as failed; and numRoutes is never emitted when BGP_SHOW_OPT_AFI_ALL is set because the i == 1 guard is never reached with json_header_depth == 1.
bgpd/bgp_evpn_vty.c Adds pathCount, multiPathCount, flags (bestPathExists), and per-RD numRoutes to EVPN JSON output (both detail and non-detail). The previously reported issues (duplicate pathCount, numRoutes overwrite in loop) appear addressed. Includes the bgp_mpath.h header needed for bgp_path_info_mpath_count. Logic looks correct for the EVPN path.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["bgp_show_table() per dest"] --> B{use_json && detail_json?}
    B -- No --> Z[non-JSON output]
    B -- Yes --> C[open per-prefix dict\nroute_vty_out_detail_header\n+ pathCount via header]
    C --> D[iterate paths\ntrack prefix_path_count\nbest_path_selected]
    D --> E[vty_json_no_pretty\njson_paths array]
    E --> F{json_detail_header_used?}
    F -- Yes --> G[build json_flags\nbestPathExists]
    G --> H{BGP_FLAG_SUPPRESS_FIB_PENDING?}
    H -- Yes --> I["fibInstalled\nfibWaitForInstall\nfibInstallFailed ⚠️\nfibSuppress=true"]
    H -- No --> J[emit multiPathCount\nfibSuppress fields skipped]
    I --> J
    J --> K[vty_out multiPathCount\nvty_out flags JSON]
    K --> L[close per-prefix dict]
    L --> M{is_last?}
    M -- Yes --> N["close header brackets\n i==1: emit numRoutes ⚠️\n(skipped when depth==1 / all flag)\n emit totalRoutes totalPaths"]
    M -- No --> O[continue to next dest]

    style I fill:#ffcccc,stroke:#cc0000
    style N fill:#ffcccc,stroke:#cc0000
Loading

Last reviewed commit: bf348a5

Comment thread bgpd/bgp_route.c Outdated
Comment thread bgpd/bgp_evpn_vty.c
Comment thread bgpd/bgp_route.c Outdated
@hnattamaisub hnattamaisub force-pushed the flags_add branch 3 times, most recently from b2e8dc0 to bf348a5 Compare March 6, 2026 15:42
@hnattamaisub hnattamaisub marked this pull request as ready for review March 6, 2026 15:50
Comment thread bgpd/bgp_route.c Outdated
Comment thread bgpd/bgp_route.c Outdated
@frrbot frrbot bot added the tests Topotests, make check, etc label Mar 9, 2026
@hnattamaisub hnattamaisub force-pushed the flags_add branch 4 times, most recently from 9571fc5 to 3648318 Compare March 10, 2026 13:38
@github-actions github-actions bot added the rebase PR needs rebase label Mar 10, 2026
@riw777 riw777 self-requested a review March 10, 2026 15:31
@hnattamaisub
Copy link
Copy Markdown
Contributor Author

ci:rerun

@hnattamaisub hnattamaisub force-pushed the flags_add branch 3 times, most recently from 7047a7d to f91882a Compare March 16, 2026 11:53
Comment thread bgpd/bgp_evpn_vty.c Outdated
Comment thread bgpd/bgp_route.c Outdated
Copy link
Copy Markdown
Member

@riw777 riw777 left a comment

Choose a reason for hiding this comment

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

looks good, just waiting on @ton31337 's comments

@hnattamaisub
Copy link
Copy Markdown
Contributor Author

@ton31337 @riw777 can we please merge this? thanks

@hnattamaisub hnattamaisub force-pushed the flags_add branch 2 times, most recently from 8e81d4c to 72730e2 Compare March 24, 2026 10:17
@riw777
Copy link
Copy Markdown
Member

riw777 commented Mar 24, 2026

@ton31337 @riw777 can we please merge this? thanks

as soon as we can make ci happy ... I'll watch it over the next couple of days to see if we can get it in.

@github-actions
Copy link
Copy Markdown

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

Added no of rotues, pathcount, multipathcount and flags fileds
into show bgp ipv4/ipv6 detail json output and show bgp
l2vpn evpn route detail json output.

Commands:
1)show bgp vrf blue  ipv4 unicast json detail
2)show bgp vrf blue  ipv6 unicast json detail
3)show bgp l2vpn evpn route detail json

Signed-off-by: harini <hnattamaisub@nvidia.com>
Enhanced existing tests to match their behaviour

Signed-off-by: harini <hnattamaisub@nvidia.com>
@riw777 riw777 merged commit 680d732 into FRRouting:master Mar 31, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants