-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Yang] Add Yang Model and tests for VNET_ROUTE table #24995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
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 adds a YANG model and comprehensive test suite for the VNET_ROUTE table to provide schema validation for VNET route configurations. The VNET_ROUTE table uses a composite key of vnet_name and prefix, with mandatory nexthop and ifname attributes.
Key changes:
- Added VNET_ROUTE container and list definition to sonic-vnet.yang with validation for nexthop IP and interface name fields
- Added six test cases covering valid configurations, multiple routes, and various error conditions (missing fields, invalid values, duplicates)
- Updated documentation with VNET_ROUTE table description and examples
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/sonic-yang-models/yang-models/sonic-vnet.yang | Defines VNET_ROUTE table schema with composite key (vnet_name, prefix) and mandatory nexthop/ifname fields |
| src/sonic-yang-models/tests/yang_model_tests/tests_config/vnet.json | Adds test data for valid and invalid VNET_ROUTE configurations |
| src/sonic-yang-models/tests/yang_model_tests/tests/vnet.json | Defines test case descriptions and expected validation errors |
| src/sonic-yang-models/tests/files/sample_config_db.json | Adds sample VNET_ROUTE configuration entry |
| src/sonic-yang-models/doc/Configuration.md | Documents VNET_ROUTE table schema with examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "VXLAN_TUNNEL_LIST": [ | ||
| { | ||
| "name": "vtep1", | ||
| "src_ip": "256.256.256.256" |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test includes an invalid IP address (256.256.256.256) for the VXLAN_TUNNEL src_ip, which would cause the test to fail before validating the VNET_ROUTE nexthop. To properly test invalid nexthop validation in VNET_ROUTE, the VXLAN_TUNNEL configuration should use a valid src_ip value.
| "src_ip": "256.256.256.256" | |
| "src_ip": "1.2.3.4" |
| "VNET_ROUTE_LIST": [ | ||
| { | ||
| "vnet_name": "Vnet1", | ||
| "nexthop":"100.100.1.1", | ||
| "ifname":"Ethernet0" | ||
| } | ||
| ] |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The VNET_ROUTE_LIST entry is missing the required "prefix" field which is part of the composite key (vnet_name|prefix) according to the YANG model definition. The prefix field should be added to match the schema, similar to how VNET_ROUTE_TUNNEL_LIST includes it.
| "VNET_ROUTE_LIST": [ | ||
| { | ||
| "vnet_name": "Vnet1", | ||
| "nexthop":"100.100.1.1", | ||
| "ifname":"Ethernet0" | ||
| }, | ||
| { | ||
| "vnet_name": "Vnet2", | ||
| "nexthop":"100.100.2.1", | ||
| "ifname":"Ethernet4" | ||
| } | ||
| ] |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both VNET_ROUTE_LIST entries are missing the required "prefix" field which is part of the composite key (vnet_name|prefix) according to the YANG model definition. Each entry should include a prefix field with an IPv4 prefix in CIDR format.
| { | ||
| "vnet_name": "Vnet1", | ||
| "ifname":"Ethernet0" | ||
| } |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The VNET_ROUTE_LIST entry is missing the required "prefix" field which is part of the composite key (vnet_name|prefix) according to the YANG model definition.
|
|
||
| VNET_ROUTE table has vnet_name|prefix as the object key, where vnet_name is the name of the VNet and prefix is the ip4 prefix associated with the vnet route. The table includes the following attributes: | ||
| - NEXTHOP: The nexthop IP (mandatory). It is used to identify the nexthop of the vnet route. | ||
| - IFNAME: The Interface name (mandatory). It should be a 12-hexadeimal digit value. |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description states that the Interface name "should be a 12-hexadeimal digit value," which is incorrect. The ifname field represents an interface name (like "Ethernet1" or "Ethernet2" as shown in the examples), not a hexadecimal value. This description should be corrected to accurately describe the interface name field.
| - IFNAME: The Interface name (mandatory). It should be a 12-hexadeimal digit value. | |
| - IFNAME: The interface name (mandatory), such as "Ethernet1". It identifies the outgoing interface for the vnet route. |
| } | ||
|
|
||
| leaf nexthop { | ||
| description "nexthop tunnel"; |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description "nexthop tunnel" is misleading. Based on the schema documentation and usage, this field represents the nexthop IP address for the VNET route, not a tunnel. The description should be updated to accurately reflect that this is the nexthop IP address.
| "VNET_ROUTE_LIST": [ | ||
| { | ||
| "vnet_name": "Vnet1", | ||
| "nexthop":"100.100.1.1", | ||
| "ifname":"Ethernet0" | ||
| }, | ||
| { | ||
| "vnet_name": "Vnet1", | ||
| "nexthop":"100.100.2.1", | ||
| "ifname":"Ethernet4" | ||
| } | ||
| ] |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both VNET_ROUTE_LIST entries are missing the required "prefix" field which is part of the composite key (vnet_name|prefix). Without different prefix values, these entries would be duplicate keys even if the test intends to test duplicate VNET names. Add unique prefix values to both entries.
| { | ||
| "vnet_name": "Vnet1", | ||
| "nexthop":"256.256.256.256", | ||
| "ifname":"Ethernet0" | ||
| } |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The VNET_ROUTE_LIST entry is missing the required "prefix" field which is part of the composite key (vnet_name|prefix) according to the YANG model definition.
| { | ||
| "vnet_name": "Vnet1", | ||
| "nexthop":"100.100.1.1" | ||
| } |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The VNET_ROUTE_LIST entry is missing the required "prefix" field which is part of the composite key (vnet_name|prefix) according to the YANG model definition.
| "desc": "Multiple VNET route configurations for different VNETs in VNET_ROUTE table." | ||
| }, | ||
| "VNET_ROUTE_TEST_DUPLICATE_NAME": { | ||
| "desc": "VNET route configuration with duplicate name keys in VNET_ROUTE table.", |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test description states "duplicate name keys" but this is ambiguous. The VNET_ROUTE_LIST has a composite key of "vnet_name" and "prefix". The test should clarify whether it's testing duplicate composite keys (vnet_name|prefix pairs) or just duplicate vnet_name values with different prefixes. Based on the test case name, it appears to be testing same vnet_name with different routes, which would require different prefix values to be valid.
| "desc": "VNET route configuration with duplicate name keys in VNET_ROUTE table.", | |
| "desc": "VNET route configuration with duplicate composite keys (same vnet_name and prefix) in VNET_ROUTE table.", |
Why I did it
Added YANG model and tests for VNET_ROUTE table to provide schema validation and testing capabilities for VNET route configurations.
Work item tracking
How I did it
Edit the existing sonic-vnet.yang model to define the VNET_ROUTE table schema
Added comprehensive test cases covering both valid and invalid configurations
Implemented validation for:
Mandatory nexthop field
Mandatory Interface name field
How to verify it
Review the YANG model against the config_db schema
Which release branch to backport (provide reason below if selected)
Tested branch (Please provide the tested image version)
Description for the changelog
Link to config_db schema for YANG module changes
https://github.com/prsunny/SONiC/blob/gh-pages/doc/vxlan/Vxlan_hld.md#21-config-db