Skip to content

bgpd: Support brief option for show bgp neighbors command - #20914

Merged
ton31337 merged 3 commits into
FRRouting:masterfrom
hnattamaisub:bgp_brief_json
Mar 10, 2026
Merged

bgpd: Support brief option for show bgp neighbors command#20914
ton31337 merged 3 commits into
FRRouting:masterfrom
hnattamaisub:bgp_brief_json

Conversation

@hnattamaisub

Copy link
Copy Markdown
Contributor

New brief option for "show bgp neighbor" is added and logs are as below:

r1# show bgp neighbors 192.168.0.2 brief

Neighbor AS MsgRcvd MsgSent ResetTime State Afi/Safi PfxRcd PfxSnt
192.168.0.2 65000 22 22 00:00:57 Established IPv4 Unicast 7 8

r1#
r1# show bgp neighbors brief

Neighbor AS MsgRcvd MsgSent ResetTime State Afi/Safi PfxRcd PfxSnt
192.168.0.2 65000 85 85 00:04:06 Established IPv4 Unicast 7 8
192.168.101.2 65100 99 99 00:04:06 Established IPv4 Unicast 3 9

r1#
r1# show ip bgp neighbors brief

Neighbor AS MsgRcvd MsgSent ResetTime State Afi/Safi PfxRcd PfxSnt
192.168.0.2 65000 98 98 00:04:44 Established IPv4 Unicast 7 8
192.168.101.2 65100 112 112 00:04:44 Established IPv4 Unicast 3 9

r1# show ip bgp neighbors 192.168.0.2 brief

Neighbor AS MsgRcvd MsgSent ResetTime State Afi/Safi PfxRcd PfxSnt
192.168.0.2 65000 110 110 00:05:22 Established IPv4 Unicast 7 8

r1# show ip bgp neighbors 192.168.0.2 brief json
{
"192.168.0.2":{
"hostname":"r2",
"remoteAs":65000,
"localAs":65000,
"lastResetDueTo":"No path to specified Neighbor",
"bgpState":"Established",
"bgpTimerUpMsec":332000,
"bgpTimerUpString":"00:05:32",
"bgpTimerUpEstablishedEpoch":1771862507,
"lastResetTimerMsecs":343000,
"messageStats":{
"totalSent":117,
"totalRecv":117
},
"addressFamilyInfo":{
"ipv4Unicast":{
"acceptedPrefixCounter":7,
"sentPrefixCounter":8
}
}
}
}
r1# show bgp neighbors 192.168.0.2 brief json
{
"192.168.0.2":{
"hostname":"r2",
"remoteAs":65000,
"localAs":65000,
"lastResetDueTo":"No path to specified Neighbor",
"bgpState":"Established",
"bgpTimerUpMsec":348000,
"bgpTimerUpString":"00:05:48",
"bgpTimerUpEstablishedEpoch":1771862507,
"lastResetTimerMsecs":359000,
"messageStats":{
"totalSent":122,
"totalRecv":122
},
"addressFamilyInfo":{
"ipv4Unicast":{
"acceptedPrefixCounter":7,
"sentPrefixCounter":8
}
}
}
}
r1# show bgp neighbors brief json
{
"192.168.0.2":{
"hostname":"r2",
"remoteAs":65000,
"localAs":65000,
"lastResetDueTo":"No path to specified Neighbor",
"bgpState":"Established",
"bgpTimerUpMsec":363000,
"bgpTimerUpString":"00:06:03",
"bgpTimerUpEstablishedEpoch":1771862507,
"lastResetTimerMsecs":374000,
"messageStats":{
"totalSent":127,
"totalRecv":127
},
"addressFamilyInfo":{
"ipv4Unicast":{
"acceptedPrefixCounter":7,
"sentPrefixCounter":8
}
}
},
"192.168.101.2":{
"hostname":"r4",
"remoteAs":65100,
"localAs":65000,
"lastResetDueTo":"No path to specified Neighbor",
"bgpState":"Established",
"bgpTimerUpMsec":373000,
"bgpTimerUpString":"00:06:13",
"bgpTimerUpEstablishedEpoch":1771862497,
"lastResetTimerMsecs":374000,
"messageStats":{
"totalSent":141,
"totalRecv":141
},
"addressFamilyInfo":{
"ipv4Unicast":{
"acceptedPrefixCounter":3,
"sentPrefixCounter":9
}
}
}
}
r1# show ip bgp neighbors brief json
{
"192.168.0.2":{
"hostname":"r2",
"remoteAs":65000,
"localAs":65000,
"lastResetDueTo":"No path to specified Neighbor",
"bgpState":"Established",
"bgpTimerUpMsec":376000,
"bgpTimerUpString":"00:06:16",
"bgpTimerUpEstablishedEpoch":1771862507,
"lastResetTimerMsecs":387000,
"messageStats":{
"totalSent":132,
"totalRecv":132
},
"addressFamilyInfo":{
"ipv4Unicast":{
"acceptedPrefixCounter":7,
"sentPrefixCounter":8
}
}
},
"192.168.101.2":{
"hostname":"r4",
"remoteAs":65100,
"localAs":65000,
"lastResetDueTo":"No path to specified Neighbor",
"bgpState":"Established",
"bgpTimerUpMsec":386000,
"bgpTimerUpString":"00:06:26",
"bgpTimerUpEstablishedEpoch":1771862497,
"lastResetTimerMsecs":387000,
"messageStats":{
"totalSent":146,
"totalRecv":146
},
"addressFamilyInfo":{
"ipv4Unicast":{
"acceptedPrefixCounter":3,
"sentPrefixCounter":9
}
}
}
}
r1#

@frrbot frrbot Bot added bgp tests Topotests, make check, etc labels Feb 24, 2026
@greptile-apps

greptile-apps Bot commented Feb 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a brief option to the show bgp neighbors command, providing a compact tabular view of BGP neighbor information including AS, message counts, uptime, state, and per-AFI/SAFI prefix counts.

Key Changes:

  • Added VTY_BGP_PEER_SHOW_BRIEF_INFO flag to control brief output mode
  • Implemented brief output in both text (tabular) and JSON formats in bgp_show_peer()
  • Modified bgp_show_neighbor() to print header for brief text output
  • Updated command definition to accept brief keyword alongside existing graceful-restart option
  • Added comprehensive test coverage for single/multiple neighbors in text/JSON formats

Implementation Details:

  • Text format displays neighbors in a table with columns for neighbor IP, AS, message stats, reset time, state, and AFI/SAFI-specific prefix counts
  • Multiple AFI/SAFI families for a single neighbor are shown on separate rows with proper indentation
  • JSON format includes essential fields: hostname, AS numbers, state, uptime, message stats, and per-AFI/SAFI prefix counters
  • Early return in bgp_show_peer() ensures brief mode doesn't execute the full verbose output path

Confidence Score: 4/5

  • This PR is safe to merge with low risk of introducing bugs
  • The implementation is straightforward with proper separation between brief and full output modes. Code follows existing patterns in the codebase, handles both text and JSON output correctly, and includes comprehensive test coverage. Minor formatting alignment concern in multi-AFI/SAFI text output doesn't affect functionality.
  • No files require special attention

Important Files Changed

Filename Overview
bgpd/bgp_vty.c Adds brief output mode for BGP neighbors with text and JSON formats; implementation is solid with minor alignment concern in multi-AFI/SAFI text output
bgpd/bgp_vty.h Adds VTY_BGP_PEER_SHOW_BRIEF_INFO flag and header constant; straightforward changes with no issues
tests/topotests/bgp_features/test_bgp_features.py Adds comprehensive test coverage for brief mode in both text and JSON formats; validates all required fields and scenarios

Last reviewed commit: 407137c

@hnattamaisub
hnattamaisub force-pushed the bgp_brief_json branch 5 times, most recently from d2305a7 to 7912ab5 Compare February 24, 2026 06:05
@donaldsharp

Copy link
Copy Markdown
Member

doc changes?

@hnattamaisub

Copy link
Copy Markdown
Contributor Author

ci:rerun

@ton31337 ton31337 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Documentation is missing.

Comment thread bgpd/bgp_vty.c Outdated
Comment thread bgpd/bgp_vty.c Outdated
@frrbot frrbot Bot added the documentation label Feb 26, 2026
@github-actions github-actions Bot added the rebase PR needs rebase label Feb 26, 2026
@hnattamaisub

Copy link
Copy Markdown
Contributor Author

doc changes?

done

@hnattamaisub

Copy link
Copy Markdown
Contributor Author

Documentation is missing.

done

@hnattamaisub

Copy link
Copy Markdown
Contributor Author

ci:rerun

Comment thread bgpd/bgp_vty.c Outdated

@ton31337 ton31337 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still some comments from my side...

Comment thread bgpd/bgp_vty.c Outdated
Comment thread doc/user/bgp.rst Outdated
Comment thread tests/topotests/bgp_features/test_bgp_features.py Outdated
Comment thread tests/topotests/bgp_features/test_bgp_features.py Outdated

@riw777 riw777 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good, waiting on @ton31337 's comment

@hnattamaisub

Copy link
Copy Markdown
Contributor Author

ci:rerun

@hnattamaisub
hnattamaisub force-pushed the bgp_brief_json branch 3 times, most recently from db79c59 to ab6cdc2 Compare March 5, 2026 03:49
@hnattamaisub

Copy link
Copy Markdown
Contributor Author

ci:rerun

@ashred-lnx

ashred-lnx commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Hi @riw777 @ton31337 can we please merge this? thanks

@ton31337 ton31337 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use f-strings everywhere including logger.

@hnattamaisub

Copy link
Copy Markdown
Contributor Author

Please use f-strings everywhere including logger.

done , thanks

@hnattamaisub

Copy link
Copy Markdown
Contributor Author

ci:rerun

1 similar comment
@hnattamaisub

Copy link
Copy Markdown
Contributor Author

ci:rerun

New commands:
1)show bgp neighbors 192.168.0.2 brief
2)show bgp neighbors brief
3)show ip bgp neighbors brief
4)show ip bgp neighbors 192.168.0.2 brief
5)show ip bgp neighbors 192.168.0.2 brief json
6)show bgp neighbors 192.168.0.2 brief json
7)show bgp neighbors brief json
8)show ip bgp neighbors brief json

Signed-off-by: harini <hnattamaisub@nvidia.com>
Comment thread tests/topotests/bgp_features/test_bgp_features.py Outdated
Signed-off-by: harini <hnattamaisub@nvidia.com>
Signed-off-by: harini <hnattamaisub@nvidia.com>

@ton31337 ton31337 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@hnattamaisub

Copy link
Copy Markdown
Contributor Author

ci:rerun

@ton31337
ton31337 merged commit d6671d4 into FRRouting:master Mar 10, 2026
19 checks passed
@hnattamaisub
hnattamaisub deleted the bgp_brief_json branch March 10, 2026 10:45
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/L tests Topotests, make check, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants