Skip to content

Conversation

@alawing
Copy link

@alawing alawing commented Jan 7, 2026

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)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Tested branch (Please provide the tested image version)

  • 202511

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

@alawing alawing requested a review from qiluo-msft as a code owner January 7, 2026 18:17
Copilot AI review requested due to automatic review settings January 7, 2026 18:17
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

Copilot AI left a 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"
Copy link

Copilot AI Jan 7, 2026

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.

Suggested change
"src_ip": "256.256.256.256"
"src_ip": "1.2.3.4"

Copilot uses AI. Check for mistakes.
Comment on lines +207 to +213
"VNET_ROUTE_LIST": [
{
"vnet_name": "Vnet1",
"nexthop":"100.100.1.1",
"ifname":"Ethernet0"
}
]
Copy link

Copilot AI Jan 7, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +247 to +258
"VNET_ROUTE_LIST": [
{
"vnet_name": "Vnet1",
"nexthop":"100.100.1.1",
"ifname":"Ethernet0"
},
{
"vnet_name": "Vnet2",
"nexthop":"100.100.2.1",
"ifname":"Ethernet4"
}
]
Copy link

Copilot AI Jan 7, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +368 to +371
{
"vnet_name": "Vnet1",
"ifname":"Ethernet0"
}
Copy link

Copilot AI Jan 7, 2026

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.

Copilot uses AI. Check for mistakes.

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.
Copy link

Copilot AI Jan 7, 2026

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.

Suggested change
- 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.

Copilot uses AI. Check for mistakes.
}

leaf nexthop {
description "nexthop tunnel";
Copy link

Copilot AI Jan 7, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +292 to +303
"VNET_ROUTE_LIST": [
{
"vnet_name": "Vnet1",
"nexthop":"100.100.1.1",
"ifname":"Ethernet0"
},
{
"vnet_name": "Vnet1",
"nexthop":"100.100.2.1",
"ifname":"Ethernet4"
}
]
Copy link

Copilot AI Jan 7, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +333 to +337
{
"vnet_name": "Vnet1",
"nexthop":"256.256.256.256",
"ifname":"Ethernet0"
}
Copy link

Copilot AI Jan 7, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +402 to +405
{
"vnet_name": "Vnet1",
"nexthop":"100.100.1.1"
}
Copy link

Copilot AI Jan 7, 2026

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.

Copilot uses AI. Check for mistakes.
"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.",
Copy link

Copilot AI Jan 7, 2026

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.

Suggested change
"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.",

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants