Skip to content
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

[YANG MODEL] SONiC Yang support for VXLAN #7294

Merged
merged 15 commits into from
Jul 8, 2022
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def run(self):
'./yang-models/sonic-types.yang',
'./yang-models/sonic-versions.yang',
'./yang-models/sonic-vlan.yang',
'./yang-models/sonic-vxlan.yang',
'./yang-models/sonic-vrf.yang',
'./yang-models/sonic-mclag.yang',
'./yang-models/sonic-vlan-sub-interface.yang',
Expand Down
23 changes: 22 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@
}
},
"VLAN": {
"Vlan100": {
"description": "vxlan",
"vlanid": "100",
"mtu": "9216",
"admin_status": "up"
},
"Vlan111": {
"description": "svlan",
"dhcp_servers": [
Expand Down Expand Up @@ -1675,7 +1681,22 @@
"4": "4"
}
},

"VXLAN_TUNNEL": {
"vtep1": {
"src_ip": "1.2.3.4"
}
},
"VXLAN_EVPN_NVO": {
"nvo1": {
"source_vtep": "vtep1"
}
},
"VXLAN_TUNNEL_MAP": {
"vtep1|map_100_Vlan100": {
"vni" : "100",
"vlan": "Vlan100"
}
},
"PORT_QOS_MAP": {
"Ethernet0": {
"dot1p_to_tc_map" : "Dot1p_to_tc_map1",
Expand Down
21 changes: 21 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/vxlan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"VXLAN_VALID_TEST": {
"desc": "Valid VXLAN Configuration."
},
"VXLAN_EVPN_NVO_WITHOUT_VTEP": {
"desc": "Configure EVPN_NVO without VXLAN_TUNNEL entry",
"eStrKey" : "LeafRef"
},
"VXLAN_MAP_WITHOUT_VTEP": {
"desc": "Configure VXLAN_TUNNEL_MAP without VXLAN_TUNNEL entry",
"eStrKey" : "LeafRef"
},
"VXLAN_MAP_WITHOUT_VLAN": {
"desc": "Configure VXLAN_TUNNEL_MAP without VLAN entry",
"eStrKey" : "LeafRef"
},
"VXLAN_MAP_OOR_VNI": {
"desc": "VNI Out of Range in VXLAN_TUNNEL_MAP TABLE",
"eStrKey": "Range"
}
}
141 changes: 141 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/vxlan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"VXLAN_VALID_TEST": {
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [
{
"name": "Vlan100"
}
]
}
},
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "vtep1",
"src_ip": "1.2.3.4"
}
]
},
"sonic-vxlan:VXLAN_EVPN_NVO": {
"VXLAN_EVPN_NVO_LIST": [
{
"name": "nvo1",
"source_vtep": "vtep1"
}
]
},
"sonic-vxlan:VXLAN_TUNNEL_MAP": {
"VXLAN_TUNNEL_MAP_LIST": [
{
"name": "vtep1",
"mapname": "map_100_Vlan100",
"vlan": "Vlan100",
"vni": "100"
}
]
}
}
},
"VXLAN_VTEP_WRONG_NAME": {
srj102 marked this conversation as resolved.
Show resolved Hide resolved
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "tunnel1",
"src_ip": "1.2.3.4"
}
]
}
}
},
"VXLAN_EVPN_NVO_WITHOUT_VTEP": {
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_EVPN_NVO": {
"VXLAN_EVPN_NVO_LIST": [
{
"name": "nvo1",
"source_vtep": "vtep1"
}
]
}
}
},
"VXLAN_MAP_WITHOUT_VTEP": {
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [
{
"name": "Vlan100"
}
]
}
},
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL_MAP": {
"VXLAN_TUNNEL_MAP_LIST": [
{
"name": "vtep1",
"mapname": "map_100_Vlan100",
"vlan": "Vlan100",
"vni": "100"
}
]
}
}
},
"VXLAN_MAP_WITHOUT_VLAN": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see corresponding key in tests/vxlan.json. Can you please check and update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was removed in the last commit as the reference to vlan (import vlan) was failing the builds.
The intent is that this be re-added later once the import vlan is fixed. Hence it is being removed only in the
tests and not the tests_config.

