Skip to content

[Nexthop][fboss2-dev] fboss2 bgp policy community-list community subcommand - #1486

Closed
hillol-nexthop wants to merge 22 commits into
meta:mainfrom
nexthop-ai:bgp-policy-community-list-community
Closed

hillol-nexthop wants to merge 22 commits into
meta:mainfrom
nexthop-ai:bgp-policy-community-list-community

Conversation

@hillol-nexthop

@hillol-nexthop hillol-nexthop commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1475 (config/delete protocol bgp policy community-list). This PR's branch contains the whole stack below it, so the diff shows those commits too — please review only the bgp policy community-list community commit(s) here. Merge the lower PRs first.

Stack (bottom → top): #1345 → #1391 → #1395 → #1401 → #1485 → #1475 → #1486 (this PR) → #1477 → #1487 → #1488 → #1489 → #1490 → #1491

Summary

Splits the community (inline member) level of config protocol bgp policy community-list out of the list-level PR into its own CLI11 subcommand,
mirroring as-path-list <name> entry <seq-num>.

Before, community <name> was parsed as tokens inside BgpCommunityListConfig,
so one arg type and one queryClient carried both key levels. Now the list
command owns only list attributes, and this command owns the member: the list
name reaches it through the ancestor-args tuple, and lookup/create is shared
through BgpCommunityListCliUtils.h (added by the base PR).

The user-visible grammar is unchanged — community-list CL100 community CM1 value 65000:100 still works; it is now dispatched by CLI11 rather than by
hand-rolled token matching. delete ... community-list <name> community <name>
is untouched and stays in the base PR.

A list attribute typed alongside community is rejected rather than silently
dropped, because only the leaf command runs.

Sample usage

$ fboss2-dev config protocol bgp policy community-list CL100 community CM1
Successfully created BGP community-list CL100 community CM1
Config saved to: ~/.fboss2/bgp_config.json

$ fboss2-dev config protocol bgp policy community-list CL100 community CM1 value 65000:100
Successfully set value to: 65000:100 for community-list CL100 community CM1

$ fboss2-dev config protocol bgp policy community-list CL100 community CM1 type LARGE
Successfully set type to: LARGE for community-list CL100 community CM1

$ fboss2-dev config protocol bgp policy community-list CL100 community CM1 description spine tag
Successfully set description to: spine tag for community-list CL100 community CM1

$ fboss2-dev config protocol bgp policy community-list CL100 community CM1 type MEDIUM
Error: Invalid type value 'MEDIUM'; expected NORMAL|EXTENDED|LARGE

$ fboss2-dev config protocol bgp policy community-list CL100 description mixed community CM1
Error: configure community-list attributes and community in separate commands (got community-list attribute 'description' alongside community CM1)

Test plan

Unit — fboss2_cmd_config_test:

$ fboss2_cmd_config_test --gtest_filter=*CommunityListCommunity*
[       OK ] CmdConfigBgpPolicyCommunityListCommunityTestFixture.argValidation (88 ms)
[       OK ] CmdConfigBgpPolicyCommunityListCommunityTestFixture.bareCreateCommunity (73 ms)
[       OK ] CmdConfigBgpPolicyCommunityListCommunityTestFixture.setCommunityAttributes (197 ms)
[       OK ] CmdConfigBgpPolicyCommunityListCommunityTestFixture.communitiesAccumulateAndAreKeyed (133 ms)
[       OK ] CmdConfigBgpPolicyCommunityListCommunityTestFixture.reReferenceReportsExisting (107 ms)
[       OK ] CmdConfigBgpPolicyCommunityListCommunityTestFixture.invalidCommunityTypeRejected (59 ms)
[       OK ] CmdConfigBgpPolicyCommunityListCommunityTestFixture.rejectedCommunityOnExistingListKeepsList (76 ms)
[       OK ] CmdConfigBgpPolicyCommunityListCommunityTestFixture.rejectedCommunityKeepsExistingMembers (118 ms)
[       OK ] CmdConfigBgpPolicyCommunityListCommunityTestFixture.listAttributeMixedWithCommunityRejected (76 ms)
[==========] 9 tests from 1 test suite ran. (931 ms total)
[  PASSED  ] 9 tests.

Integration — fboss2_integration_test on a lab device with bgp_pp active:

