Skip to content

[Yang] Add Yang Model and tests for VNET_ROUTE_TUNNEL table - v2#21939

Merged
qiluo-msft merged 24 commits intosonic-net:masterfrom
miatttao:mia-add-yang-new
Mar 11, 2025
Merged

[Yang] Add Yang Model and tests for VNET_ROUTE_TUNNEL table - v2#21939
qiluo-msft merged 24 commits intosonic-net:masterfrom
miatttao:mia-add-yang-new

Conversation

@miatttao
Copy link
Contributor

@miatttao miatttao commented Mar 5, 2025

Why I did it

Added YANG model and tests for VNET_ROUTE_TUNNEL table to provide schema validation and testing capabilities for VNET route tunnel configurations.

Work item tracking

How I did it

  • Edit the existing sonic-vnet.yang model to define the VNET_ROUTE_TUNNEL table schema
  • Added comprehensive test cases covering both valid and invalid configurations
  • Implemented validation for:
    • Mandatory endpoint field
    • MAC address format
    • VXLAN ID range
    • Name format (vnet_name:prefix)

How to verify it

  1. Review the YANG model against the config_db schema
  2. cd src/sonic-yang-models && python3 setup.py test
Test Cases Validated

image

Yang Model Validated (assertionError can be ignored)

image
image

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

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

Tested branch (Please provide the tested image version)

  • master of 202411

Description for the changelog

Link to config_db schema for YANG module changes

https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md/VNET_ROUTE_TUNNEL

Note Anish's note

Today, we do not use ipv6 prefixes so ipv4 only is fine, in the future if we need to support ipv6 prefix we will need to look into including ipv6 prefix stype here. Same comment on supporting ipv6 endpoints.

@miatttao miatttao requested a review from qiluo-msft as a code owner March 5, 2025 18:22
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 5, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@miatttao miatttao requested a review from anish-n March 7, 2025 22:10
@miatttao
Copy link
Contributor Author

miatttao commented Mar 7, 2025

03/07 a0be257 passed all pipeline checks.
Changed ip_address type

type yang:mac-address;
}

