Skip to content

Make the BGP multipath limits of the SONiC default VRF configurable - #2947

Draft
berendt wants to merge 3 commits into
mainfrom
implement/issue-2559-bgp-multipath-limits
Draft

berendt wants to merge 3 commits into
mainfrom
implement/issue-2559-bgp-multipath-limits

Conversation

@berendt

@berendt berendt commented Nov 28, 2026

Copy link
Copy Markdown
Member

Closes #2559

The SONiC config generator no longer pins max_ebgp_paths and max_ibgp_paths of default|ipv4_unicast and default|ipv6_unicast to "2". Each field resolves per device and on its own, first valid value wins:

  1. sonic_parameters.max_ebgp_paths / max_ibgp_paths in the device's custom fields
  2. _segment_bgp_max_ebgp_paths / _segment_bgp_max_ibgp_paths in its config context
  3. SONIC_BGP_MAX_PATHS in the conductor environment (new, shared by both fields)
  4. the built-in DEFAULT_BGP_MAX_PATHS = 2

A valid value is an int (not a bool) or a digit string from 1 to 256, the range sonic-bgp-global.yang gives both fields. An invalid value is skipped with a warning naming its source and the device. A missing or null one is skipped silently. A device that sets nothing generates the same config as before. default|l2vpn_evpn and the per-VRF address families are unchanged.

Commits

  1. Add the SONIC_BGP_MAX_PATHS setting: a string setting in osism/settings.py, deliberately not wrapped in int(), so a typo cannot fail the import for every osism process. Tests: test_sonic_bgp_max_paths_default, test_sonic_bgp_max_paths_override.
  2. Resolve the BGP multipath limits of the SONiC default VRF per device: removes the four literals from DEFAULT_VRF_BGP_GLOBALS_AF, and adds the BGP_MAX_PATHS_* / DEFAULT_VRF_MULTIPATH_AFS constants and _parse_bgp_max_paths / _get_bgp_max_paths. _add_default_vrf_configuration merges the resolved pair into both unicast families, still assigning per key. Tests: the new test_config_generator_multipath.py (53 cases), test_vrf_ipv4_unicast_limits_ignore_conductor_setting, and a subset assertion in test_generate_sonic_config_default_vrf_entries_match_policy_constants.
  3. Cover the BGP multipath limits in the SONiC E2E scenario: e2e-segment sets _segment_bgp_max_ebgp_paths: 4, and e2e-leaf-2 sets max_ebgp_paths: 8 / max_ibgp_paths: 4. The goldens were regenerated from a fresh stack (make sonic-e2e-down && make sonic-e2e-regen). They change in exactly the 20 lines the issue lists (9 files, max_ebgp_paths "4", and on leaf-2 "8" / "4"). VrfStorage|ipv4_unicast is untouched.

Notes for review

  • The one assertion this PR changes is in test_generate_sonic_config_default_vrf_entries_match_policy_constants. It goes from equality to af_attributes.items() <= ...items(), as the issue prescribes: the unicast constants no longer carry the two fields, so equality cannot hold. test_generate_sonic_config_emits_default_vrf_entries_without_vni_vrfs still pins the literal "2" values and is unedited.
  • Deviations from the approved plan:
    • test_get_bgp_max_paths_logs_source_at_debug is parametrized over the device and the segment source. The issue lists only the device case, but its criterion names both.
    • test_get_bgp_max_paths_falls_back_to_builtin_default also asserts that no WARNING is logged, since the "absent inputs" criterion cites it.
    • Local environment only (no effect on the diff): the tool venvs were built with uv because the machine's python3 lacks ensurepip, and the E2E runs used their own pipenv venv, so the unit-test venv stayed as CI builds it (no ansible-core).
  • Declined questions: none.

Verification

Run locally on 1323a3a0:

  • pipenv run pytest tests/unit: 4285 passed, 3 xfailed (main baseline: 4229 passed, same 3 xfailed)
  • pipenv run pytest tests/unit/tasks/conductor/sonic/test_validator_artifacts.py: 11 passed, every golden validates
  • grep -c '"max_[ei]bgp_paths": "' osism/tasks/conductor/sonic/config_generator.py: 2 (the per-VRF literals only)
  • git diff --stat origin/main -- tests/e2e/golden/: 9 files changed, 20 insertions(+), 20 deletions(-)
  • make sonic-e2e, cold, against the committed goldens: >>> SONiC E2E golden test passed.
  • At the CI jobs' pinned versions: black==26.10.1 --check . (252 files unchanged), flake8==7.5.0 on every changed .py file (clean), mypy==1.20.2 --ignore-missing-imports --install-types --non-interactive . (no issues in 251 files)

Not exercised here: the Zuul check jobs flake8, python-black, mypy, and python-osism-sonic-e2e themselves. They run on this pull request. Locally, the seeding tool came from a netbox-manager checkout on its bump-dependencies branch, while the job uses netbox-manager's main.

Noticed but not touching

🤖 Generated with Claude Code

Conductor-wide default for max_ebgp_paths and max_ibgp_paths in the IPv4
and IPv6 unicast address families of the SONiC default VRF. It is kept as
a string, not wrapped in int(), so a typo cannot fail the import of
osism.settings for every osism process; the SONiC config generator
validates it and falls back to 2.

Part of #2559.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Berendt <berendt@b42labs.com>
The generator pinned max_ebgp_paths and max_ibgp_paths of
default|ipv4_unicast and default|ipv6_unicast to 2, so a leaf with more
than two uplinks installed only two equal-cost paths.

Each field now resolves on its own, first valid value wins:
sonic_parameters.max_ebgp_paths / max_ibgp_paths on the device, then
_segment_bgp_max_ebgp_paths / _segment_bgp_max_ibgp_paths in its config
context, then SONIC_BGP_MAX_PATHS, then the built-in 2. A valid value is an
int (not a bool) or a digit string from 1 to 256, the range of
sonic-bgp-global.yang. An invalid value is skipped with a warning; a
missing or null one is skipped silently. A device that sets nothing
generates the same config as before. l2vpn_evpn and the per-VRF address
families are unchanged.

Part of #2559.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Berendt <berendt@b42labs.com>
The e2e-segment config context sets _segment_bgp_max_ebgp_paths to 4, so
every fixture device shows the segment default for max_ebgp_paths and the
built-in 2 for max_ibgp_paths. e2e-leaf-2 sets max_ebgp_paths 8 and
max_ibgp_paths 4 in sonic_parameters, proving the per-device override over
the segment value and over the fallback.

The goldens were regenerated from a fresh stack with make sonic-e2e-down
and make sonic-e2e-regen; they change in the default-VRF unicast address
families only (9 files, 20 lines).

Part of #2559.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Berendt <berendt@b42labs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Make the BGP multipath limits of the SONiC default VRF configurable

1 participant