$ fboss2_integration_test --gtest_filter='ConfigBgpPolicyCommunityListCommunityTest.*'
[       OK ] ConfigBgpPolicyCommunityListCommunityTest.SetAttributesAndCommit (1293 ms)
[       OK ] ConfigBgpPolicyCommunityListCommunityTest.DeleteCommunityAndCommit (3430 ms)
[==========] 2 tests from 1 test suite ran.
[  PASSED  ] 2 tests.

Based-on: #1475

@meta-cla meta-cla Bot added the CLA Signed label Aug 7, 2026
@hillol-nexthop
hillol-nexthop force-pushed the bgp-policy-community-list-community branch from 60d9845 to 72e754a Compare August 10, 2026 04:44
@hillol-nexthop
hillol-nexthop force-pushed the bgp-policy-community-list-community branch 2 times, most recently from c4d61f8 to 4ccab72 Compare August 10, 2026 05:43
@hillol-nexthop
hillol-nexthop marked this pull request as ready for review August 10, 2026 09:54
@hillol-nexthop
hillol-nexthop requested review from a team as code owners August 10, 2026 09:54
@hillol-nexthop
hillol-nexthop force-pushed the bgp-policy-community-list-community branch 3 times, most recently from 796f2b2 to a6457d4 Compare August 11, 2026 05:52
@hillol-nexthop
hillol-nexthop force-pushed the bgp-policy-community-list-community branch 6 times, most recently from b1d436b to 5bce693 Compare August 27, 2026 12:32
@hillol-nexthop
hillol-nexthop force-pushed the bgp-policy-community-list-community branch 2 times, most recently from 3b67168 to 5a25617 Compare September 2, 2026 05:43
@hillol-nexthop
hillol-nexthop force-pushed the bgp-policy-community-list-community branch from 5a25617 to 5e44ffd Compare September 7, 2026 05:41
meta-codesync Bot pushed a commit that referenced this pull request Sep 11, 2026
Summary:
> **Base of the `fboss2-dev config protocol bgp` stack** (follow-up to the merged #1344). Everything above it in the list below builds on this PR, so merge this one first.
>
> **Stack (bottom → top):** **#1446 (this PR)** → #1345 → #1391 → #1395 → #1401 → #1485 → #1475 → #1486 → #1477 → #1487 → #1488 → #1489 → #1490 → #1491

Follow-up to #1344 (BGP-aware fboss2 config session): unify the agent and BGP
domains inside `ConfigSession` and decouple the `ConfigSession.h` header from
the heavy generated thrift types.

- Make `ConfigActionLevel` generic across services (review feedback below):
  `HITLESS` / `SERVICE_RESTART` / `DISRUPTIVE_SERVICE_RESTART` replace
  `HITLESS` / `AGENT_WARMBOOT` / `AGENT_COLDBOOT` (+ the bgpd-only `BGP_RESTART`).
  What a level means is decided per service from the (service, level) pair in
  `FbossServiceUtil::restartTypeName()`: agent → warmboot / coldboot, bgpd (no
  warmboot or hitless reload) → plain restart. `config session commit` labels
  the restarted services accordingly (`wedge_agent (warmboot)`, `bgpd (restart)`).
  A session staged before this change (old level names in
  `~/.fboss2/cli_metadata.json`) no longer parses and loses its recorded
  restart level (WARNING logged) -- `config session clear` it first.
- Introduce a single `ConfigDomain` descriptor + `configDomains()` and shared
  per-domain helpers so `commit()`, `rollback()` and `config session diff`
  handle the agent and BGP domains uniformly (private `DiffDomain` removed).
- Make the agent skip-when-unchanged like BGP: a commit whose staged config
  equals what is already promoted is a true no-op (no git revision, no symlink
  churn, no `reloadConfig()`/bgpd restart). Change detection is semantic
  (compare the deserialized thrift structs), so formatting-only diffs don't
  count.
- Consolidate `config session clear` onto a static `stagedSessionFilePaths()`
  and reuse `ConfigSession::readStagedContent()` in diff.
- Make `ConfigSession::saveConfig(service, level)` generic over the service and
  reduce `saveBgpConfig()` to a thin wrapper.
- Keep the heavy generated thrift headers out of `ConfigSession.h`: use the
  `*_types_fwd.h` forward-declaration headers, hold `agentConfig_`/`bgpConfig_`
  by `std::unique_ptr`, and drop the `configLoaded_`/`bgpConfigLoaded_` bools
  (null == not loaded).

Pull Request resolved: #1446

Test Plan:
- `fboss/cli/fboss2/test/config:cmd_config_test` passes (the config-session /
  commit / diff / BGP / clear unit tests cover the refactored paths); re-run in
  full after the action-level rename (871 tests).
- `//fboss/cli/...` builds and tests pass on top of `upstream/main`.
- Verified the agent no-op commit behaviour live on test switches.

Reviewed By: AarjunC

Differential Revision: D114376130

Pulled By: joseph5wu

fbshipit-source-id: 3a00f779a3c26b280be27dba92b28549bec692ca
@hillol-nexthop
hillol-nexthop force-pushed the bgp-policy-community-list-community branch from 5e44ffd to f49a347 Compare September 15, 2026 16:52
hillol-nexthop and others added 22 commits September 15, 2026 17:04
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.
- Extract the value parsers (parseBool/parseInt/parseNonNegInt32, handler
  Result) into a shared BgpCliValueParsers.h so sibling BGP dispatchers can
  reuse them, and add a bounded parseAsn4Byte: local-asn/confed-asn accepted
  any uint64 and silently persisted out-of-range ASNs (>= 2^32 wrap the i64
  field negative).
- positionals_at_end() on the global command: CLI11's parent-chain subcommand
  fallthrough steals value tokens that match a sibling command name (e.g. a
  policy named "peer-group") and misparses the command.
- Integration test base: probe the bgpd unit, and pass
  -c safe.directory=/etc/coop on the raw git invocations (gitHead /
  bgpTrackedAtRevision), mirroring the CLI's Git class -- /etc/coop is owned
  by another user (e.g. coop) on provisioned devices, which git otherwise
  rejects as dubious ownership and the helpers silently return empty results.
The commit-path global-attribute tests asserted on the promoted
/etc/coop/bgpcpp/bgpcpp.conf, which only proves what the CLI wrote to disk.
Route ConfigBgpTestBase::setAndCommit() through a new
readRunningBgpConfigViaRpc() -- TBgpService::getRunningConfig against the local
bgpd -- so every positive ConfigBgpGlobalTest asserts its attribute in the
daemon's own view of its config, proving bgpd parsed and adopted the promoted
file after the commit-triggered restart.

The helper retries briefly on connection errors: systemd reports bgpd active as
soon as the process starts, but its thrift server binds the port a few seconds
later, so an RPC issued right after a restart races that window.

Test Plan:
- bazel build //fboss/cli/fboss2/test/integration_test:fboss2_integration_test
- fboss2_integration_test on a DUT with bgpd active: ConfigBgpGlobalTest 7/7
  pass (each attribute set+commit verified in bgpd's getRunningConfig view,
  plus the invalid-bool and negative-graceful-restart-time reject paths).
Companion to "fboss2 config session seeds BGP config from the daemon's
config path": ConfigBgpTestBase::systemBgpConfigPath() reads the stable
/etc/coop/bgpcpp.conf daemon path instead of the promoted file, so the
fixture no longer requires a prior commit to have happened and BGP tests
can run first-thing on a freshly imaged box.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…p global

`router-id` stored whatever token it was given. bgpd builds an IPAddress from
it at config load (an unparseable string fails the load) and later calls
asV4() on it, so a v6 address passes construction and throws afterwards.
Parse with folly::IPAddress::tryFromString, require IPv4 and store the
normalized form.

`switch-limit-overload-protection-mode` cast any int32 straight into the enum;
bgpd switches on the value without a default and logs anything but 2 as
DROP_EXCESS_PREFIXES, so -5 or 999 silently behaved as mode 1. Accept the
enum name or its integer, reject everything else listing the valid names, and
validate before ensure() so a rejected value does not materialize
switch_limit_config. The success message keeps printing the integer so the
j2c round-trip is unchanged.

Adds CmdConfigBgpGlobalTest.cpp (the global command had no unit fixture) and
rejection/positive-commit cases to ConfigBgpGlobalTest.cpp.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Adds `config protocol bgp neighbor <ip-address> [<attribute> <value> ...]`
and `delete protocol bgp neighbor <ip-address>` — the first per-peer BGP
config family, beneath the `protocol bgp` grouping node.

- neighbor dispatcher keyed by peer address, writing bgp_config.BgpPeer
  through the typed ConfigSession. Attributes cover the peer identity
  (remote/local ASN, description, peer-tag, peer-group), policy bindings
  (ingress/egress policy), session tunables (timers, route limits,
  next-hop, add-path, RR client, and the rest of the documented set), and
  the sheet-documented attributes bgpd does not support, which are
  rejected with an explanatory message rather than staged.
- delete removes the peer by address.
- ConfigBgpTestBase restores the committed BGP config after every test, so
  a failed run cannot leave a device carrying test config; commit-path
  integration tests verify each value through bgpd's own getRunningConfig
  RPC rather than only the staged file.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review feedback on meta#1391: the generator quoted free-form strings but emitted
numeric/boolean fields raw. The input JSON is not type-checked, so a string
in an ASN or timer field reached the generated script unquoted. Quote every
value uniformly; shlex.quote is a no-op for valid integers and booleans.
… flag unconverted j2c fields

Route limits: when neither the peer nor its group carries a RouteLimit, the
first warning-only/threshold edit seeded the thrift default (max_routes 12000,
a hard cap with session teardown) where bgpd enforced nothing. Seed
{max_routes 0, warning_only false, warning_limit 0} instead: bgpd reads 0 as
unlimited, so only the requested field changes.

Attributes: add remove-private-as, enforce-first-as, route-refresh and
ttl-security-hops (1..255, bgpd's kMin/kMaxTtlSecurityHops), the remaining
BgpPeer fields bgpd resolves peer > group. Document the fields deliberately
not exposed (enabled, router_port_id, graceful_restart_end_of_rib_seconds:
nothing in bgpd reads them).

bgp_json_to_cli.py: shared bool/int/link-bandwidth tables for the fields
BgpPeer and PeerGroup have in common; deprecated i32 ASNs map to the 4-byte
attribute; any JSON field with no CLI equivalent emits a `# WARNING` comment
line in the script and on stderr instead of being dropped silently.
Collapses the 18 per-attribute `config protocol bgp peer-group` command
classes (built on the deprecated `folly::dynamic` BgpConfigSession) into a
single typed dispatcher, mirroring CmdConfigProtocolBgpNeighbor. Also adds
`delete protocol bgp peer-group <name>`.

The group name is the first positional token; the next one or two tokens
name the attribute, matched longest-prefix-first so `timers hold-time` wins
over any `timers` prefix; the rest are its value(s). Handlers mutate the
typed bgp::thrift::PeerGroup through ConfigSession::getBgpConfig() /
saveBgpConfig(), so adding a tunable is a one-entry change in the dispatch
table rather than a new command class. 36 command files are deleted.

- Covers the 29 dispatch keys that map to a PeerGroup thrift field: remote-asn /
  local-asn (4-byte-bounded), description, peer-tag, ingress-policy /
  egress-policy, rr-client, confed-peer, redistribute-peer,
  enhanced-route-refresh, connect-mode, add-path send|receive, afi
  disable-ipv4-afi|disable-ipv6-afi|ipv4-over-ipv6-nh, graceful-restart
  restart-time|stateful-ha, max-route pre-filter|post-filter (plus the
  warning-threshold / warning-only knobs), timers
  hold-time|keepalive|out-delay|withdraw-unprog-delay, and next-hop-self.
- Rejected rather than persisted as dead config (precedent: cluster-id in
  the global command, connect-mode BOTH in the neighbor command):
  connect-mode BOTH, since thrift only models is_passive. add-path
  send|receive merges into the AddPath enum bitmask, and clearing the last
  direction unsets the field.
- Attributes with no per-peer-group thrift field (afi
  ipv4-labeled-unicast, afi ipv6-labeled-unicast, peer-port) are absent
  from the dispatch table, so they are refused at parse time as unknown
  attributes; a rejected value never lands on disk.
- positionals_at_end() stops parent-chain subcommand fallthrough from
  reclassifying an attribute token that matches a sibling command name
  once the group name has been consumed (same fix as the neighbor
  command).

- unit tests (16): CmdConfigBgpPeerGroupTest (12) covering arg validation,
  longest-prefix match, the add-path merge matrix, connect-mode, the
  bool/string/route-limit attributes, value validation and unknown-attribute
  rejection, plus CmdDeleteBgpPeerGroupTest (4).
- integration tests (3): ConfigBgpPeerGroupTest asserts the committed
  peer_groups through bgpd's getRunningConfig RPC, proving the daemon
  parsed and adopted the promoted config rather than only checking the
  file the CLI wrote.
…UT gaps

delete protocol bgp peer-group now refuses to delete a group that a
neighbor's peer_group_name still references, naming the referencing
neighbors, instead of committing a dangling reference bgpd has no
defined behavior for.

New/extended unit tests close the coverage gaps found in review:
- timers out-delay and withdraw-unprog-delay (previously untested;
  withdraw-unprog-delay is a parity attribute tested for neighbor)
- valueValidation now asserts the half-created group is rolled back
  (state assertion, not just the error string)
- wrongValueCountRejected: zero/too-many value token counts
- overwriteSameAttributeLastWins: re-setting an attribute updates in
  place
- namedGroupsAreDistinct now asserts field preservation across
  mutations and sibling isolation
- delete: referenced-group rejected (all referencing neighbors named),
  unreferenced delete unaffected by other references, delete-then-
  recreate starts clean

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Two pre-existing CI failures surfaced on every CLI-touching PR:

- ConfigBgp*Test: the SetUp gate sampled systemctl is-active once. On
  fboss-sim bgpd flaps activating->active->failed from boot, so one
  unlucky sample lands in the brief active window, runs the test, and
  the bgpd thrift RPC then times out after 90s (seen as
  SetGracefulRestartTime / SetCountConfedsInAsPathLenFalse failures;
  green runs are the ones where every sample landed on inactive and
  skipped). The gate now also requires bgpd to answer its
  getRunningConfig RPC within 10s, else the test skips like the rest
  of the flap cycle.

- ConfigVlanDefaultTest.ChangeDefaultVlanWithPortInNonDefaultVlan
  vacated only the test port before changing the default VLAN, but the
  change-default guard refuses while ANY port still uses the old
  default VLAN without an interface. On baselines generated before the
  default VLAN, so the guard always fired. Vacate every eth port from
  the old default VLAN first and restore them after.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The suite is ~60 files of ConfigSession-backed tests, each doing several
fsync-backed writeFileAtomic calls per case; with this PR's added
peer-group tests the full run takes ~530s on a dev box and timed out at
the CI job's default moderate test timeout (300s) — killed
mid-fsync in ConfigSessionTestFixture.commandTrackingMultipleCommands,
50/51 remaining tests green. size=large raises the test timeout to 900s
(same precedent as thrift_packet_stream/tests).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rammar

Signed-off-by: hillol-nexthop <hillol@nexthop.ai>
…gap, flag unconverted j2c fields

Route limits: a group with no RouteLimit imposes none on its members (bgpd
skips the check when the struct is absent), yet the first warning-only or
threshold edit created the struct with the thrift default max_routes 12000,
a hard cap with session teardown the operator never asked for. The struct is
now seeded {max_routes 0, warning_only false, warning_limit 0} (0 = unlimited
in bgpd) and only the requested field changes; a rejected value leaves no
struct behind.

Attributes: add every remaining PeerGroup field bgpd resolves peer > group:
remove-private-as, enforce-first-as, route-refresh, ttl-security-hops
(1..255), link-bandwidth, advertise-lbw, receive-lbw -- same spellings and
validation as the neighbor command. Document the fields deliberately not
exposed because bgpd never reads them from a group (local_addr, next_hop4/6,
enabled, router_port_id, graceful_restart_end_of_rib_seconds).

bgp_json_to_cli.py: the peer-group generator covers the new attributes via
the shared tables, maps the deprecated i32 ASNs to the 4-byte attribute, and
emits a `# WARNING` line (script + stderr) for any field with no CLI
equivalent instead of dropping it. test_complete_peer_group_loses_no_field
now asserts 36 commands.
…y as-path-list

Adds the first BGP policy object-type command family, under a new `policy`
grouping node beneath `protocol bgp` (sibling to global/neighbor/peer-group):

  config protocol bgp policy as-path-list <name> [description <string>]
  delete protocol bgp policy as-path-list <name>

The list's `entry <seq-num>` level is a CLI11 subcommand of its own and
lands in the next commit, so this one owns only the list level.

- Follows the dispatcher shape the neighbor/peer-group families use: one
  factory per value shape from the shared BgpCliAttrHandlers.h, named
  setters that do nothing but assign the thrift field, and a registry that
  is one line per attribute. Writes bgp_policy.BgpPolicies.aspath_lists[]
  through the typed ConfigSession — no new session plumbing, since
  BgpConfig.policies already exists.
- Lookup/create helpers live in BgpAsPathListCliUtils.h, including the
  entry-level helpers, so the delete command and the entry subcommand in
  the next commit share them rather than re-deriving the scan.
- A rejected value leaves nothing staged: a list implicitly created for the
  failed command is rolled back before returning.
- There is no per-entry delete; `delete ... as-path-list <name>` removes the
  whole list.

- unit tests (10): CmdConfigBgpPolicyAsPathListTest (6) covering arg
  validation, bare create, the description round-trip, named lists staying
  distinct, re-reference reporting the existing list and unknown-attribute
  rejection, plus CmdDeleteBgpPolicyAsPathListTest (4).
- integration tests (2): ConfigBgpPolicyAsPathListTest stages and commits,
  then asserts against bgpd's running config via the getRunningConfig RPC,
  confirming bgpd accepts and adopts the .policies blob end to end.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Deleting an as-path-list that a routing-policy term still names committed a
dangling as_path_list_names reference; bgpd fails the config load on it and
crash-loops. The whole-list delete now refuses and names every referencing
`policy <P> term <seq>`, the same rule the peer-group delete applies to
neighbors. findTermsReferencingAsPathList lives in BgpAsPathListCliUtils.h
because the boolean-operator setter uses the same walk.

The list gained the two fields bgpd actually matches on: `regex <regex>`
appends one boost::regex to as_paths (compiled here so a pattern bgpd would
reject at load never reaches the session; whitespace is refused since bgpd
renders the AS path `_`-joined), and `boolean-operator <AND|OR>` (NOT is not
offered: bgpd treats anything but OR as AND). The operator is written through
to every referencing term's inline copy, which bgpd requires to agree with the
list ("Conflicting boolean_operator"). `delete ... as-path-list <name> regex
<regex>` removes a single pattern and is allowed on a referenced list.

Adds boost_regex to the fboss2 config lib (BUCK: boost_regex; cmake:
Boost::regex, regex component) and the unit/integration coverage for each
path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
bgp_json_to_cli.py rebuilt global, peer-group and peer settings only; every
policy object in the input was dropped, so a replayed script could commit
peers naming policies that no longer exist. This adds
generate_as_path_list_commands (description, one `regex` line per as_paths
pattern, `boolean-operator` when not the OR default) and a
generate_policy_commands block that the nested families hook into.

`--raw` and the script wrapper now share one generate_commands sequence:
global, policy objects, then the peer-groups and peers that reference them,
so the emitted order never stages a dangling name. Fields the CLI cannot
express (as_path_list_names, the unread as_path_list entries, NOT) are
emitted as `# WARNING:` comment lines, which the script wrapper passes
through unprefixed instead of silently dropping the data.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…bcommand

Splits the `entry` level of `config protocol bgp policy as-path-list` into
its own CLI11 subcommand. The previous commit ships the list level; this one
ships everything keyed by `entry <seq-num>`:

  as-path-list <name> entry <seq-num>
    -> AsPathList.as_path_list[], keyed by sequence_number
  as-path-list <name> entry <seq-num> asn-regexp <regex>
    -> AsPathListEntry.as_path.as_path.asn_regexp
  as-path-list <name> entry <seq-num> description <string>
    -> AsPathListEntry.description
  as-path-list <name> entry <seq-num> match-logic <EQUAL|NOT_EQUAL>
    -> AsPathListEntry.match_logic_type

- `entry` is a real CLI11 subcommand rather than tokens parsed inside the
  parent's arg type: the list name arrives through the ancestor-args tuple,
  and lookup/create is shared with the parent through
  BgpAsPathListCliUtils.h. Adding an entry attribute is a one-line registry
  change, same as at the list level.
- A list attribute typed alongside `entry` is rejected rather than silently
  dropped, because only the leaf command runs.
- asn-regexp sets the AsPathType union's inline AsPath arm. The pattern may
  contain spaces, since AS-path regexes separate ASNs with spaces
  (e.g. `^65000 65001$`), so it takes the joined-string value shape rather
  than requiring a single token.
- A rejected value leaves nothing staged: a list or entry implicitly created
  for the failed command is rolled back.

- unit tests (10): CmdConfigBgpPolicyAsPathListEntryTest covering arg
  validation, bare entry create, attribute round-trips, seq-num keying,
  asn-regexp accepting spaces, the match-logic default, and the rejection
  paths.
- integration tests (2): ConfigBgpPolicyAsPathListEntryTest stages and
  commits each attribute, then reads it back out of bgpd's running config
  via the getRunningConfig RPC. Enums come back over SimpleJSON as
  integers, so match_logic_type is asserted as MatchValueLogicOperator's
  numeric value rather than its name.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…y community-list

Adds `config protocol bgp policy community-list <name> [community <name>]
[<attribute> <value> ...]` and `delete protocol bgp policy community-list
<name>` — the second BGP policy object-type command family, beneath the
`policy` grouping node alongside as-path-list.

- community-list dispatcher with a two-level key (list name + inline
  community member name) writing bgp_policy.BgpPolicies.community_lists[]
  through the typed ConfigSession; boolean-operator maps to
  routing_policy.BooleanOperator, exact-match to the optional bool, and
  the member attributes (description/type/value) set the CommunityRefType
  union's inline Community arm, keyed by Community.name.
- new boolAttr factory in the shared BgpCliAttrHandlers.h (generalizing
  the neighbor dispatcher's), reused by upcoming prefix-list.
- fix a latent dangling-string_view in the shared enumAttr factory: the
  lambda captured a string_view over the caller's fmt::format temporary,
  so every invalid-enum-value rejection printed garbage after
  "expected". valueDesc is now taken (and captured) by value; the
  as-path-list and community-list rejection tests pin the full message.
- unit tests (19) + commit-path integration tests mirroring
  ConfigBgpPolicyAsPathListTest (not yet run on a DUT).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds generate_community_list_commands (description, boolean-operator when not
the OR default, exact-match) and hooks it into the policy block after the
as-path-lists. The deprecated inline `communities` and `community_list_names`
have no CLI spelling and are emitted as `# WARNING:` lines. Members follow in
the community subcommand change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ity subcommand

Splits the `community` (inline member) level of `config protocol bgp policy
community-list` into its own CLI11 subcommand, mirroring
`as-path-list <name> entry <seq-num>`. The previous commit ships the list
level and the whole delete command; this one ships the member level of the
config command:

  community-list <name> community <name>
    -> members[] inline Community, keyed by name
  community-list <name> community <name> value <string>
    -> Community.value
  community-list <name> community <name> type <NORMAL|EXTENDED|LARGE>
    -> Community.type
  community-list <name> community <name> description <string>
    -> Community.description

- The member is selected through the CommunityRefType union's inline arm.
  The list name arrives through the ancestor-args tuple, and lookup/create
  is shared with the parent through BgpCommunityListCliUtils.h.
- A list attribute typed alongside `community` is rejected rather than
  silently dropped, because only the leaf command runs.
- `delete ... community-list <name> community <name>` already ships in the
  previous commit and is untouched here: delete is a single dispatcher that
  handles both levels through parseListMemberSelector(), so it did not need
  splitting.
- A rejected value leaves nothing staged: a list or member implicitly
  created for the failed command is rolled back.

- unit tests (9): CmdConfigBgpPolicyCommunityListCommunityTest covering arg
  validation, bare member create, the three member attributes, named
  members staying distinct, and the rejection paths.
- integration tests (2): ConfigBgpPolicyCommunityListCommunityTest stages
  and commits, then verifies through bgpd's getRunningConfig RPC, including
  that the list and a sibling member survive a single-member delete.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Each inline `community` member of a community-list becomes
`... community-list <name> community <name> {description|type|value}` lines,
emitted inside the list generator right after the list attributes. A
`community_name` reference member has no CLI spelling and is emitted as a
`# WARNING:` line.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hillol-nexthop
hillol-nexthop force-pushed the bgp-policy-community-list-community branch from f49a347 to 85446b4 Compare September 15, 2026 17:37
@hillol-nexthop
hillol-nexthop deleted the bgp-policy-community-list-community branch September 16, 2026 10:42
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.

1 participant