Skip to content

Commit

Permalink
[YANG MODEL] SONiC Yang support for VXLAN (#7294)
Browse files Browse the repository at this point in the history
Why I did it
SONiC Yang support for VXLAN

How I did it
Added a new sonic-vxlan.yang file.
Please refer to EVPN VXLAN HLD for DB details
https://github.com/Azure/SONiC/tree/master/doc/vxlan/EVPN

How to verify it
Added tests for sonic vxlan yang.
  • Loading branch information
srj102 authored Jul 8, 2022
1 parent f788072 commit 3ba5cdc
Show file tree
Hide file tree
Showing 7 changed files with 335 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Table of Contents
* [Versions](#versions)
* [VLAN](#vlan)
* [VLAN_MEMBER](#vlan_member)
* [VXLAN](#vxlan)
* [Virtual router](#virtual-router)
* [WRED_PROFILE](#wred_profile)
* [PASSWORD_HARDENING](#password_hardening)
Expand Down Expand Up @@ -1460,6 +1461,37 @@ channel name as object key, and tagging mode as attributes.
}
```

### VXLAN

VXLAN_TUNNEL holds the VTEP source ip configuration.
VXLAN_TUNNEL_MAP holds the vlan to vni and vni to vlan mapping configuration.
VXLAN_EVPN_NVO holds the VXLAN_TUNNEL object to be used for BGP-EVPN discovered tunnels.

```
{
"VXLAN_TUNNEL": {
"vtep1": {
"src_ip": "10.10.10.10"
}
}
"VXLAN_TUNNEL_MAP" : {
"vtep1|map_1000_Vlan100": {
"vni": "1000",
"vlan": "100"
},
"vtep1|testmap": {
"vni": "22000",
"vlan": "70"
},
}
"VXLAN_EVPN_NVO": {
"nvo1": {
"source_vtep": "vtep1"
}
}
}
```

### Virtual router

The virtual router table allows to insert or update a new virtual router
Expand Down
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,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 @@ -332,6 +332,12 @@
}
},
"VLAN": {
"Vlan100": {
"description": "vxlan",
"vlanid": "100",
"mtu": "9216",
"admin_status": "up"
},
"Vlan111": {
"description": "svlan",
"dhcp_servers": [
Expand Down Expand Up @@ -1703,7 +1709,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
17 changes: 17 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,17 @@
{
"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_OOR_VNI": {
"desc": "VNI Out of Range in VXLAN_TUNNEL_MAP TABLE",
"eStrKey": "Range"
}
}
129 changes: 129 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,129 @@
{
"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_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": {
"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"
}
]
}
}
}
}
126 changes: 126 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,126 @@
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;
}
// Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference.
//import sonic-vlan {
// 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;
}
}

leaf src_ip {
type inet:ipv4-address;
}
}
}

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;
// Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern
// type leafref {
// path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name";
//}
type string {
pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])';
}

}

leaf vni {
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;

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 @@ -262,6 +262,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

0 comments on commit 3ba5cdc

Please sign in to comment.