Closed
[bgp] Add bgpd.aggregate.conf.j2 bootstrap template and sonic-cfggen tests for BGP_AGGREGATE_ADDRESS rendering#28635
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. |
Collaborator
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
…BGP_AGGREGATE_ADDRESS rendering
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Copilot
AI
changed the title
[WIP] Fix code for review comment and add unit tests
[bgp] Add bgpd.aggregate.conf.j2 bootstrap template and sonic-cfggen tests for BGP_AGGREGATE_ADDRESS rendering
Jul 27, 2026
guangyao6
marked this pull request as ready for review
July 27, 2026 10:43
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
/azp run |
|
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list. |
Contributor
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the missing
bgpd.aggregate.conf.j2bootstrap template that rendersBGP_AGGREGATE_ADDRESSinto FRR config before any BGP sessions are established, closing the transient route-leak window on cold boot /restart bgp. Also adds the sonic-cfggen unit tests and test vectors that were flagged as missing in the PR review.Why I did it
On a T1 aggregation router,
AggregateAddressMgrinstalls suppression routes only at runtime after bgpd forms sessions. The stock bootstrapbgpd.confcarries no aggregate-address, so contributing more-specifics escape to T2 peers for the duration of the manager reconciliation window.Additionally, PR review requested focused cfggen tests covering the
BGP_AGGREGATE_ADDRESSrendering logic (strict-prefix validation, BBR gating, prefix-list generation) to prevent regressions.Work item tracking
How I did it
New template
dockers/docker-fpm-frr/frr/bgpd/bgpd.aggregate.conf.j2:BGP_AGGREGATE_ADDRESSrows from CONFIG_DB into bootstrapbgpd.confvalidate_prefix(strict=True))bbr-required=trueentries rendered only whenBGP_BBR|all status == "enabled"is explicitly present — deliberately does not consultconstants.ymldefault_state since peer-group existence cannot be verified at bootstrapmanagers_aggregate_address.py(generate_aggregate_address_commands()/generate_prefix_list_commands()) byte-for-byte so manager reconcile is a FRR no-opprefix-list seq >= 10to avoid collision withpolicy.conf.j2anchor atseq 5Updated
dockers/docker-fpm-frr/frr/bgpd/bgpd.conf.j2: includes the new template beforebgpd.main.conf.j2, guarded by{% if BGP_AGGREGATE_ADDRESS is defined %}— no output change when key is absent.New sonic-cfggen test vectors
src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.aggregate.conf.j2/:ipv4_basicipv4_with_prefix_listsbbr_required_enabledbbr_required_disabledNew test functions in
src/sonic-bgpcfgd/tests/test_sonic-cfggen.py:test_aggregate_conf_ipv4_basic— canonical file comparisontest_aggregate_conf_ipv4_with_prefix_lists— canonical file comparisontest_aggregate_conf_bbr_required_enabled— canonical file comparisontest_aggregate_conf_bbr_required_disabled— canonical file comparison (empty structural content)test_aggregate_conf_no_bbr_required_renders_regardless— assertion: non-BBR aggregate always renderedtest_aggregate_conf_bbr_gate_blocks_bbr_required_when_disabled— assertion: BBR gate suppressionHow to verify it
Run the sonic-cfggen test suite from
src/sonic-bgpcfgd/:pytest tests/test_sonic-cfggen.py -v -k "aggregate"Expected: all 6 new
test_aggregate_conf_*tests pass.To verify bootstrap behavior on a device with
BGP_AGGREGATE_ADDRESSin CONFIG_DB:systemctl restart bgp/etc/frr/bgpd.conf—aggregate-addressandprefix-listentries must be present before any session reaches Establishedbgpcfgdreconciles, confirmAggregateAddressMgrreconcile is a FRR no-op (no config churn invtysh)Which release branch to backport (provide reason below if selected)
Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO):
Failure type:
Tested branch
Test result
Description for the changelog
Render BGP_AGGREGATE_ADDRESS into bootstrap bgpd.conf via new bgpd.aggregate.conf.j2 template to eliminate transient route-leak window on BGP restart; add sonic-cfggen unit tests covering IPv4/IPv6 rendering, prefix-list generation, and BBR gate logic.
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)