Skip to content

[Nexthop][fboss2-dev] Add fboss2-dev config protocol bgp global command#1345

Open
hillol-nexthop wants to merge 2 commits into
facebook:mainfrom
nexthop-ai:bgpglobal-global
Open

[Nexthop][fboss2-dev] Add fboss2-dev config protocol bgp global command#1345
hillol-nexthop wants to merge 2 commits into
facebook:mainfrom
nexthop-ai:bgpglobal-global

Conversation

@hillol-nexthop

@hillol-nexthop hillol-nexthop commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Add fboss2-dev config protocol bgp global <attr> <value> on top of the
BGP-aware ConfigSession. It edits the typed bgp::thrift::BgpConfig via
ConfigSession::getBgpConfig()/saveBgpConfig() — the whole-config,
scope-agnostic typed API (no global/peer/peer-group special-casing in
ConfigSession).

  • Collapses the 10 per-attribute global command classes into one dispatcher;
    rejects cluster-id (no BgpConfig field) instead of writing dead config;
    bounds switch-limit / max_golden_vips so out-of-range values aren't
    truncated.
  • Integration tests: ConfigBgpGlobalTest (each attribute set+commit, verified
    in the promoted /etc/coop/bgpcpp/bgpcpp.conf) and ConfigBgpSessionTest
    (clear/diff/commit/rollback + an unchanged-config no-op-restart regression),
    sharing ConfigBgpTestBase.

Stacked on #1344 (BGP-aware ConfigSession infra). This PR's branch
includes #1344's commit as its base, so the diff shows two commits — please
review only the second (config protocol bgp global) here; the first is
reviewed in #1344. Merge #1344 first.

Test Plan

  • fboss/cli/fboss2/test/config:cmd_config_test
  • fboss2_integration_test on a DUT with bgp_pp active:
    ConfigBgpSessionTest 6/6 pass (clear, diff, commit-restarts-bgp_pp,
    rollback-restores-config, unchanged-config-does-not-restart); agent-session
Integration test output (bgp_pp active)
$ fboss2_integration_test --gtest_filter='ConfigBgpSessionTest.*'
[       OK ] ConfigBgpSessionTest.CreateAndClearBgpSession
[       OK ] ConfigBgpSessionTest.ClearNonExistentBgpSession
[       OK ] ConfigBgpSessionTest.DiffShowsStagedBgpChange
[       OK ] ConfigBgpSessionTest.CommitRestartsBgpDaemon (2083 ms)
[       OK ] ConfigBgpSessionTest.RollbackRestoresBgpConfig (298 ms)
[       OK ] ConfigBgpSessionTest.CommitUnchangedBgpConfigDoesNotRestart (133 ms)
[==========] 6 tests from 1 test suite ran.
[  PASSED  ] 6 tests.
@meta-cla meta-cla Bot added the CLA Signed label Jun 29, 2026
@hillol-nexthop hillol-nexthop force-pushed the bgpglobal-global branch 2 times, most recently from 7ef6303 to 5512012 Compare June 29, 2026 17:21
hillol-nexthop and others added 2 commits June 30, 2026 14:26
Make the fboss2 ConfigSession and `config session` lifecycle BGP-aware. This is
the base for the `config protocol bgp` commands, which stack on top.

- ConfigSession owns the BGP config as a typed bgp::thrift::BgpConfig, exactly
  the way it owns cfg::AgentConfig for the agent. getBgpConfig()/saveBgpConfig()
  expose the WHOLE typed config and stage it to ~/.fboss2/bgp_config.json.
  ConfigSession is BGP-aware but agnostic about the config's internal structure:
  it has no notion of "global" vs "peer" vs "peer-group" -- a command mutates
  whichever typed fields it needs, mirroring how interface commands mutate
  getAgentConfig().sw()->ports(). Because the whole config round-trips through
  the typed struct, no surgical merge / preserve-list is needed.
- commit() promotes bgp_config.json to /etc/coop/bgpcpp/bgpcpp.conf, restarts
  bgp_pp, and versions it in the same /etc/coop git repo as agent.conf.
- config session clear/diff/rebase/rollback are BGP-aware: clear removes a
  staged BGP session, diff shows staged BGP changes, rebase 3-way-merges
  bgpcpp.conf, rollback restores bgpcpp.conf + restarts bgp_pp (using metadata
  history so BGP-only commits are reachable).
- FbossServiceUtil + cli_metadata gain the bgp_pp (BGP_PP) service/action; the
  config lib gains the bgp_config cpp2 dependency.
- Unit tests in CmdConfigSession{,Diff}Test cover the typed round-trip, commit,
  rebase, and rollback behavior.

Test Plan:
- bazel test //fboss/cli/fboss2/test/config:cmd_config_test //fboss/cli/fboss2/test:cmd_test
- fboss2_integration_test on a DUT (ConfigConcurrentSessionsTest.ConflictAndRebase,
  ConfigSessionClearTest, ConfigInterfaceMtuTest, ConfigInterfaceDescriptionTest): 5/5 pass

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add `fboss2-dev config protocol bgp global <attr> <value>` on top of the
BGP-aware ConfigSession (base PR). Edits the typed bgp::thrift::BgpConfig via
ConfigSession::getBgpConfig()/saveBgpConfig() -- the whole-config,
scope-agnostic typed API (no global/peer/peer-group special-casing in
ConfigSession).

- Collapse the 10 per-attribute global command classes into one dispatcher;
  reject cluster-id (no BgpConfig field) instead of writing dead config; bound
  switch-limit / max_golden_vips so out-of-range values aren't truncated.
- Integration tests: ConfigBgpGlobalTest (each attr set+commit, verified in the
  promoted /etc/coop/bgpcpp/bgpcpp.conf) and ConfigBgpSessionTest
  (clear/diff/commit/rollback + a no-op-restart regression), sharing
  ConfigBgpTestBase.

Test Plan:
- bazel test //fboss/cli/fboss2/test/config:cmd_config_test
- bazel build //fboss/cli/fboss2/test/integration_test:fboss2_integration_test
- fboss2_integration_test on a DUT with bgp_pp active: ConfigBgpSessionTest
  6/6 pass (clear, diff, commit-restarts-bgp_pp, rollback-restores-config, and
  the unchanged-config does-not-restart case); agent-session regression
  (ConfigInterfaceMtuTest) passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hillol-nexthop hillol-nexthop marked this pull request as ready for review June 30, 2026 16:26
@hillol-nexthop hillol-nexthop requested review from a team as code owners June 30, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant