Skip to content

[Nexthop] [fboss2-dev] Add BGP CLI show commands and tests#1039

Open
manoharan-nexthop wants to merge 2 commits into
facebook:mainfrom
nexthop-ai:manoharan.bgp-show
Open

[Nexthop] [fboss2-dev] Add BGP CLI show commands and tests#1039
manoharan-nexthop wants to merge 2 commits into
facebook:mainfrom
nexthop-ai:manoharan.bgp-show

Conversation

@manoharan-nexthop
Copy link
Copy Markdown
Contributor

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

Summary

Adds BGP CLI show commands for the fboss2 CLI tool. These commands provide visibility into BGP state, configuration, routes, neighbors, and statistics.

BGP Show Commands Added:

Core Commands:

  • show bgp summary - Display BGP session summary
  • show bgp summary egress - Display egress BGP summary
  • show bgp neighbors - Show BGP neighbor information
  • show bgp table - Display BGP routing table
  • show bgp table - Show specific prefix details
  • show bgp table detail - Show detailed routing table
  • show bgp table community - Filter by community
  • show bgp table more-specifics - Show more specific routes
  • show bgp originated-routes - Display originated routes
  • show bgp shadowrib - Show shadow RIB entries
  • show bgp changelist - Display BGP changelist
  • show version bgp - Show BGP version information

Configuration Commands:

  • show config running bgp - Display running BGP configuration

Neighbor Route Commands:

  • show bgp neighbors received pre-policy - Routes received before policy
  • show bgp neighbors received post-policy - Routes received after policy
  • show bgp neighbors received rejected - Rejected received routes
  • show bgp neighbors advertised pre-policy - Routes to advertise before policy
  • show bgp neighbors advertised post-policy - Routes advertised after policy
  • show bgp neighbors advertised rejected - Rejected advertised routes
  • show bgp neighbors advertised dry-run - Dry-run advertised routes
  • show bgp neighbors session-id - Display session ID

Statistics Commands:

  • show bgp stats entries - Display BGP entry statistics
  • show bgp stats policy - Show BGP policy statistics
  • show bgp stats attrs - Display BGP attribute statistics

Stream Commands:

  • show bgp stream summary - Display BGP stream summary
  • show bgp stream subscriber - Show stream subscribers
  • show bgp stream subscriber pre-policy - Pre-policy stream subscribers
  • show bgp stream subscriber post-policy - Post-policy stream subscribers

Implementation Details:

Command Handler:

  • CmdHandlerImplBgp.cpp - BGP command handler implementation
  • CmdList.cpp - Updated to register BGP commands

Utilities:

  • CmdShowUtils.cpp/h - Common utilities for BGP show commands
  • CmdClientUtils.cpp/h - Client utilities for BGP service communication
  • CmdUtilsCommon.cpp - Common command utilities
  • NetTools.h - Network utility functions

Tests (22 test files):

  • CmdShowBgpSummaryTest.cpp
  • CmdShowBgpSummaryEgressTest.cpp
  • CmdShowBgpNeighborsTest.cpp
  • CmdShowBgpTableTest.cpp
  • CmdShowBgpTablePrefixTest.cpp
  • CmdShowBgpTableDetailTest.cpp
  • CmdShowBgpTableCommunityTest.cpp
  • CmdShowBgpTableMoreSpecificsTest.cpp
  • CmdShowBgpOriginatedRoutesTest.cpp
  • CmdShowBgpShadowRibTest.cpp
  • CmdShowBgpChangelistTest.cpp
  • CmdShowBgpNeighborsReceivedPrePolicyTest.cpp
  • CmdShowBgpNeighborsReceivedPostPolicyTest.cpp
  • CmdShowBgpNeighborsReceivedRejectedTest.cpp
  • CmdShowBgpNeighborsAdvertisedPrePolicyTest.cpp
  • CmdShowBgpNeighborsAdvertisedPostPolicyTest.cpp
  • CmdShowBgpNeighborsAdvertisedRejectedTest.cpp
  • CmdShowBgpStatsEntriesTest.cpp
  • CmdShowBgpStatsPolicyTest.cpp
  • CmdShowBgpStatsAttrsTest.cpp
  • CmdShowBgpStreamSummaryTest.cpp
  • CmdShowBgpStreamSubscriberTest.cpp

Test Infrastructure:

  • CmdBgpTestUtils.cpp/h - BGP test utilities
  • MockBgpClient.h - Mock BGP client for testing
  • CmdHandlerTestBase.h - Base class for command handler tests
  • MockClients.h - Mock client implementations
  • CmdShowConfigTestUtils.cpp/h - Configuration test utilities
  • BgpConfigSessionTest.cpp - BGP configuration session tests

Build System Updates:

  • cmake/CliFboss2.cmake - Added BGP command sources
  • cmake/CliFboss2Test.cmake - Added BGP test sources

Test Plan

All the CLI unit tests passes.

@manoharan-nexthop manoharan-nexthop requested review from a team as code owners March 26, 2026 18:31
@meta-cla meta-cla Bot added the CLA Signed label Mar 26, 2026
@manoharan-nexthop manoharan-nexthop force-pushed the manoharan.bgp-show branch 2 times, most recently from 10dcdb2 to 5b087e9 Compare March 26, 2026 20:32
@manoharan-nexthop manoharan-nexthop force-pushed the manoharan.bgp-show branch 4 times, most recently from 9262a08 to 83e2d58 Compare May 1, 2026 05:22
@manoharan-nexthop manoharan-nexthop force-pushed the manoharan.bgp-show branch 2 times, most recently from 128f228 to 61ac3e3 Compare May 7, 2026 14:25
@induvsuresh
Copy link
Copy Markdown
Contributor

bgp_thrift.thrift and policy_thrift.thrift have been published already, could we remove from the current PR?

@manoharan-nexthop manoharan-nexthop force-pushed the manoharan.bgp-show branch 2 times, most recently from a7df529 to 77f2cbd Compare May 8, 2026 08:27
@manoharan-nexthop
Copy link
Copy Markdown
Contributor Author

bgp_thrift.thrift and policy_thrift.thrift have been published already, could we remove from the current PR?

@induvsuresh , This has been updated.. please let me know if anything else to be changed. Thanks!

Copy link
Copy Markdown
Contributor

@induvsuresh induvsuresh left a comment

Choose a reason for hiding this comment

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

Thank you for the working on this! the test changes, cmake are going to be super useful and it is very thorough

I've left some comments that are blockers for merge , eg: the buck changes etc, could we address that for merge pls

Comment thread fboss/cli/fboss2/BUCK
Comment thread fboss/cli/fboss2/test/MockClients.h Outdated
Comment thread fboss/cli/fboss2/commands/show/hardware/CmdShowHardware.cpp Outdated
Comment thread fboss/cli/fboss2/BUCK
Comment thread fboss/cli/fboss2/oss/NetTools.h Outdated
Comment thread fboss/cli/fboss2/commands/show/bgp/CmdShowBgpOriginatedRoutes.h Outdated
Comment thread fboss/cli/fboss2/test/CmdBgpTestUtils.cpp Outdated
Comment thread fboss/cli/fboss2/test/bgp/MockBgpClient.h Outdated
@manoharan-nexthop manoharan-nexthop force-pushed the manoharan.bgp-show branch 5 times, most recently from 496831c to e74db48 Compare May 20, 2026 12:45
Comment thread fboss/cli/fboss2/BUCK Outdated
This commit adds build configuration for existing upstream BGP thrift
interfaces from the neteng/ directory.

Files Referenced:
- neteng/fboss/bgp/if/bgp_thrift.thrift - Main BGP service interface (TBgpService)
  defining RPC methods for BGP operations, session management, RIB queries,
  policy management, and monitoring
- neteng/fboss/bgp/if/policy_thrift.thrift - Routing policy statistics
- fboss/cli/fboss2/commands/show/bgp/summary/bgp_summary.thrift - BGP summary
  data model for CLI commands

