diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 3d5bf91db542..817d8f1e884b 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -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) @@ -1440,6 +1441,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 diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 3dfdde1cef89..191c612b9746 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -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', diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 9be6d29e8922..f6d37e28a615 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -329,6 +329,12 @@ } }, "VLAN": { + "Vlan100": { + "description": "vxlan", + "vlanid": "100", + "mtu": "9216", + "admin_status": "up" + }, "Vlan111": { "description": "svlan", "dhcp_servers": [ @@ -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", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vxlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vxlan.json new file mode 100644 index 000000000000..6bb0507fb050 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vxlan.json @@ -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" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vxlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vxlan.json new file mode 100644 index 000000000000..90e71063cb24 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vxlan.json @@ -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" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-vxlan.yang b/src/sonic-yang-models/yang-models/sonic-vxlan.yang new file mode 100644 index 000000000000..6a9b4ffb5e3b --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-vxlan.yang @@ -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"; + } + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 index 29be032e8876..5bd490367e24 100644 --- a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 +++ b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 @@ -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 {