Skip to content

[Nexthop][fboss2-dev] BGP-aware fboss2 config session (ConfigSession infra)#1344

Open
hillol-nexthop wants to merge 1 commit into
facebook:mainfrom
nexthop-ai:bgpglobal-session
Open

[Nexthop][fboss2-dev] BGP-aware fboss2 config session (ConfigSession infra)#1344
hillol-nexthop wants to merge 1 commit into
facebook:mainfrom
nexthop-ai:bgpglobal-session

Conversation

@hillol-nexthop

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

Copy link
Copy Markdown
Contributor

Summary

Make the fboss2 ConfigSession and config session lifecycle BGP-aware. This
is the base for the config protocol bgp commands, which build on top (see the
stacked PR).

  • 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: a command mutates whichever typed
    fields it needs, mirroring how interface commands mutate
    getAgentConfig().sw()->ports(). The whole config round-trips through the
    typed struct, so 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.

Test Plan

  • fboss/cli/fboss2/test/config:cmd_config_test — 455 tests pass
    (the BGP-session unit tests for the fixes below land in this PR).
  • //fboss/cli/... builds on top of upstream/main.
  • End-to-end coverage of the BGP session lifecycle on a live bgp_pp runs as
    ConfigBgpSessionTest, which is added in the stacked PR (the integration
    harness ships with the config protocol bgp commands) — 6/6 pass there.
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>
@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