"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "vtep1",
"src_ip": "1.2.3.4"
}
]
},
"sonic-vxlan:VXLAN_TUNNEL_MAP": {
"VXLAN_TUNNEL_MAP_LIST": [
{
"name": "vtep1",
"mapname": "map_100_Vlan100",
"vlan": "Vlan100",
"vni": "100"
}
]
}
}
},
"VXLAN_MAP_OOR_VNI": {
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [
{
"name": "Vlan100"
}
]
}
},
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "vtep1",
"src_ip": "1.2.3.4"
}
]
},
"sonic-vxlan:VXLAN_TUNNEL_MAP": {
"VXLAN_TUNNEL_MAP_LIST": [
{
"name": "vtep1",
"mapname": "map_100_Vlan100",
"vlan": "Vlan100",
"vni": "16777299"
}
]
}
}
}
}
121 changes: 121 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-vxlan.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
module sonic-vxlan {
yang-version 1.1;
namespace "http://github.com/Azure/sonic-vxlan";
prefix svxlan;

import ietf-yang-types {
prefix yang;
}

import ietf-inet-types {
prefix inet;
}

import sonic-extension {
prefix sonic-ext;
}
import sonic-vlan {
Copy link
Contributor

Choose a reason for hiding this comment

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

The tests are failing in Sonic-utils specifically GCU because of yang known issue: #9312

Please comment out sonic-vlan import and add a note

    // Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference.
    //import sonic-vlan {
    //    prefix vlan;
    //}

Copy link
Contributor

Choose a reason for hiding this comment

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

@qiluo-msft for viz

prefix svlan;
}
import sonic-types {
prefix stypes;
}


organization
"SONiC";

contact
"SONiC";

description
"SONIC VXLAN";

revision 2021-04-12 {
description
"First revision.";
}

container sonic-vxlan {

container VXLAN_TUNNEL {

description "config db VXLAN_TUNNEL table";

list VXLAN_TUNNEL_LIST {

key "name";
max-elements 1;

leaf name {
/* vni devices are created of the form 'name'-vlanid
The kernel has a max limit of 15 chars for netdevices.
keeping aside 5 chars for hyphen and vlanid the
name should have a max of 10 chars */

type string {
length 1..10;
Copy link
Collaborator

@qiluo-msft qiluo-msft Dec 9, 2021

Choose a reason for hiding this comment

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

1..10

Where is the limitation from? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for every vlan vni map a vni netdevice of form - is created.
The kernel devices can have a max length of 15 characters.
Keeping aside 5 characters for the "-" we are left with 10.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the detailed explanation! Could you also add it as code comment? the 10 is magic number here.

Copy link
Collaborator

@venkatmahalingam venkatmahalingam Jan 13, 2022

Choose a reason for hiding this comment

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

Using "-" is a must or the user can choose any letter after "vtep" prefix? if any character, please put max 15 chars.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The vni device format is -
Max vid is 4 characters and 1 for hyphen leaving us
with 10 characters for tunnelname.

Added a comment in the yang file for the same.

}
}

leaf src_ip {
type inet:ipv4-address;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we also have "dst_ip" in vxlan tunnel. Please update
VXLAN_TUNNEL|{{tunnel_name}}
"src_ip": {{ip_address}}
"dst_ip": {{ip_address}} (OPTIONAL)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont think, we support static vxlan tunnel yet, so dst_ip is not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The dst_ip is not handled here.
Even for non BGP P2P tunnel support the configuration will continue to have only the src_ip.

}

container VXLAN_TUNNEL_MAP {

description "config db VXLAN_TUNNEL_MAP table";

list VXLAN_TUNNEL_MAP_LIST {
key "name mapname";

leaf name {
type leafref {
path "/svxlan:sonic-vxlan/svxlan:VXLAN_TUNNEL/svxlan:VXLAN_TUNNEL_LIST/svxlan:name";
}
}

leaf mapname {
type string;
}

leaf vlan {
mandatory true;
type leafref {
path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name";
}

}

leaf vni {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add a common type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a common type

mandatory true;
type stypes:vnid_type;
}
}
}

container VXLAN_EVPN_NVO {

description "config db VXLAN_EVPN_NVO table";

list VXLAN_EVPN_NVO_LIST {

key "name";
max-elements 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We dont need the list if it's a single entry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For future expansion. It was recommended that we use the LIST and hence kept it so that the URIs dont have to change later on.


leaf name {
type string;
}

leaf source_vtep {
mandatory true;
type leafref {
path "/svxlan:sonic-vxlan/svxlan:VXLAN_TUNNEL/svxlan:VXLAN_TUNNEL_LIST/svxlan:name";
}
}
}
}
}
}
8 changes: 8 additions & 0 deletions src/sonic-yang-models/yang-templates/sonic-types.yang.j2
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ module sonic-types {
}
}

typedef vnid_type {
type uint32 {
range "1..16777215";
}
description
"VXLAN Network Identifier";
}

{% if yang_model_type == "cvl" %}
/* Required for CVL */
container operation {
Expand Down