Skip to content

[sonic-yang-models]: Add VNet name support to BGP_NEIGHBOR YANG model#28566

Open
miatttao wants to merge 2 commits into
sonic-net:masterfrom
miatttao:dev/mia/bgp-neighbor-vnet-support
Open

[sonic-yang-models]: Add VNet name support to BGP_NEIGHBOR YANG model#28566
miatttao wants to merge 2 commits into
sonic-net:masterfrom
miatttao:dev/mia/bgp-neighbor-vnet-support

Conversation

@miatttao

@miatttao miatttao commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Why I did it

The BGP_NEIGHBOR YANG model only accepted a VRF name (referencing BGP_GLOBALS) as the first key component. This prevented creating BGP neighbor configurations scoped to a VNet, such as BGP_NEIGHBOR|Vnet1|10.0.0.0, which is needed for overlay BGP sessions over VxLAN tunnels.

Work item tracking
  • Microsoft ADO (number only):

How I did it

Changed the vrf_name leaf type in BGP_NEIGHBOR_LIST and BGP_NEIGHBOR_AF_LIST from a plain leafref to a union of two leafref types — one pointing to BGP_GLOBALS_LIST (existing VRF path) and one pointing to VNET_LIST (new VNet path). This follows the identical pattern already used in sonic-bgp-peerrange for the same requirement.

Files changed:

  • yang-models/sonic-bgp-neighbor.yang — import sonic-vnet, change vrf_name to union
    leafref in both BGP_NEIGHBOR_LIST and BGP_NEIGHBOR_AF_LIST
  • doc/Configuration.md — document VNet key format and add example
  • tests/files/sample_config_db.json — add Vnet55|10.0.0.0 BGP_NEIGHBOR and
    BGP_NEIGHBOR_AF entries
  • tests/yang_model_tests/tests/bgp.json — add BGP_NEIGHBOR_VNET_VALID and
    BGP_NEIGHBOR_NEG_VNET_NOT_EXIST test descriptors
  • tests/yang_model_tests/tests_config/bgp.json — add full test data for both new cases

How to verify it

Run the existing YANG model tests:

cd src/sonic-yang-models
python3 -m pytest tests/yang_model_tests/test_yang_model.py -v -k "BGP_NEIGHBOR"

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202506

Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO):
Failure type:

Tested branch

  • master
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202512
  • 202605
  • 202608
  • N/A

Test result

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Copilot AI review requested due to automatic review settings July 22, 2026 04:30
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the sonic-bgp-neighbor YANG model so BGP_NEIGHBOR/BGP_NEIGHBOR_AF entries can be keyed by either a VRF (via BGP_GLOBALS) or a VNet (via VNET), enabling overlay BGP neighbor configurations like BGP_NEIGHBOR|Vnet1|10.0.0.0.

Changes:

  • Updated sonic-bgp-neighbor.yang to allow vrf_name to be a union of VRF and VNet leafrefs.
  • Added new YANG-model test cases (valid VNet neighbor + negative non-existent VNet).
  • Updated docs and sample config DB to include VNet-scoped BGP neighbor examples.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang Adds sonic-vnet import and changes vrf_name to a union of VRF/VNet leafrefs.
src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json Adds descriptors for the new VNet neighbor positive/negative tests.
src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json Adds test configs for VNet neighbor cases (but currently introduces an invalid JSON structure that must be fixed).
src/sonic-yang-models/tests/files/sample_config_db.json Adds sample BGP_NEIGHBOR/BGP_NEIGHBOR_AF entries under a VNet key (but one boolean value encoding needs to match Config DB conventions).
src/sonic-yang-models/doc/Configuration.md Documents VNet key usage for BGP_NEIGHBOR and adds an example (example formatting/consistency needs follow-up).

Comment thread src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json
Comment thread src/sonic-yang-models/tests/files/sample_config_db.json Outdated
Comment thread src/sonic-yang-models/doc/Configuration.md Outdated
Signed-off-by: miatao <miatao@microsoft.com>
Copilot AI review requested due to automatic review settings July 22, 2026 18:51
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines +555 to 561
"Vnet1|10.0.0.0": {
"asn": 65100,
"name": "overlay-peer",
"admin_status": "up"
}

"BGP_PEER_RANGE": {
@mssonicbld

Copy link
Copy Markdown
Collaborator

This PR has backport request for branch(es): 202506.
Added label(s) for branch(es) msft-202506.

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

This PR has backport request label(s) for branch(es): msft-202506, but is missing required test information. Please make sure you tick the tested branch(es) in the Tested branch section and provide test evidence (e.g., 202506: <test result>) in the Test result section as well in your PR description.

---Powered by SONiC BuildBot

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.

3 participants