leaf vxlanid {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you change this to vni. Upon checking sonic-swss I see that this should be called vni:
https://github.com/sonic-net/sonic-swss/blob/master/orchagent/vnetorch.cpp#L2733

@prsunny should we update the HLD https://github.com/sonic-net/SONiC/blob/gh-pages/doc/vxlan/Vxlan_hld.md to say that the tunnel route field is vni vs vxlandid?
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Anish, for a specific vnet_route_tunnel, can the vni in VNET_ROUTE_TABLE overwrite the base vni in VNET_TABLE? Or do they have to be the same? See below for reference. Thanks!

image
image

Copy link
Contributor

Choose a reason for hiding this comment

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

The vni in VNET_ROUTE_TUNNEL_TABLE overrides the base vni in VNET_TABLE for any traffic destined to the IP of prefix in VNET_ROUTE_TUNNEL_TABLE. It is also an optional field, so if none is provided the default VNET_TABLE vni is used for the traffic.

Copy link
Contributor

Choose a reason for hiding this comment

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

agree Anish. good to update HLD

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, will raise a PR!

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@miatttao miatttao requested a review from anish-n March 10, 2025 15:11
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@prsunny prsunny left a comment

Choose a reason for hiding this comment

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

lgtm


leaf prefix {
description "IPv4 prefix in CIDR format";
type stypes:sonic-ip4-prefix;
Copy link
Contributor

@anish-n anish-n Mar 10, 2025

Choose a reason for hiding this comment

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

Today, we do not use ipv6 prefixes so ipv4 only is fine, in the future if we need to support ipv6 prefix we will need to look into including ipv6 prefix stype here. Same comment on supporting ipv6 endpoints.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you Anish! I will make a note of this.

@miatttao
Copy link
Contributor Author

Checked the testbed failures due to infra issue, not related to code.

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@qiluo-msft qiluo-msft merged commit c0c89c4 into sonic-net:master Mar 11, 2025
21 checks passed
miatttao added a commit to miatttao/SONiC that referenced this pull request Mar 18, 2025
Follow manager's suggestion mentioned during the VNET_ROUTE_TUNNEL PR review.

See: sonic-net/sonic-buildimage#21939 (comment)
@liuh-80
Copy link
Contributor

liuh-80 commented Apr 9, 2025

@miatttao , https://github.com/sonic-net/sonic-gnmi repo PR validation break after March 14, seems related with change in this PR, can you check?

HEAD is now at 4607fd1 Merge pull request #54 from openconfig/fix-lists-no-sibling-check
touch ../../build/oc-community-linter/.done
Writing sonic-acl.yang
Writing sonic-show-techsupport.yang

Copy sonic yangs specified in SONICYANG_IMPORTS, from SONICYANG_IMPORT_DIR

../../tools/pyang/import_yang.py
--from=/usr/local/cvlyang-models --from common
--to=../../build/yang/sonic

sonic-interface.yang sonic-port.yang sonic-portchannel.yang sonic-sflow.yang
error: sonic-interface:29: module "sonic-vnet" not found in search path
make[2]: *** [Makefile:187: ../../build/yang/.sync_sonic_yangs] Error 1
make[2]: Leaving directory '/__w/1/s/sonic-mgmt-common/models/yang'
make[1]: *** [Makefile:70: models] Error 2

@miatttao
Copy link
Contributor Author

miatttao commented Apr 9, 2025

@miatttao , https://github.com/sonic-net/sonic-gnmi repo PR validation break after March 14, seems related with change in this PR, can you check?

HEAD is now at 4607fd1 Merge pull request #54 from openconfig/fix-lists-no-sibling-check touch ../../build/oc-community-linter/.done Writing sonic-acl.yang Writing sonic-show-techsupport.yang

Copy sonic yangs specified in SONICYANG_IMPORTS, from SONICYANG_IMPORT_DIR

../../tools/pyang/import_yang.py --from=/usr/local/cvlyang-models --from common --to=../../build/yang/sonic sonic-interface.yang sonic-port.yang sonic-portchannel.yang sonic-sflow.yang error: sonic-interface:29: module "sonic-vnet" not found in search path make[2]: *** [Makefile:187: ../../build/yang/.sync_sonic_yangs] Error 1 make[2]: Leaving directory '/__w/1/s/sonic-mgmt-common/models/yang' make[1]: *** [Makefile:70: models] Error 2

Hi @liuh-80,

Thanks for pointing this out!

Could you please clarify the exact commands used for your build? Are they run within the sonic-gnmi repo or the sonic-buildimage repo?

Also, if possible, could you share a link to the relevant pipeline or job?
I’m asking because my changes passed all validations in the sonic-buildimage repo, so I’d like to better understand the environment where it’s failing.

@miatttao
Copy link
Contributor Author

@miatttao , https://github.com/sonic-net/sonic-gnmi repo PR validation break after March 14, seems related with change in this PR, can you check?
HEAD is now at 4607fd1 Merge pull request #54 from openconfig/fix-lists-no-sibling-check touch ../../build/oc-community-linter/.done Writing sonic-acl.yang Writing sonic-show-techsupport.yang

Copy sonic yangs specified in SONICYANG_IMPORTS, from SONICYANG_IMPORT_DIR

../../tools/pyang/import_yang.py --from=/usr/local/cvlyang-models --from common --to=../../build/yang/sonic sonic-interface.yang sonic-port.yang sonic-portchannel.yang sonic-sflow.yang error: sonic-interface:29: module "sonic-vnet" not found in search path make[2]: *** [Makefile:187: ../../build/yang/.sync_sonic_yangs] Error 1 make[2]: Leaving directory '/__w/1/s/sonic-mgmt-common/models/yang' make[1]: *** [Makefile:70: models] Error 2

Hi @liuh-80,

Thanks for pointing this out!

Could you please clarify the exact commands used for your build? Are they run within the sonic-gnmi repo or the sonic-buildimage repo?

Also, if possible, could you share a link to the relevant pipeline or job? I’m asking because my changes passed all validations in the sonic-buildimage repo, so I’d like to better understand the environment where it’s failing.

I have some clues now.

  1. I found a file here: https://github.com/sonic-net/sonic-mgmt-common/blob/master/cvl/testdata/schema/sonic-interface.yang. May I kindly ask whether I need to update the sonic-interface.yang file here based on this PR's changes? Do the new changes for YANG model in sonic-buildimage always have to be synchronous with the yang models in sonic-mgmt-common/cvl/testdata/schema/?
  2. The missing import of sonic-vnet in sonic-mgmt-common/models/yang/sonic/import.mk might be the root cause.

@wen587
Copy link
Contributor

wen587 commented Sep 26, 2025

Hi @miatttao , seems VNET_ROUTE table is also missing YANG could you help?
#24136

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.

7 participants