Build System Updates:
- CMakeLists.txt - Added thrift compilation targets for BGP thrift files
  referencing the upstream neteng/ implementations with dependencies on
  configerator BGP policy and attribute definitions
- fboss/cli/fboss2/commands/show/bgp/summary/BUCK - Thrift library for bgp_summary

Dependencies:
- Uses upstream neteng BGP thrift definitions (full-featured version)
- Requires configerator BGP policy and attribute thrift definitions
- Integrates with fb303 for service monitoring

Migration Notes:
- Previously attempted to create custom thrift files in fboss/bgp/if/ and
  fboss/routing/policy/if/, but upstream Meta already provides these in
  neteng/fboss/bgp/if/ with full BGP++ feature set including health checks,
  partial drain state, profiler, and advanced session management
- Migrated to use the full-featured upstream version to avoid duplication
  and benefit from complete BGP++ functionality
This commit adds comprehensive BGP (Border Gateway Protocol) CLI show commands
for the fboss2 CLI tool. These commands provide visibility into BGP state,
configuration, routes, neighbors, and statistics.

BGP Show Commands Added:
========================

Core Commands:
- show bgp summary - Display BGP session summary
- show bgp summary egress - Display egress BGP summary
- show bgp neighbors - Show BGP neighbor information
- show bgp table - Display BGP routing table
- show bgp table <prefix> - Show specific prefix details
- show bgp table detail - Show detailed routing table
- show bgp table community <community> - Filter by community
- show bgp table more-specifics <prefix> - Show more specific routes
- show bgp originated-routes - Display originated routes
- show bgp shadowrib - Show shadow RIB entries
- show bgp changelist - Display BGP changelist
- show version bgp - Show BGP version information

Configuration Commands:
- show config running bgp - Display running BGP configuration

Neighbor Route Commands:
- show bgp neighbors <neighbor> received pre-policy - Routes received before policy
- show bgp neighbors <neighbor> received post-policy - Routes received after policy
- show bgp neighbors <neighbor> received rejected - Rejected received routes
- show bgp neighbors <neighbor> advertised pre-policy - Routes to advertise before policy
- show bgp neighbors <neighbor> advertised post-policy - Routes advertised after policy
- show bgp neighbors <neighbor> advertised rejected - Rejected advertised routes
- show bgp neighbors <neighbor> advertised dry-run - Dry-run advertised routes
- show bgp neighbors <neighbor> session-id - Display session ID

Statistics Commands:
- show bgp stats entries - Display BGP entry statistics
- show bgp stats policy - Show BGP policy statistics
- show bgp stats attrs - Display BGP attribute statistics

Stream Commands:
- show bgp stream summary - Display BGP stream summary
- show bgp stream subscriber - Show stream subscribers
- show bgp stream subscriber pre-policy - Pre-policy stream subscribers
- show bgp stream subscriber post-policy - Post-policy stream subscribers

Implementation Details:
======================

Command Handler:
- CmdHandlerImplBgp.cpp - BGP command handler implementation
- CmdList.cpp - Updated to register BGP commands

Utilities:
- CmdShowUtils.cpp/h - Common utilities for BGP show commands
- NetTools.h - Network utility functions

Build System Updates:
- cmake/CliFboss2.cmake - Added BGP command sources
- cmake/CliFboss2Test.cmake - Added BGP test sources

Migration Notes:
- Updated bgp_summary.thrift to use neteng/fboss/bgp/if/ include path
- Updated all C++ includes to use neteng/fboss/bgp/if/gen-cpp2/ for generated code
- Removed OSS-specific simplified policy stats implementation to use full-featured
  upstream implementation everywhere

Dependencies:
This commit depends on the BGP thrift definitions added in the previous commit.

Total Changes:
- 39 command implementation files
- 22 test files
- 8 utility/infrastructure files
- 2 cmake build files
- 85 files changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants